Skip to content

Commit 4d541c5

Browse files
Zorin95670AntoLC
authored andcommitted
🎨(frontend) Minor refactoring
- improve condition statements - add "no-var" rule in eslint - remove some unnecessary variables Signed-off-by: Zorin95670 <[email protected]>
1 parent e5f029a commit 4d541c5

File tree

10 files changed

+11
-26
lines changed

10 files changed

+11
-26
lines changed

src/frontend/apps/impress/next.config.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ const nextConfig = {
4848
swDest: '../public/service-worker.js',
4949
include: [
5050
({ asset }) => {
51-
if (asset.name.match(/.*(static).*/)) {
52-
return true;
53-
}
54-
return false;
51+
return !!asset.name.match(/.*(static).*/);
5552
},
5653
],
5754
}),

src/frontend/apps/impress/src/api/fetchApi.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ export const fetchAPI = async (
2323
delete headers?.['Content-Type' as keyof typeof headers];
2424
}
2525

26-
const response = await fetch(apiUrl, {
26+
return await fetch(apiUrl, {
2727
...init,
2828
credentials: 'include',
2929
headers,
3030
});
31-
32-
return response;
3331
};

src/frontend/apps/impress/src/core/AppProvider.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ export function AppProvider({ children }: { children: React.ReactNode }) {
3535
);
3636

3737
useEffect(() => {
38-
const cleanupResizeListener = initializeResizeListener();
39-
return cleanupResizeListener;
38+
return initializeResizeListener();
4039
}, [initializeResizeListener]);
4140

4241
useEffect(() => {

src/frontend/apps/impress/src/core/config/api/useConfig.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,11 @@ export function useConfig() {
5353
const cachedData = getCachedTranslation();
5454
const oneHour = 1000 * 60 * 60;
5555

56-
const response = useQuery<ConfigResponse, APIError, ConfigResponse>({
56+
return useQuery<ConfigResponse, APIError, ConfigResponse>({
5757
queryKey: [KEY_CONFIG],
5858
queryFn: () => getConfig(),
5959
initialData: cachedData,
6060
staleTime: oneHour,
6161
initialDataUpdatedAt: Date.now() - oneHour, // Force initial data to be considered stale
6262
});
63-
64-
return response;
6563
}

src/frontend/apps/impress/src/features/docs/doc-editor/hook/useSaveDoc.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const useSaveDoc = (docId: string, yDoc: Y.Doc, canSave: boolean) => {
3131
_updatedDoc: Y.Doc,
3232
transaction: Y.Transaction,
3333
) => {
34-
setIsLocalChange(transaction.local ? true : false);
34+
setIsLocalChange(transaction.local);
3535
};
3636

3737
yDoc.on('update', onUpdate);

src/frontend/apps/impress/src/services/PosthogAnalytic.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,10 @@ export class PostHogAnalytic extends AbstractAnalytic {
2525
}
2626

2727
public isFeatureFlagActivated(flagName: string): boolean {
28-
if (
28+
return !(
2929
posthog.featureFlags.getFlags().includes(flagName) &&
3030
posthog.isFeatureEnabled(flagName) === false
31-
) {
32-
return false;
33-
}
34-
35-
return true;
31+
);
3632
}
3733
}
3834

src/frontend/apps/impress/src/utils/url.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ export function isSafeUrl(url: string): boolean {
4040
}
4141

4242
// Check for directory traversal attempts
43-
if (url.includes('..') || url.includes('../') || url.includes('..\\')) {
44-
return false;
45-
}
46-
47-
return true;
43+
return !(url.includes('..') || url.includes('../') || url.includes('..\\'));
4844
} catch {
4945
return false;
5046
}

src/frontend/packages/eslint-config-impress/common.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const globalRules = {
5656
'error',
5757
{ varsIgnorePattern: '^_', argsIgnorePattern: '^_' },
5858
],
59+
'no-var': 'error',
5960
'react/jsx-curly-brace-presence': [
6061
'error',
6162
{ props: 'never', children: 'never', propElementValues: 'always' },

src/frontend/servers/y-provider/.eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ module.exports = {
1313
rules: {
1414
'@next/next/no-html-link-for-pages': 'off',
1515
},
16-
ignorePatterns: ['node_modules', '.eslintrc.js'],
16+
ignorePatterns: ['node_modules'],
1717
};

src/frontend/servers/y-provider/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var config = {
1+
const config = {
22
rootDir: './__tests__',
33
testEnvironment: 'node',
44
transform: {

0 commit comments

Comments
 (0)