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