-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
264 lines (263 loc) · 8.84 KB
/
.eslintrc.js
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
const rules = {
'accessor-pairs': 'error',
'array-callback-return': 'error',
'default-case-last': 'error',
'dot-notation': 'error',
eqeqeq: 'error',
'func-name-matching': 'error',
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
'grouped-accessor-pairs': 'error',
'max-classes-per-file': 'error',
'new-cap': 'error',
'no-alert': 'error',
'no-array-constructor': 'error',
'no-await-in-loop': 'error',
'no-bitwise': 'error',
'no-caller': 'error',
'no-console': 'warn',
'no-constant-binary-expression': 'error',
'no-constructor-return': 'error',
'no-debugger': 'warn',
'no-duplicate-imports': 'error',
'no-else-return': 'error',
'no-empty-function': 'error',
'no-eval': 'error',
'no-extend-native': 'error',
'no-extra-label': 'error',
'no-implicit-coercion': 'error',
'no-implicit-globals': 'error',
'no-implied-eval': 'error',
'no-iterator': 'error',
'no-label-var': 'error',
'no-labels': 'error',
'no-lonely-if': 'error',
'no-multi-assign': 'error',
'no-new': 'error',
'no-new-func': 'error',
'no-new-object': 'error',
'no-new-wrappers': 'error',
'no-octal-escape': 'error',
'no-promise-executor-return': 'error',
'no-proto': 'error',
'no-return-assign': 'error',
'no-return-await': 'error',
'no-script-url': 'error',
'no-self-compare': 'error',
'no-sequences': 'error',
'no-throw-literal': 'error',
'no-underscore-dangle': ['error', { allow: ['__schema'] }],
'no-unneeded-ternary': 'error',
'no-unreachable-loop': 'error',
'no-unused-private-class-members': 'error',
'no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
ignoreRestSiblings: true,
varsIgnorePattern: '^(React|_)',
},
],
'no-useless-call': 'error',
'no-useless-computed-key': 'error',
'no-useless-concat': 'error',
'no-useless-rename': 'error',
'no-useless-return': 'error',
'no-var': 'error',
'no-warning-comments': 'warn',
'object-shorthand': 'error',
'prefer-arrow-callback': 'error',
'prefer-const': 'error',
'prefer-destructuring': 'error',
'prefer-exponentiation-operator': 'error',
'prefer-object-has-own': 'error',
'prefer-object-spread': 'error',
'prefer-promise-reject-errors': 'error',
'prefer-regex-literals': 'error',
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'prefer-template': 'error',
radix: 'error',
'require-await': 'error',
'require-atomic-updates': 'error',
'sort-imports': [
'error',
{
ignoreDeclarationSort: true,
memberSyntaxSortOrder: ['all', 'single', 'multiple', 'none'],
allowSeparatedGroups: true,
},
],
'symbol-description': 'error',
'react/button-has-type': 'error',
'react/destructuring-assignment': ['error', 'always'],
'react/function-component-definition': [
'error',
{ namedComponents: 'function-declaration' },
],
'react-hooks/exhaustive-deps': 'error',
'react/hook-use-state': 'error',
'react/iframe-missing-sandbox': 'error',
'react/jsx-boolean-value': 'error',
'react/jsx-curly-brace-presence': [
'error',
{ children: 'never', props: 'never', propElementValues: 'always' },
],
'react/jsx-equals-spacing': ['error', 'never'],
'react/jsx-filename-extension': ['error', { extensions: ['.js', '.tsx'] }],
'react/jsx-fragments': ['error', 'syntax'],
'react/jsx-handler-names': 'error',
'react/jsx-key': ['error', { warnOnDuplicates: true }],
'react/jsx-no-constructed-context-values': 'error',
'react/jsx-no-leaked-render': 'error',
'react/jsx-no-script-url': 'error',
'react/jsx-pascal-case': 'error',
'react/jsx-sort-default-props': 'error',
'react/no-access-state-in-setstate': 'error',
'react/no-array-index-key': 'error',
'react/no-danger': 'error',
'react/no-namespace': 'error',
'react/no-this-in-sfc': 'error',
'react/no-typos': 'error',
'react/no-unstable-nested-components': 'error',
'react/no-unused-prop-types': 'error',
'react/prefer-stateless-function': 'error',
'react/prop-types': ['error', { ignore: ['children'] }],
'react/self-closing-comp': 'error',
'react/style-prop-object': 'error',
'react/void-dom-elements-no-children': 'error',
'jsx-a11y/anchor-is-valid': 'off',
}
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 'latest',
sourceType: 'module',
// tsconfigRootDir: __dirname,
// project: ['./tsconfig.json'],
},
env: {
browser: true,
es2021: true,
node: true,
},
plugins: ['react', 'react-hooks', 'jsx-a11y', '@typescript-eslint'],
extends: [
'react-app',
'react-app/jest',
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'plugin:jsx-a11y/recommended',
// 'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier',
],
rules,
overrides: [
{
files: ['**/*.{ts,tsx}'],
extends: [
'react-app',
'react-app/jest',
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'plugin:jsx-a11y/recommended',
'plugin:@typescript-eslint/recommended',
// 'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier',
],
rules: {
...rules,
'@typescript-eslint/consistent-generic-constructors': 'error',
'@typescript-eslint/consistent-indexed-object-style': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-definitions': [
'error',
'interface',
],
// '@typescript-eslint/consistent-type-exports': 'error',
// '@typescript-eslint/consistent-type-imports': 'error',
'default-param-last': 'off',
'@typescript-eslint/default-param-last': 'error',
// 'dot-notation': 'off',
// '@typescript-eslint/dot-notation': 'error',
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/method-signature-style': 'error',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'interface',
format: ['PascalCase'],
custom: {
regex: '^I[A-Z]',
match: true,
},
},
],
// '@typescript-eslint/no-base-to-string': 'error',
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
'@typescript-eslint/no-duplicate-enum-values': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
// '@typescript-eslint/no-for-in-array': 'error',
'no-invalid-this': 'off',
'@typescript-eslint/no-invalid-this': 'error',
'no-loop-func': 'off',
'@typescript-eslint/no-loop-func': 'error',
// '@typescript-eslint/no-meaningless-void-operator': 'error',
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
'no-redeclare': 'off',
'@typescript-eslint/no-redeclare': 'error',
// '@typescript-eslint/no-redundant-type-constituents': 'error',
'@typescript-eslint/no-require-imports': 'error',
// '@typescript-eslint/no-throw-literal': 'error',
// '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
// '@typescript-eslint/no-unnecessary-condition': 'error',
'no-unused-expressions': 'off',
'@typescript-eslint/no-unused-expressions': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
ignoreRestSiblings: true,
varsIgnorePattern: '(React|_)',
},
],
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': 'error',
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-useless-empty-export': 'error',
// '@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-literal-enum-member': 'error',
// '@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
// '@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/prefer-ts-expect-error': 'error',
'@typescript-eslint/unified-signatures': 'error',
},
},
{
files: ['**/*.stories.*'],
rules: {
...rules,
'react/function-component-definition': 'off',
'react/prop-types': 'off',
},
},
{
files: ['**/*.test.{ts,tsx}'],
rules: {
...rules,
'@typescript-eslint/no-explicit-any': 'off',
},
},
],
}