🎨(frontend) Minor refactoring
- improve condition statements - add "no-var" rule in eslint - remove some unnecessary variables Signed-off-by: Zorin95670 <moittie.vincent@gmail.com>
This commit is contained in:
@@ -48,10 +48,7 @@ const nextConfig = {
|
||||
swDest: '../public/service-worker.js',
|
||||
include: [
|
||||
({ asset }) => {
|
||||
if (asset.name.match(/.*(static).*/)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return !!asset.name.match(/.*(static).*/);
|
||||
},
|
||||
],
|
||||
}),
|
||||
|
||||
@@ -23,11 +23,9 @@ export const fetchAPI = async (
|
||||
delete headers?.['Content-Type' as keyof typeof headers];
|
||||
}
|
||||
|
||||
const response = await fetch(apiUrl, {
|
||||
return await fetch(apiUrl, {
|
||||
...init,
|
||||
credentials: 'include',
|
||||
headers,
|
||||
});
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
@@ -35,8 +35,7 @@ export function AppProvider({ children }: { children: React.ReactNode }) {
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const cleanupResizeListener = initializeResizeListener();
|
||||
return cleanupResizeListener;
|
||||
return initializeResizeListener();
|
||||
}, [initializeResizeListener]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -53,13 +53,11 @@ export function useConfig() {
|
||||
const cachedData = getCachedTranslation();
|
||||
const oneHour = 1000 * 60 * 60;
|
||||
|
||||
const response = useQuery<ConfigResponse, APIError, ConfigResponse>({
|
||||
return useQuery<ConfigResponse, APIError, ConfigResponse>({
|
||||
queryKey: [KEY_CONFIG],
|
||||
queryFn: () => getConfig(),
|
||||
initialData: cachedData,
|
||||
staleTime: oneHour,
|
||||
initialDataUpdatedAt: Date.now() - oneHour, // Force initial data to be considered stale
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ const useSaveDoc = (docId: string, yDoc: Y.Doc, canSave: boolean) => {
|
||||
_updatedDoc: Y.Doc,
|
||||
transaction: Y.Transaction,
|
||||
) => {
|
||||
setIsLocalChange(transaction.local ? true : false);
|
||||
setIsLocalChange(transaction.local);
|
||||
};
|
||||
|
||||
yDoc.on('update', onUpdate);
|
||||
|
||||
@@ -25,14 +25,10 @@ export class PostHogAnalytic extends AbstractAnalytic {
|
||||
}
|
||||
|
||||
public isFeatureFlagActivated(flagName: string): boolean {
|
||||
if (
|
||||
return !(
|
||||
posthog.featureFlags.getFlags().includes(flagName) &&
|
||||
posthog.isFeatureEnabled(flagName) === false
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,11 +40,7 @@ export function isSafeUrl(url: string): boolean {
|
||||
}
|
||||
|
||||
// Check for directory traversal attempts
|
||||
if (url.includes('..') || url.includes('../') || url.includes('..\\')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return !(url.includes('..') || url.includes('../') || url.includes('..\\'));
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ const globalRules = {
|
||||
'error',
|
||||
{ varsIgnorePattern: '^_', argsIgnorePattern: '^_' },
|
||||
],
|
||||
'no-var': 'error',
|
||||
'react/jsx-curly-brace-presence': [
|
||||
'error',
|
||||
{ props: 'never', children: 'never', propElementValues: 'always' },
|
||||
|
||||
@@ -13,5 +13,5 @@ module.exports = {
|
||||
rules: {
|
||||
'@next/next/no-html-link-for-pages': 'off',
|
||||
},
|
||||
ignorePatterns: ['node_modules', '.eslintrc.js'],
|
||||
ignorePatterns: ['node_modules'],
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var config = {
|
||||
const config = {
|
||||
rootDir: './__tests__',
|
||||
testEnvironment: 'node',
|
||||
transform: {
|
||||
|
||||
Reference in New Issue
Block a user