Skip to content

Commit 4bcc106

Browse files
committed
performance-optimize
1 parent 75fa631 commit 4bcc106

33 files changed

Lines changed: 1440 additions & 1484 deletions

web/.eslintrc.cjs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,58 @@ module.exports = {
1515
{ allowConstantExport: true },
1616
],
1717
'@typescript-eslint/no-explicit-any': 'off',
18+
19+
// Ban direct useEffect — use useMountEffect, React Query, or derived state instead.
20+
'no-restricted-imports': [
21+
'error',
22+
{
23+
paths: [
24+
{
25+
name: 'react',
26+
importNames: ['useEffect'],
27+
message:
28+
'Direct useEffect is banned. Use useMountEffect() for DOM setup, useQuery/useMutation for data, inline computation for derived state, or event handlers for user actions.',
29+
},
30+
],
31+
},
32+
],
33+
'no-restricted-syntax': [
34+
'error',
35+
{
36+
selector: "CallExpression[callee.name='useEffect']",
37+
message:
38+
'Direct useEffect is banned. Use useMountEffect() from @/hooks/useMountEffect for one-time DOM setup.',
39+
},
40+
{
41+
selector:
42+
"CallExpression[callee.object.name='React'][callee.property.name='useEffect']",
43+
message:
44+
'Direct React.useEffect is banned. Use useMountEffect() from @/hooks/useMountEffect.',
45+
},
46+
],
1847
},
48+
overrides: [
49+
// Approved useEffect zones: hooks (abstraction layer), shadcn/ui primitives (generated), contexts
50+
{
51+
files: [
52+
'src/hooks/**/*.{ts,tsx}',
53+
'src/components/ui/**/*.{ts,tsx}',
54+
'src/components/ThemeProvider.tsx',
55+
'src/contexts/**/*.{ts,tsx}',
56+
],
57+
rules: {
58+
'no-restricted-imports': 'off',
59+
'no-restricted-syntax': 'off',
60+
// These files intentionally export utilities/hooks alongside components
61+
'react-refresh/only-export-components': 'off',
62+
},
63+
},
64+
// Common components intentionally export utility functions alongside components
65+
{
66+
files: ['src/components/common/**/*.{ts,tsx}'],
67+
rules: {
68+
'react-refresh/only-export-components': 'off',
69+
},
70+
},
71+
],
1972
}

0 commit comments

Comments
 (0)