-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheslint.config.mjs
More file actions
98 lines (95 loc) · 2.88 KB
/
Copy patheslint.config.mjs
File metadata and controls
98 lines (95 loc) · 2.88 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
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 { defineConfig } from 'eslint/config'
/**
* Rules intentionally enabled for @laststance/react-next-eslint-plugin v2.2.0.
* Keeping the list explicit means dependency upgrades cannot silently turn on a
* new rule without a focused lint-fix pass in the same PR.
*/
const laststanceReactNextRuleNames = [
'all-memo',
'jsx-no-useless-fragment',
'no-context-provider',
'no-deopt-use-callback',
'no-deopt-use-memo',
'no-direct-use-effect',
'no-duplicate-key',
'no-forward-ref',
'no-jsx-without-return',
'no-missing-button-type',
'no-missing-component-display-name',
'no-missing-key',
'no-nested-component-definitions',
'no-set-state-prop-drilling',
'no-use-reducer',
'prefer-stable-context-value',
'prefer-usecallback-for-memoized-component',
'prefer-usecallback-might-work',
'prefer-usememo-for-memoized-component',
'prefer-usememo-might-work',
]
const laststanceReactNextRules = Object.fromEntries(
laststanceReactNextRuleNames.map((ruleName) => [
`@laststance/react-next/${ruleName}`,
'error',
]),
)
export default defineConfig([
...tsPrefixer,
{
languageOptions: {
parserOptions: {
tsconfigRootDir: import.meta.dirname,
},
},
},
{
ignores: [
'out/**',
'dist/**',
'node_modules/**',
'coverage/**',
'*.config.js',
'*.config.ts',
'*.config.mjs',
'.storybook/**',
'storybook-static/**',
'.pnpmfile.cjs',
'scripts/**',
'website/**',
],
},
// 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-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',
},
},
{
plugins: {
'@laststance/react-next': laststanceReactNextPlugin,
},
rules: {
...laststanceReactNextRules,
// Keep the stricter prop-drilling depth while still enforcing the rule at error severity.
'@laststance/react-next/no-set-state-prop-drilling': [
'error',
{ depth: 1 },
],
},
},
])