🎨(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:
Zorin95670
2025-05-07 12:04:08 +02:00
committed by Anthony LC
parent e5f029ad1d
commit 4d541c5d52
10 changed files with 11 additions and 26 deletions

View File

@@ -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).*/);
},
],
}),

View File

@@ -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;
};

View File

@@ -35,8 +35,7 @@ export function AppProvider({ children }: { children: React.ReactNode }) {
);
useEffect(() => {
const cleanupResizeListener = initializeResizeListener();
return cleanupResizeListener;
return initializeResizeListener();
}, [initializeResizeListener]);
useEffect(() => {

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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;
);
}
}

View File

@@ -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;
}