-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
347 lines (330 loc) · 11 KB
/
eslint.config.mjs
File metadata and controls
347 lines (330 loc) · 11 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
// For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format
import { defineConfig, globalIgnores } from 'eslint/config'
import nextPlugin from '@next/eslint-plugin-next'
import eslintPluginReactHooks from 'eslint-plugin-react-hooks'
import jsxA11y from 'eslint-plugin-jsx-a11y'
import globals from 'globals'
import laststanceReactNextPlugin from '@laststance/react-next-eslint-plugin'
import tsPrefixer from 'eslint-config-ts-prefixer'
import reactYouMightNotNeedAnEffect from 'eslint-plugin-react-you-might-not-need-an-effect'
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript'
export default defineConfig([
// ts-prefixer: @typescript-eslint + import-x + parser
...tsPrefixer,
// Override ts-prefixer legacy resolver with new import-x/resolver-next format
{
settings: {
'import-x/resolver-next': [
createTypeScriptImportResolver({
alwaysTryTypes: true,
}),
],
},
},
// React "You Might Not Need an Effect" rules (explicit instead of configs.recommended)
{
plugins: {
'react-you-might-not-need-an-effect': reactYouMightNotNeedAnEffect,
},
rules: {
'react-you-might-not-need-an-effect/no-empty-effect': 'error',
'react-you-might-not-need-an-effect/no-adjust-state-on-prop-change':
'error',
'react-you-might-not-need-an-effect/no-reset-all-state-on-prop-change':
'error',
'react-you-might-not-need-an-effect/no-event-handler': 'error',
'react-you-might-not-need-an-effect/no-pass-live-state-to-parent':
'error',
'react-you-might-not-need-an-effect/no-pass-data-to-parent': 'error',
'react-you-might-not-need-an-effect/no-initialize-state': 'error',
'react-you-might-not-need-an-effect/no-chain-state-updates': 'error',
'react-you-might-not-need-an-effect/no-derived-state': 'error',
},
},
// Global ignores
globalIgnores([
'**/.vscode/**',
'**/node_modules/**',
'**/build/**',
'**/dist/**',
'**/.github/**',
'**/.git/**',
'**/.idea/**',
'.next/**',
'out/**',
'next-env.d.ts',
'**/storybook-static/**',
'**/mockServiceWorker.js',
'**/tests-examples/**',
'./playwright-report/**',
'./test-results/**',
'./e2e/tablet/**',
'./e2e/tablet-landscape/**',
'.storybook/**',
'**/.husky/**',
'_trials/**',
'src/lib/supabase/types.ts',
'src/lib/supabase/database.types.ts',
'src/lib/github/api.ts',
'e2e/**',
'**/*.backup/**',
'**/.backup/**',
'**/coverage/**',
'**/coverage-e2e/**',
'public/sw.js',
// Config files not in tsconfig
'eslint.config.mjs',
'postcss.config.mjs',
'tailwind.config.js',
'playwright.config.ts',
// Package examples (have their own ESLint configs)
'**/packages/**/examples/**',
// Package benchmarks use console.log for output
'**/packages/**/benchmarks/**',
]),
// react-hooks + @next/next plugins
{
files: ['**/*.{js,jsx,mjs,ts,tsx,mts,cts}'],
plugins: {
'react-hooks': eslintPluginReactHooks,
'jsx-a11y': jsxA11y,
'@next/next': nextPlugin,
},
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
},
rules: {
// ── react-hooks (individual, no recommended) ──
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'error',
// ── jsx-a11y (individual, no recommended) ──
'jsx-a11y/alt-text': [
'error',
{
elements: ['img'],
img: ['Image'],
},
],
'jsx-a11y/aria-props': 'error',
'jsx-a11y/aria-proptypes': 'error',
'jsx-a11y/aria-unsupported-elements': 'error',
'jsx-a11y/role-has-required-aria-props': 'error',
'jsx-a11y/role-supports-aria-props': 'error',
// ── @next/next (ALL 21 rules as error) ──
'@next/next/google-font-display': 'error',
'@next/next/google-font-preconnect': 'error',
'@next/next/inline-script-id': 'error',
'@next/next/next-script-for-ga': 'error',
'@next/next/no-assign-module-variable': 'error',
'@next/next/no-async-client-component': 'error',
'@next/next/no-before-interactive-script-outside-document': 'error',
'@next/next/no-css-tags': 'error',
'@next/next/no-document-import-in-page': 'error',
'@next/next/no-duplicate-head': 'error',
'@next/next/no-head-element': 'error',
'@next/next/no-head-import-in-document': 'error',
'@next/next/no-html-link-for-pages': 'error',
'@next/next/no-img-element': 'error',
'@next/next/no-page-custom-font': 'error',
'@next/next/no-script-component-in-head': 'error',
'@next/next/no-styled-jsx-in-document': 'error',
'@next/next/no-sync-scripts': 'error',
'@next/next/no-title-in-document-head': 'error',
'@next/next/no-typos': 'error',
'@next/next/no-unwanted-polyfillio': 'error',
},
},
// Project-specific rules
{
rules: {
'no-restricted-globals': [
'error',
{
name: 'localStorage',
message:
'Do not use localStorage directly. Use redux-storage-middleware.',
},
{
name: 'fetch',
message:
'Use axios instead of fetch for MSW compatibility. Import from lib/axios.ts.',
},
],
'no-restricted-properties': [
'error',
{
object: 'window',
property: 'localStorage',
message:
'Do not use window.localStorage directly. Use redux-storage-middleware.',
},
{
object: 'globalThis',
property: 'localStorage',
message:
'Do not use globalThis.localStorage directly. Use redux-storage-middleware.',
},
{
object: 'JSON',
property: 'parse',
message:
"Use destr() from 'destr' instead of JSON.parse for safe parsing.",
},
],
// Ban revalidatePath/revalidateTag - Supabase SDK doesn't use Next.js cache
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'next/cache',
importNames: ['revalidatePath', 'revalidateTag'],
message:
'Supabase SDK does not use Next.js cache. Use Redux optimistic updates instead.',
},
],
},
],
// Ban console usage - use logger (server) or Sentry (client) instead
'no-console': 'error',
},
},
// @laststance/react-next-eslint-plugin rules
{
plugins: {
'@laststance/react-next': laststanceReactNextPlugin,
},
rules: {
'@laststance/react-next/no-forward-ref': 'error',
'@laststance/react-next/no-context-provider': 'error',
'@laststance/react-next/no-missing-key': 'error',
'@laststance/react-next/no-duplicate-key': 'error',
'@laststance/react-next/no-jsx-without-return': 'error',
'@laststance/react-next/all-memo': 'error',
'@laststance/react-next/no-use-reducer': 'error',
'@laststance/react-next/no-set-state-prop-drilling': [
'error',
{ depth: 1 },
],
'@laststance/react-next/no-deopt-use-callback': 'error',
'@laststance/react-next/prefer-stable-context-value': 'error',
},
},
// Page components don't need memo
{
files: ['**/src/app/**/page.tsx'],
rules: {
'@laststance/react-next/all-memo': 'off',
},
},
// next.config allows require imports
{
files: ['next.config.js', 'next.config.ts'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
},
},
// Test files - relaxed rules
{
files: [
'**/*.test.ts',
'**/*.test.tsx',
'**/*.spec.ts',
'**/*.spec.tsx',
'tests/**/*',
],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
// localStorage and JSON.parse checks in tests are acceptable for verification.
// Keep fetch banned for axios/MSW consistency.
'no-restricted-globals': [
'error',
{
name: 'fetch',
message:
'Use axios instead of fetch for MSW compatibility. Import from lib/axios.ts.',
},
],
// Allow localStorage and JSON.parse in tests (E2E page.evaluate can't import destr).
'no-restricted-properties': 'off',
},
},
// Storybook files
{
files: ['**/*.stories.tsx', '**/*.stories.ts'],
rules: {
// Allow console in Storybook stories for demo callbacks
'no-console': 'off',
},
},
// Plate UI components from registry - relax rules for auto-generated code
{
files: [
'src/components/ui/*-node.tsx',
'src/components/ui/*-node-static.tsx',
'src/components/ui/*-toolbar-button.tsx',
'src/components/ui/*-toolbar.tsx',
'src/components/ui/toolbar.tsx',
'src/components/ui/comment.tsx',
'src/components/ui/caption.tsx',
'src/components/ui/calendar.tsx',
'src/components/ui/command.tsx',
'src/components/ui/resize-handle.tsx',
'src/components/ui/inline-combobox.tsx',
'src/components/ui/block-*.tsx',
'src/components/ui/dropdown-menu.tsx',
'src/components/ui/table-icons.tsx',
'src/components/ui/alert-dialog.tsx',
'src/components/ui/suggestion-*.tsx',
'src/components/ui/editor.tsx',
'src/components/ui/editor-static.tsx',
'src/components/ui/media-*.tsx',
'src/components/ui/fixed-toolbar*.tsx',
'src/components/ui/floating-toolbar*.tsx',
'src/components/editor/plugins/*.tsx',
'src/components/editor/transforms.ts',
],
rules: {
'@laststance/react-next/all-memo': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/promise-function-async': 'off',
'@next/next/no-img-element': 'off',
// Allow console.warn in Plate editor transforms (external library pattern)
'no-console': 'off',
// Plate UI components use patterns that trigger these rules
'react-you-might-not-need-an-effect/no-derived-state': 'off',
'react-you-might-not-need-an-effect/no-pass-data-to-parent': 'off',
'react-you-might-not-need-an-effect/no-initialize-state': 'off',
},
},
// BoardPageClient - theme application exception
{
files: ['**/src/app/board/*/BoardPageClient.tsx'],
rules: {
'react-you-might-not-need-an-effect/no-event-handler': 'off',
'react-you-might-not-need-an-effect/no-chain-state-updates': 'off',
},
},
// Combobox/Dialog patterns
{
files: [
'src/components/Board/AddRepositoryCombobox.tsx',
'src/app/maintenance/MaintenanceClient.tsx',
],
rules: {
'react-you-might-not-need-an-effect/no-event-handler': 'off',
'react-you-might-not-need-an-effect/no-derived-state': 'off',
'react-you-might-not-need-an-effect/no-chain-state-updates': 'off',
},
},
// Command palette - global keyboard handler exception
{
files: ['src/components/CommandPalette/CommandPalette.tsx'],
rules: {
'react-you-might-not-need-an-effect/no-event-handler': 'off',
},
},
])