/
index.js
366 lines (355 loc) · 15.3 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',
parserOptions: { sourceType: 'module' },
plugins: [
'@typescript-eslint',
'react-hooks',
'functional',
'react',
'import',
'node',
],
rules: {
/**
* ESLint rules
* https://eslint.org/docs/rules/
* based on version 6.8.0
*/
/**
* Possible Errors
*
* These are unusual cases that are most often errors rather than intended code.
* If you find an actual use case for any of these that cannot be worked around,
* please open an issue describing your use case.
*/
/** Enforce "for" loop update clause moving the counter in the right direction. */
'for-direction': 'error',
/** Enforce `return` statements in getters */
'getter-return': 'error',
/** Disallow using an async function as a Promise executor */
'no-async-promise-executor': 'error',
/** Disallow lexical declarations in case clauses */
'no-case-declarations': 'error',
/** Disallow comparing against -0 */
'no-compare-neg-zero': 'error',
/** Disallow assignment operators in conditional expressions */
'no-cond-assign': 'error',
/** Disallow constant expressions in conditions */
'no-constant-condition': 'error',
/** Disallow control characters in regular expressions */
'no-control-regex': 'error',
/** Disallow the use of `debugger` */
'no-debugger': 'error',
/** Disallow duplicate arguments in `function` definitions */
'no-dupe-args': 'error',
/** Disallow duplicate conditions in if-else-if chains */
'no-dupe-else-if': 'error',
/** Disallow duplicate keys in object literals */
'no-dupe-keys': 'error',
/** Disallow duplicate case labels */
'no-duplicate-case': 'error',
/** Disallow empty block statements */
'no-empty': 'error',
/** Disallow empty character classes in regular expressions */
'no-empty-character-class': 'error',
/** Disallow reassigning exceptions in `catch` clauses */
'no-ex-assign': 'error',
/** Disallow unnecessary boolean casts */
'no-extra-boolean-cast': 'error',
/** Disallow reassigning `function` declarations */
'no-func-assign': 'error',
/** Disallow assigning to imported bindings */
'no-import-assign': 'error',
/** Disallow variable or `function` declarations in nested blocks */
'no-inner-declarations': 'error',
/** Disallow invalid regular expression strings in `RegExp` constructors */
'no-invalid-regexp': 'error',
/** Disallow irregular whitespace */
'no-irregular-whitespace': 'error',
/** Disallow characters which are made with multiple code points in character class syntax */
'no-misleading-character-class': 'error',
/** Disallow calling global object properties as functions */
'no-obj-calls': 'error',
/** Disallow calling some `Object.prototype` methods directly on objects */
'no-prototype-builtins': 'error',
/** Disallow multiple spaces in regular expressions */
'no-regex-spaces': 'error',
/** Disallow returning values from setters */
'no-setter-return': 'error',
/** Disallow sparse arrays */
'no-sparse-arrays': 'error',
/** Disallow unreachable code after `return`, `throw`, `continue`, and `break` statements */
'no-unreachable': 'error',
/** Disallow control flow statements in `finally` blocks */
'no-unsafe-finally': 'error',
/** Disallow negating the left operand of relational operators */
'no-unsafe-negation': 'error',
/** Require calls to `isNaN()` when checking for `NaN` */
'use-isnan': 'error',
/** Enforce comparing `typeof` expressions against valid strings */
'valid-typeof': 'error',
/**
* Best Practices
*/
/** Enforce `return` statements in callbacks of array methods */
'array-callback-return': ['error', { allowImplicit: true }],
/** Require === and !== */
eqeqeq: ['error', 'always'],
/** Require `for-in` loops to include an `if` statement */
'guard-for-in': 'error',
/** Disallow `else` blocks after `return` statements in `if` statements */
'no-else-return': 'error',
/** Disallow empty destructuring patterns */
'no-empty-pattern': 'error',
/** Disallow the use of `eval()` */
'no-eval': 'error',
/** Disallow extending native types */
'no-extend-native': 'error',
/** Disallow fallthrough of `case` statements */
'no-fallthrough': 'error',
/** Disallow assignments to native objects or read-only global variables */
'no-global-assign': 'error',
/** Disallow the use of `eval()`-like methods */
'no-implied-eval': 'error',
/** Disallow `new` operators outside of assignments or comparisons */
'no-new': 'error',
/** Disallow `new` operators with the `Function` object */
'no-new-func': 'error',
/** Disallow `new` operators with the `String`, `Number`, and `Boolean` objects */
'no-new-wrappers': 'error',
/** Disallow octal literals */
'no-octal': 'error',
/** Disallow assignments where both sides are exactly the same */
'no-self-assign': 'error',
/** Disallow `javascript:` urls */
'no-script-url': 'error',
/** Disallow throwing literals as exceptions */
'no-throw-literal': 'error',
/** Disallow unused labels */
'no-unused-labels': 'error',
/** Disallow unnecessary `catch` clauses */
'no-useless-catch': 'error',
/** Disallow unnecessary escape characters */
'no-useless-escape': 'error',
/**
* Variables
*/
/** Disallow identifiers from shadowing restricted names */
'no-shadow-restricted-names': 'error',
/**
* ECMAScript 6
*/
/** Require `super()` calls in constructors */
'constructor-super': 'error',
/** Disallow reassigning class members */
'no-class-assign': 'error',
/** Disallow duplicate module imports */
'no-duplicate-imports': 'error',
/** Disallow `new` operators with the `Symbol` object */
'no-new-symbol': 'error',
/** Disallow `this`/`super` before calling `super()` in constructors */
'no-this-before-super': 'error',
/** Require `let` or `const` instead of `var` */
'no-var': 'error',
/** Require or disallow method and property shorthand syntax for object literals */
'object-shorthand': 'error',
/** Require `const` declarations for variables that are never reassigned after declared */
'prefer-const': 'error',
/** Require template literals instead of string concatenation */
'prefer-template': 'error',
/** Require generator functions to contain `yield` */
'require-yield': 'error',
/**
* @typescript-eslint rules
* https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/docs/rules
* based on version 2.29.0
*/
/** Require that member overloads be consecutive */
'@typescript-eslint/adjacent-overload-signatures': 'error',
/** Requires using either T[] or Array<T> for arrays */
'@typescript-eslint/array-type': ['error', { default: 'generic' }],
/** Disallows awaiting a value that is not a Promise */
'@typescript-eslint/await-thenable': 'error',
/** Bans “// @ts-ignore” comments from being used */
'@typescript-eslint/ban-ts-comment': 'error',
/** Bans specific types from being used */
'@typescript-eslint/ban-types': 'error',
/** Enforces consistent usage of type assertions */
'@typescript-eslint/consistent-type-assertions': 'error',
/** Consistent with type definition either interface or type */
'@typescript-eslint/consistent-type-definitions': 'error',
/** Require explicit accessibility modifiers on class properties and methods */
'@typescript-eslint/explicit-member-accessibility': 'error',
/** Require PascalCased class and interface names */
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'typeLike',
format: ['PascalCase'],
},
],
/** Disallow generic Array constructors */
'@typescript-eslint/no-array-constructor': 'error',
/** Disallow Empty Functions */
'@typescript-eslint/no-empty-function': 'error',
/** Disallow usage of the any type */
'@typescript-eslint/no-explicit-any': 'error',
/** Forbids the use of classes as namespaces */
'@typescript-eslint/no-extraneous-class': 'error',
/** Requires Promise-like values to be handled appropriately */
'@typescript-eslint/no-floating-promises': 'error',
/** Disallow iterating over an array with a for-in loop */
'@typescript-eslint/no-for-in-array': 'error',
/** Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean */
'@typescript-eslint/no-inferrable-types': 'error',
/** Enforce valid definition of new and constructor */
'@typescript-eslint/no-misused-new': 'error',
/** Avoid using promises in places not designed to handle them */
'@typescript-eslint/no-misused-promises': 'error',
/** Disallows non-null assertions using the ! postfix operator */
'@typescript-eslint/no-non-null-assertion': 'error',
/** Disallow the use of parameter properties in class constructors */
'@typescript-eslint/no-parameter-properties': 'error',
/** Disallow variable redeclaration */
"@typescript-eslint/no-redeclare": "error",
/** Disallows invocation of require() */
'@typescript-eslint/no-require-imports': 'error',
/** Disallow variable declarations from shadowing variables declared in the outer scope */
"@typescript-eslint/no-shadow": "error",
/** Disallow aliasing this */
'@typescript-eslint/no-this-alias': 'error',
/** Warns when a namespace qualifier is unnecessary */
'@typescript-eslint/no-unnecessary-qualifier': 'error',
/** Enforces that types will not to be used */
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
/** Warns if a type assertion does not change the type of an expression */
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
/** Disallow unused variables */
'@typescript-eslint/no-unused-vars': [
'error',
{
vars: 'all',
args: 'after-used',
varsIgnorePattern: '_',
ignoreRestSiblings: true,
},
],
/** Disallow unnecessary constructors */
'@typescript-eslint/no-useless-constructor': 'error',
/** Use for-of loops instead of standard for loops over arrays */
'@typescript-eslint/prefer-for-of': 'error',
/** Use function types instead of interfaces with call signatures */
'@typescript-eslint/prefer-function-type': 'error',
/** Enforce includes method over indexOf method */
'@typescript-eslint/prefer-includes': 'error',
/** Require never-modified private members be marked as readonly */
'@typescript-eslint/prefer-readonly': 'error',
/** Enforce the use of String#startsWith and String#endsWith instead of other equivalent methods of checking substrings */
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
/** Enforce giving compare argument to Array#sort */
'@typescript-eslint/require-array-sort-compare': 'error',
/** Disallow async functions which have no await expression */
'@typescript-eslint/require-await': 'error',
/** When adding two variables, operands must both be of type number or of type string */
'@typescript-eslint/restrict-plus-operands': 'error',
/** Boolean expressions are limited to booleans */
'@typescript-eslint/strict-boolean-expressions': 'error',
/** Sets preference level for triple slash directives versus ES6-style import declarations */
'@typescript-eslint/triple-slash-reference': 'error',
/** Enforces unbound methods are called with their expected scope */
'@typescript-eslint/unbound-method': ['error', { ignoreStatic: true }],
/** Warns for any two overloads that could be unified into one by using a union or an optional/rest parameter */
'@typescript-eslint/unified-signatures': 'error',
/**
* react rules
* https://github.com/yannickcr/eslint-plugin-react
* based on version 7.19.0
*/
/** Prevent missing displayName in a React component definition */
'react/display-name': 'error',
/** Enforce curly braces or disallow unnecessary curly braces in JSX props and/or children */
'react/jsx-curly-brace-presence': [
'error',
{ props: 'never', children: 'never' },
],
/** Detect missing key prop */
'react/jsx-key': 'error',
/** No .bind() or Arrow Functions in JSX Props */
'react/jsx-no-bind': 'error',
/** Prevent comments from being inserted as text nodes */
'react/jsx-no-comment-textnodes': 'error',
/** Prevent duplicate properties in JSX */
'react/jsx-no-duplicate-props': 'error',
/** Prevent usage of unsafe target='_blank' */
'react/jsx-no-target-blank': 'error',
/** Disallow undeclared variables in JSX */
'react/jsx-no-undef': 'error',
/** Prevent React to be incorrectly marked as unused */
'react/jsx-uses-react': 'error',
/** Prevent variables used in JSX to be incorrectly marked as unused */
'react/jsx-uses-vars': 'error',
/** Prevent passing of children as props */
'react/no-children-prop': 'error',
/** Prevent problem with children and props.dangerouslySetInnerHTML */
'react/no-danger-with-children': 'error',
/** Prevent usage of deprecated methods */
'react/no-deprecated': 'error',
/** Prevent direct mutation of this.state */
'react/no-direct-mutation-state': 'error',
/** Prevent invalid characters from appearing in markup */
'react/no-unescaped-entities': 'error',
/** Prevent usage of unknown DOM property */
'react/react-in-jsx-scope': 'error',
/** Enforce ES5 or ES6 class for returning value in render function */
'react/require-render-return': 'error',
/**
* react hooks rules
* https://github.com/facebook/react/tree/master/packages/eslint-plugin-react-hooks
* based on version 3.0.0
*/
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'error',
/**
* functional rules
* https://github.com/jonaskello/eslint-plugin-functional
* based on version 3.0.1
*/
/** Prefer readonly types over mutable types */
'functional/prefer-readonly-type': [
'error',
{ allowLocalMutation: true, ignoreClass: true },
],
/** Prefer property signatures with readonly modifiers over method signatures */
'functional/no-method-signature': 'error',
/**
* import rules
* https://github.com/benmosher/eslint-plugin-import/tree/master/docs/rules
* based on version 2.20.2
*/
/** Ensures that there is no resolvable path back to this module via its dependencies */
'import/no-cycle': 'error',
/** Prohibit default exports. */
'import/no-default-export': 'error',
/** Reports use of a default export as a locally named import */
'import/no-named-default': 'error',
/** Prevent unnecessary path segments in import and require statements */
'import/no-useless-path-segments': [
'error',
{
noUselessIndex: true,
},
],
/**
* node rules
* https://github.com/mysticatea/eslint-plugin-node/tree/master/docs/rules
* based on version 11.1.0
*/
/** Disallow import declarations which import extraneous modules */
'node/no-extraneous-import': [
'error',
{
allowModules: ['electron'],
},
],
},
}