-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy patheslint.config.mjs
More file actions
183 lines (173 loc) · 6.85 KB
/
eslint.config.mjs
File metadata and controls
183 lines (173 loc) · 6.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format
let storybook = null;
try {
storybook = (await import('eslint-plugin-storybook')).default;
} catch {
storybook = null;
}
import importPlugin from 'eslint-plugin-import';
import nextCoreWebVitals from 'eslint-config-next/core-web-vitals';
import nextTypescript from 'eslint-config-next/typescript';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
const eslintConfig = [
...nextCoreWebVitals,
...nextTypescript,
{
ignores: ['.next/**/*', 'next-env.d.ts'],
},
{
plugins: {
import: importPlugin,
react: reactPlugin,
'react-hooks': reactHooksPlugin,
},
rules: {
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-require-imports': 'warn',
'no-console': ['warn', { allow: ['warn', 'error'] }],
'import/no-restricted-paths': 'warn',
'react/no-unescaped-entities': 'warn',
'react-hooks/immutability': 'warn',
'react-hooks/preserve-manual-memoization': 'warn',
'react-hooks/purity': 'warn',
'react-hooks/set-state-in-effect': 'warn',
// Trailing commas are handled by Prettier, not enforced by ESLint
'comma-dangle': 'off',
// Layer Enforcement Rules - Hybrid Modular Architecture
'import/no-restricted-paths': [
'warn',
{
zones: [
// Rule 1: shared/ CANNOT import from features/
{
target: './shared',
from: './features/*/store',
message:
'shared/ layer cannot import from feature stores directly. Use facades exported from features/*/index.ts instead.',
},
{
target: './shared',
from: './features/*/data',
message:
'shared/ layer cannot import from feature data directly. Use facades exported from features/*/index.ts instead.',
},
{
target: './shared',
from: './features/*/lib',
message:
'shared/ layer cannot import from feature internal lib directly. Use facades exported from features/*/index.ts instead.',
},
// Rule 2: widgets/ CANNOT import from feature stores or data
{
target: './widgets',
from: './features/*/store',
message:
'widgets/ cannot import from feature stores directly. Use facades exported from features/*/index.ts instead.',
},
{
target: './widgets',
from: './features/*/data',
message:
'widgets/ cannot import from feature data directly. Use facades exported from features/*/index.ts instead.',
},
// Rule 3: Features CANNOT import from other features' internal directories
{
target: './features/!(Kana)/**/*',
from: './features/Kana/store',
message:
'Cannot import from Kana internal store. Use facade from features/Kana/index.ts instead.',
},
{
target: './features/!(Kana)/**/*',
from: './features/Kana/lib',
message:
'Cannot import from Kana internal lib. Use public API from features/Kana/index.ts instead.',
},
{
target: './features/!(Kana)/**/*',
from: './features/Kana/data',
message:
'Cannot import from Kana internal data. Use facade from features/Kana/index.ts instead.',
},
{
target: './features/!(Kanji)/**/*',
from: './features/Kanji/store',
message:
'Cannot import from Kanji internal store. Use facade from features/Kanji/index.ts instead.',
},
{
target: './features/!(Kanji)/**/*',
from: './features/Kanji/lib',
message:
'Cannot import from Kanji internal lib. Use public API from features/Kanji/index.ts instead.',
},
{
target: './features/!(Kanji)/**/*',
from: './features/Kanji/data',
message:
'Cannot import from Kanji internal data. Use facade from features/Kanji/index.ts instead.',
},
{
target: './features/!(Vocabulary)/**/*',
from: './features/Vocabulary/store',
message:
'Cannot import from Vocabulary internal store. Use facade from features/Vocabulary/index.ts instead.',
},
{
target: './features/!(Vocabulary)/**/*',
from: './features/Vocabulary/lib',
message:
'Cannot import from Vocabulary internal lib. Use public API from features/Vocabulary/index.ts instead.',
},
{
target: './features/!(Vocabulary)/**/*',
from: './features/Vocabulary/data',
message:
'Cannot import from Vocabulary internal data. Use facade from features/Vocabulary/index.ts instead.',
},
{
target: './features/!(Progress)/**/*',
from: './features/Progress/store',
message:
'Cannot import from Progress internal store. Use facade from features/Progress/index.ts instead.',
},
{
target: './features/!(Progress)/**/*',
from: './features/Progress/lib',
message:
'Cannot import from Progress internal lib. Use public API from features/Progress/index.ts instead.',
},
{
target: './features/!(Preferences)/**/*',
from: './features/Preferences/store',
message:
'Cannot import from Preferences internal store. Use facade from features/Preferences/index.ts instead.',
},
{
target: './features/!(Preferences)/**/*',
from: './features/Preferences/lib',
message:
'Cannot import from Preferences internal lib. Use public API from features/Preferences/index.ts instead.',
},
{
target: './features/!(Preferences)/**/*',
from: './features/Preferences/data',
message:
'Cannot import from Preferences internal data. Use facade from features/Preferences/index.ts instead.',
},
],
},
],
},
},
...(storybook ? storybook.configs['flat/recommended'] : []),
];
export default eslintConfig;