-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
366 lines (365 loc) · 13 KB
/
index.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
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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
module.exports = {
parser: '@typescript-eslint/parser',
env: { browser: true, node: true },
plugins: [
'react',
'react-hooks',
'react-perf',
'no-loops',
'jsdoc',
'@typescript-eslint',
'@getify/proper-arrows',
],
root: true,
settings: {
react: { version: 'detect' },
jsdoc: {
mode: 'typescript',
},
},
parserOptions: {
project: true,
},
ignorePatterns: ['**/*.d.ts'],
rules: {
'no-console': 'warn',
'for-direction': 'error',
'getter-return': 'error',
'no-async-promise-executor': 'error',
'no-await-in-loop': 'error',
'no-compare-neg-zero': 'error',
'no-cond-assign': 'error',
'no-constant-condition': 'error',
'no-control-regex': 'error',
'no-debugger': 'error',
'no-dupe-args': 'error',
'no-dupe-else-if': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'error',
'no-empty': 'error',
'no-empty-character-class': 'error',
'no-ex-assign': 'error',
'no-extra-boolean-cast': 'error',
'no-extra-semi': 'error',
'no-func-assign': 'error',
'no-import-assign': 'error',
'no-inner-declarations': 'error',
'no-invalid-regexp': 'error',
'no-irregular-whitespace': 'error',
'no-misleading-character-class': 'error',
'no-obj-calls': 'error',
'no-promise-executor-return': 'error',
'no-prototype-builtins': 'error',
'no-regex-spaces': 'error',
'no-setter-return': 'error',
'no-sparse-arrays': 'error',
'no-template-curly-in-string': 'error',
'no-unexpected-multiline': 'error',
'no-unreachable': 'error',
'no-unreachable-loop': 'error',
'no-unsafe-finally': 'error',
'no-unsafe-negation': 'error',
'no-unsafe-optional-chaining': 'error',
'require-atomic-updates': 'error',
'use-isnan': 'error',
'valid-typeof': 'error',
'array-callback-return': 'error',
'block-scoped-var': 'error',
'class-methods-use-this': 'error',
complexity: ['error', { max: 25 }],
'consistent-return': 'error',
'default-case': 'error',
'default-case-last': 'error',
eqeqeq: 'error',
'max-classes-per-file': ['error', 5],
'no-alert': 'error',
'no-case-declarations': 'error',
'no-constructor-return': 'error',
'no-else-return': 'error',
'no-empty-function': 'error',
'no-empty-pattern': 'error',
'no-eval': 'error',
'no-extra-label': 'error',
'no-fallthrough': 'error',
'no-floating-decimal': 'error',
'no-global-assign': 'error',
'no-implicit-coercion': 'error',
'no-implicit-globals': 'error',
'no-iterator': 'error',
'no-labels': 'error',
'no-lone-blocks': 'error',
'no-new': 'error',
'no-new-func': 'error',
'no-new-wrappers': 'error',
'no-octal': 'error',
'no-param-reassign': 'error',
'no-return-assign': 'error',
'no-self-assign': 'error',
'no-sequences': 'error',
'no-with': 'error',
'prefer-promise-reject-errors': 'error',
'prefer-regex-literals': 'error',
radix: 'error',
'require-unicode-regexp': 'error',
yoda: 'error',
'no-shadow-restricted-names': 'error',
'no-restricted-exports': [
'error',
{
restrictDefaultExports: {
direct: true,
named: true,
defaultFrom: true,
namedFrom: true,
namespaceFrom: true,
},
},
],
'arrow-body-style': ['error', 'as-needed'],
'constructor-super': 'error',
'no-const-assign': 'error',
'no-dupe-class-members': 'error',
'no-duplicate-imports': 'warn',
'no-this-before-super': 'error',
'no-var': 'error',
'object-shorthand': 'error',
'prefer-arrow-callback': 'error',
'prefer-const': [
'error',
{
destructuring: 'all',
},
],
'prefer-destructuring': 'error',
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'prefer-template': 'error',
'react/button-has-type': 'error',
'react/function-component-definition': [
'error',
{ namedComponents: 'function-declaration', unnamedComponents: 'arrow-function' },
],
'react/no-array-index-key': 'error',
'react/no-children-prop': 'error',
'react/no-danger-with-children': 'error',
'react/no-deprecated': 'error',
'react/no-did-mount-set-state': 'error',
'react/no-did-update-set-state': 'error',
'react/no-direct-mutation-state': 'error',
'react/no-this-in-sfc': 'error',
'react/no-typos': 'error',
'react/no-unknown-property': 'error',
'react/no-unsafe': 'error',
'react/no-unused-state': 'error',
'react/prefer-stateless-function': 'error',
'react/self-closing-comp': 'error',
'react/jsx-boolean-value': 'error',
'react/jsx-key': 'error',
'react/jsx-max-depth': ['error', { max: 15 }],
'react/jsx-no-duplicate-props': 'error',
'react/jsx-no-useless-fragment': 'error',
'react/state-in-constructor': ['error', 'always'],
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'error',
'no-loops/no-loops': 'error',
'react-perf/jsx-no-new-object-as-prop': ['error', { nativeAllowList: 'all' }],
'react-perf/jsx-no-new-array-as-prop': ['error', { nativeAllowList: 'all' }],
'react-perf/jsx-no-new-function-as-prop': ['error', { nativeAllowList: 'all' }],
'jsdoc/check-alignment': 1,
'jsdoc/check-indentation': 1,
'jsdoc/check-param-names': 1,
'jsdoc/check-tag-names': 1,
'jsdoc/check-types': 1,
'jsdoc/empty-tags': 1,
'jsdoc/multiline-blocks': 1,
'jsdoc/newline-after-description': 1,
'jsdoc/no-multi-asterisks': 1,
'jsdoc/no-undefined-types': 1,
'jsdoc/require-asterisk-prefix': ['error', 'always'],
'jsdoc/require-jsdoc': [
'error',
{
require: {
ClassDeclaration: true,
ClassExpression: true,
MethodDefinition: true,
ArrowFunctionExpression: false,
FunctionDeclaration: false,
FunctionExpression: false,
},
checkConstructors: false,
},
],
'jsdoc/require-param-description': 1,
'jsdoc/require-param-name': 1,
'jsdoc/require-param-type': 0,
'jsdoc/require-param': 1,
'jsdoc/require-property': 1,
'jsdoc/require-property-description': 1,
'jsdoc/require-property-name': 1,
'jsdoc/require-property-type': 1,
'jsdoc/require-returns-check': 1,
'jsdoc/require-returns-description': 1,
'jsdoc/require-returns-type': 0,
'jsdoc/require-returns': 1,
'jsdoc/require-throws': 1,
'@getify/proper-arrows/where': [
'error',
{ global: false, export: true, 'global-declaration': true, property: false, trivial: false },
],
'@getify/proper-arrows/return': [
'error',
{ object: false, chained: false, ternary: 1, sequence: true, trivial: false },
],
'@typescript-eslint/array-type': [
'warn',
{
default: 'array-simple',
readonly: 'array-simple',
},
],
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/ban-types': 'error',
'@typescript-eslint/consistent-generic-constructors': 'error',
'@typescript-eslint/consistent-indexed-object-style': 'error',
'@typescript-eslint/consistent-type-assertions': ['error', { assertionStyle: 'as' }],
'@typescript-eslint/consistent-type-definitions': ['error', 'type'], // maybe we should switch to interface instead
'@typescript-eslint/consistent-type-exports': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'variable',
types: ['boolean'],
format: ['PascalCase'],
prefix: ['is', 'should', 'has', 'can', 'did', 'will'],
},
{ selector: 'variableLike', format: ['camelCase', 'UPPER_CASE'] },
{
selector: ['function'],
format: ['camelCase', 'PascalCase'],
leadingUnderscore: 'allow',
},
{
selector: 'interface',
format: ['PascalCase'],
custom: {
regex: '^I[A-Z]',
match: false,
},
},
{
selector: [
'classProperty',
'objectLiteralProperty',
'typeProperty',
'classMethod',
'objectLiteralMethod',
'typeMethod',
'accessor',
'enumMember',
],
format: null,
modifiers: ['requiresQuotes'],
},
],
'@typescript-eslint/no-confusing-void-expression': 'error',
'@typescript-eslint/no-duplicate-enum-values': 'error',
'@typescript-eslint/no-duplicate-type-constituents': 'error',
'@typescript-eslint/no-dynamic-delete': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-import-type-side-effects': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-invalid-void-type': 'error',
'@typescript-eslint/no-meaningless-void-operator': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-misused-promises': [
'error',
{
checksConditionals: true,
checksVoidReturn: true,
checksSpreads: true,
},
],
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-redundant-type-constituents': 'error',
'@typescript-eslint/no-require-imports': 'warn',
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
'@typescript-eslint/no-unsafe-argument': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
'@typescript-eslint/no-useless-empty-export': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/parameter-properties': 'error',
'@typescript-eslint/prefer-as-const': 'error',
'@typescript-eslint/prefer-enum-initializers': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-function-type': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-literal-enum-member': 'error',
'@typescript-eslint/prefer-namespace-keyword': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-readonly-parameter-types': 'off', // only because React.Node is mutable
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
'@typescript-eslint/prefer-regexp-exec': 'error',
'@typescript-eslint/prefer-return-this-type': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/prefer-ts-expect-error': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/restrict-template-expressions': 'error',
'@typescript-eslint/strict-boolean-expressions': [
'error',
{
allowNullableBoolean: true,
},
],
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'@typescript-eslint/unified-signatures': 'error',
'@typescript-eslint/default-param-last': 'error',
'@typescript-eslint/dot-notation': 'error',
'@typescript-eslint/init-declarations': ['error', 'always'],
'@typescript-eslint/no-invalid-this': 'error',
'@typescript-eslint/no-loop-func': 'error',
'@typescript-eslint/no-loss-of-precision': 'error',
'@typescript-eslint/no-magic-numbers': [
'warn',
{
ignore: [-1, 0, 1, 1000, 60, 24, 12],
detectObjects: false,
ignoreDefaultValues: true,
ignoreEnums: true,
ignoreNumericLiteralTypes: true,
ignoreReadonlyClassProperties: true,
ignoreTypeIndexes: true,
},
],
'@typescript-eslint/no-redeclare': 'error',
'@typescript-eslint/no-throw-literal': 'error',
'@typescript-eslint/no-unused-expressions': 'error',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-use-before-define': 'error',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/return-await': ['error', 'in-try-catch'],
},
};