forked from ant-design/ant-design
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
169 lines (168 loc) · 5.65 KB
/
eslint.config.mjs
File metadata and controls
169 lines (168 loc) · 5.65 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
// eslint.config.mjs
import antfu from '@antfu/eslint-config';
import compat from 'eslint-plugin-compat';
import jest from 'eslint-plugin-jest';
import jsxA11y from 'eslint-plugin-jsx-a11y';
export default antfu(
{
ignores: [
'**/node_modules/**',
'**/dist/**',
'**/_site/**',
'**/es/**',
'**/lib/**',
'**/.dumi/tmp/**',
'**/.dumi/tmp-production/**',
'**/*.snap',
'**/*.md',
'.dumi/scripts/clarity.js',
],
settings: {
polyfills: ['Promise', 'URL'],
},
type: 'lib',
stylistic: false,
typescript: true,
react: true,
rules: {
'react/jsx-key-before-spread': 'off',
'node/prefer-global/process': 'off', // TODO: remove this
'node/prefer-global/buffer': 'off', // TODO: remove this
'jsdoc/empty-tags': 'off',
'ts/explicit-function-return-type': 'off',
'ts/ban-ts-comment': 'off', // TODO: remove this
'ts/consistent-type-definitions': 'off',
'ts/no-non-null-asserted-optional-chain': 'off',
'unicorn/prefer-node-protocol': 'off',
'unicorn/prefer-string-starts-ends-with': 'off', // TODO: remove this
'regexp/no-unused-capturing-group': 'off',
'regexp/no-misleading-capturing-group': 'off',
'regexp/no-super-linear-backtracking': 'off', // TODO: remove this
'regexp/optimal-quantifier-concatenation': 'off',
'react-hooks/exhaustive-deps': 'off',
'react-refresh/only-export-components': 'off', // TODO: remove this
'react/no-clone-element': 'off',
'react/no-children-for-each': 'off',
'react/no-children-map': 'off',
'react/no-children-only': 'off',
'react/prefer-namespace-import': 'off',
'react/no-create-ref': 'off', // TODO: remove this
'perfectionist/sort-imports': 'off',
'regexp/strict': 'off',
/* turn off React 19 only rules */
'react/no-forward-ref': 'off',
'react/no-context-provider': 'off',
'react/no-use-context': 'off',
'react-hooks-extra/no-direct-set-state-in-use-effect': 'off',
/* turn off 升级 @antfu/eslint-config@6 带来的 warning */
'react/no-unnecessary-use-prefix': 'off',
'react-hooks/use-memo': 'off',
'react-hooks/globals': 'off',
'react-hooks/preserve-manual-memoization': 'off',
'react-hooks/set-state-in-effect': 'off',
'react-hooks/refs': 'off',
'react/no-implicit-key': 'off',
/* e18e rules */
'e18e/prefer-spread-syntax': 'off',
'e18e/prefer-static-regex': 'off',
'e18e/prefer-array-at': 'off',
'e18e/prefer-timer-args': 'off',
'e18e/prefer-array-fill': 'off',
'e18e/prefer-array-to-reversed': 'off',
'e18e/prefer-array-to-spliced': 'off',
'e18e/prefer-array-to-sorted': 'off',
'e18e/prefer-array-from-map': 'off',
'e18e/prefer-date-now': 'off',
'e18e/prefer-object-has-own': 'off',
},
},
{
...compat.configs['flat/recommended'],
rules: {
...compat.configs['flat/recommended'].rules,
'compat/compat': 'off', // Disabled due to incompatibility with ESLint 10.0.0
},
},
jest.configs['flat/recommended'],
{
...jsxA11y.flatConfigs.recommended,
rules: {
...jsxA11y.flatConfigs.recommended.rules,
'jsx-a11y/no-noninteractive-element-interactions': 'off',
'jsx-a11y/no-static-element-interactions': 'off',
'jsx-a11y/click-events-have-key-events': 'off',
'jsx-a11y/no-autofocus': 'off',
'jsx-a11y/anchor-is-valid': 'off', // TODO: remove this
},
},
{
// commonjs, build entry, and script files
files: ['**/*.js', '**/*.cjs', '**/*.mjs', 'scripts/**/*.ts', 'scripts/**/*.tsx'],
rules: {
'ts/no-require-imports': 'off',
},
},
{
// tests
files: ['**/*.test.ts', 'tests/**/*', '**/__tests__/**/*', 'scripts/**/*', '**/*.test.tsx'],
rules: {
'react-hooks/immutability': 'off',
'test/prefer-lowercase-title': 'off',
'react/no-create-ref': 'off',
'react/no-nested-component-definitions': 'off',
'react/no-nested-components': 'off',
'react/no-useless-fragment': 'off',
'no-console': 'off',
'no-restricted-globals': 'off',
'unicorn/consistent-function-scoping': 'off',
'ts/no-non-null-asserted-optional-chain': 'off',
'compat/compat': 'off',
'jest/no-test-callback': 'off',
'jest/expect-expect': 'off',
'jest/no-done-callback': 'off',
'jest/valid-title': 'off',
'jest/no-conditional-expect': 'off',
'jest/no-standalone-expect': 'off',
'jsx-a11y/anchor-is-valid': 'off',
'jsx-a11y/anchor-has-content': 'off',
'prefer-promise-reject-errors': 'off',
},
},
{
// demos
files: ['components/*/demo/*.tsx'],
rules: {
'react-naming-convention/ref-name': 'off',
'react/no-create-ref': 'off',
'no-console': 'off',
'unicorn/consistent-function-scoping': 'off',
'jsx-a11y/anchor-is-valid': 'off',
'jsx-a11y/anchor-has-content': 'off',
},
settings: {
polyfills: ['Promise', 'URL', 'fetch', 'requestAnimationFrame'],
},
},
{
// dumi site
files: ['.dumi/**/*'],
rules: {
'react-refresh/only-export-components': 'off', // TODO: remove this
'react-dom/no-dangerously-set-innerhtml': 'off', // TODO: remove this
'react/no-array-index-key': 'off',
'react-dom/no-missing-iframe-sandbox': 'off',
'no-restricted-globals': 'off',
'react/no-use-context': 'warn',
},
settings: {
polyfills: ['Promise', 'URL', 'fetch', 'URLSearchParams'],
},
},
{
// locales
files: ['components/locale/*.ts', 'components/form/demo/*.tsx'],
rules: {
'no-template-curly-in-string': 'off',
},
},
);