@will-stone/eslint-config 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/eslint-config.js +151 -0
- package/package.json +44 -0
- package/rules/built-in.js +663 -0
- package/rules/import.js +63 -0
- package/rules/jest-ts.js +3 -0
- package/rules/jest.js +91 -0
- package/rules/jsx-a11y.js +149 -0
- package/rules/node.js +58 -0
- package/rules/prettier.js +3 -0
- package/rules/react.js +161 -0
- package/rules/switch-case.js +10 -0
- package/rules/typescript.js +299 -0
- package/rules/unicorn.js +281 -0
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
// The ESLint browser environment defines all browser globals as valid,
|
|
2
|
+
// Even though most people don't know some of them exist (e.g. `name` or `status`).
|
|
3
|
+
// This is dangerous as it hides accidentally undefined variables.
|
|
4
|
+
// We blacklist the globals that we deem potentially confusing.
|
|
5
|
+
// To use them, explicitly reference them, e.g. `window.name` or `window.status`.
|
|
6
|
+
import restrictedGlobals from 'confusing-browser-globals'
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
/**
|
|
10
|
+
* Off for Prettier
|
|
11
|
+
* https://github.com/prettier/eslint-config-prettier/blob/main/index.js
|
|
12
|
+
*/
|
|
13
|
+
'array-bracket-newline': 'off',
|
|
14
|
+
'array-bracket-spacing': 'off',
|
|
15
|
+
'array-element-newline': 'off',
|
|
16
|
+
'arrow-parens': 'off',
|
|
17
|
+
'arrow-spacing': 'off',
|
|
18
|
+
'block-spacing': 'off',
|
|
19
|
+
'brace-style': 'off',
|
|
20
|
+
'comma-dangle': 'off',
|
|
21
|
+
'comma-spacing': 'off',
|
|
22
|
+
'comma-style': 'off',
|
|
23
|
+
'computed-property-spacing': 'off',
|
|
24
|
+
'curly': 0,
|
|
25
|
+
'dot-location': 'off',
|
|
26
|
+
'eol-last': 'off',
|
|
27
|
+
'func-call-spacing': 'off',
|
|
28
|
+
'function-call-argument-newline': 'off',
|
|
29
|
+
'function-paren-newline': 'off',
|
|
30
|
+
'generator-star': 'off',
|
|
31
|
+
'generator-star-spacing': 'off',
|
|
32
|
+
'implicit-arrow-linebreak': 'off',
|
|
33
|
+
'indent': 'off',
|
|
34
|
+
'jsx-quotes': 'off',
|
|
35
|
+
'key-spacing': 'off',
|
|
36
|
+
'keyword-spacing': 'off',
|
|
37
|
+
'linebreak-style': 'off',
|
|
38
|
+
'lines-around-comment': 0,
|
|
39
|
+
'max-len': 0,
|
|
40
|
+
'multiline-ternary': 'off',
|
|
41
|
+
'new-parens': 'off',
|
|
42
|
+
'newline-per-chained-call': 'off',
|
|
43
|
+
'no-arrow-condition': 'off',
|
|
44
|
+
'no-comma-dangle': 'off',
|
|
45
|
+
'no-confusing-arrow': 0,
|
|
46
|
+
'no-extra-parens': 'off',
|
|
47
|
+
'no-extra-semi': 'off',
|
|
48
|
+
'no-floating-decimal': 'off',
|
|
49
|
+
'no-mixed-operators': 0,
|
|
50
|
+
'no-mixed-spaces-and-tabs': 'off',
|
|
51
|
+
'no-multi-spaces': 'off',
|
|
52
|
+
'no-multiple-empty-lines': 'off',
|
|
53
|
+
'no-reserved-keys': 'off',
|
|
54
|
+
'no-space-before-semi': 'off',
|
|
55
|
+
'no-tabs': 0,
|
|
56
|
+
'no-trailing-spaces': 'off',
|
|
57
|
+
'no-unexpected-multiline': 0,
|
|
58
|
+
'no-whitespace-before-property': 'off',
|
|
59
|
+
'no-wrap-func': 'off',
|
|
60
|
+
'nonblock-statement-body-position': 'off',
|
|
61
|
+
'object-curly-newline': 'off',
|
|
62
|
+
'object-curly-spacing': 'off',
|
|
63
|
+
'object-property-newline': 'off',
|
|
64
|
+
'one-var-declaration-per-line': 'off',
|
|
65
|
+
'operator-linebreak': 'off',
|
|
66
|
+
'padded-blocks': 'off',
|
|
67
|
+
'quote-props': 'off',
|
|
68
|
+
'quotes': 0,
|
|
69
|
+
'rest-spread-spacing': 'off',
|
|
70
|
+
'semi': 'off',
|
|
71
|
+
'semi-spacing': 'off',
|
|
72
|
+
'semi-style': 'off',
|
|
73
|
+
'space-after-function-name': 'off',
|
|
74
|
+
'space-after-keywords': 'off',
|
|
75
|
+
'space-before-blocks': 'off',
|
|
76
|
+
'space-before-function-paren': 'off',
|
|
77
|
+
'space-before-function-parentheses': 'off',
|
|
78
|
+
'space-before-keywords': 'off',
|
|
79
|
+
'space-in-brackets': 'off',
|
|
80
|
+
'space-in-parens': 'off',
|
|
81
|
+
'space-infix-ops': 'off',
|
|
82
|
+
'space-return-throw-case': 'off',
|
|
83
|
+
'space-unary-ops': 'off',
|
|
84
|
+
'space-unary-word-ops': 'off',
|
|
85
|
+
'switch-colon-spacing': 'off',
|
|
86
|
+
'template-curly-spacing': 'off',
|
|
87
|
+
'template-tag-spacing': 'off',
|
|
88
|
+
'unicode-bom': 'off',
|
|
89
|
+
'wrap-iife': 'off',
|
|
90
|
+
'wrap-regex': 'off',
|
|
91
|
+
'yield-star-spacing': 'off',
|
|
92
|
+
|
|
93
|
+
// Enforces getter/setter pairs in objects and classes
|
|
94
|
+
'accessor-pairs': 'error',
|
|
95
|
+
// Enforces return statements in callbacks of array's methods
|
|
96
|
+
'array-callback-return': [
|
|
97
|
+
'error',
|
|
98
|
+
// To be compatible with unicorn/no-useless-undefined
|
|
99
|
+
{ allowImplicit: true },
|
|
100
|
+
],
|
|
101
|
+
// Can cause issues when Prettier is enabled
|
|
102
|
+
'arrow-body-style': 'off',
|
|
103
|
+
// Generates warnings when variables are used outside of the
|
|
104
|
+
// block in which they were defined
|
|
105
|
+
'block-scoped-var': 'error',
|
|
106
|
+
// camelCase vars
|
|
107
|
+
'camelcase': 'error',
|
|
108
|
+
// Write comments however you like
|
|
109
|
+
'capitalized-comments': 'off',
|
|
110
|
+
// If a class method does not use this,
|
|
111
|
+
// it can sometimes be made into a static function
|
|
112
|
+
'class-methods-use-this': 'error',
|
|
113
|
+
// Measures the number of linearly independent paths through a program's
|
|
114
|
+
// source code. Rubbish. Use your own judgement on complexity.
|
|
115
|
+
'complexity': 'off',
|
|
116
|
+
// Do not care how return statements specify values.
|
|
117
|
+
// When on, this rule gets annoying when combined with Unicorn's no-useless-* rules.
|
|
118
|
+
'consistent-return': 'off',
|
|
119
|
+
// Not sure if required
|
|
120
|
+
'consistent-this': 'error',
|
|
121
|
+
// Constructors of derived classes must call super().
|
|
122
|
+
// Constructors of non derived classes must not call super()
|
|
123
|
+
'constructor-super': 'error',
|
|
124
|
+
// Require Default Case in Switch Statements
|
|
125
|
+
'default-case': 'error',
|
|
126
|
+
// enforce default clauses in switch statements to be last
|
|
127
|
+
'default-case-last': 'error',
|
|
128
|
+
// Putting default parameter at last allows function calls
|
|
129
|
+
// to omit optional tail arguments.
|
|
130
|
+
'default-param-last': 'error',
|
|
131
|
+
// Access properties using the dot notation.
|
|
132
|
+
'dot-notation': 'warn',
|
|
133
|
+
// Use === over ==
|
|
134
|
+
'eqeqeq': 'warn',
|
|
135
|
+
// Enforce "for" loop update clause moving the counter in the right direction
|
|
136
|
+
'for-direction': 'error',
|
|
137
|
+
// Require function names to match the name of the variable or property to
|
|
138
|
+
// which they are assigned.
|
|
139
|
+
'func-name-matching': 'error',
|
|
140
|
+
// Requires function expressions to have a name,
|
|
141
|
+
// If the name cannot be assigned automatically
|
|
142
|
+
'func-names': ['error', 'as-needed'],
|
|
143
|
+
// Declaration style: function name() {}
|
|
144
|
+
// Except arrow functions
|
|
145
|
+
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
|
|
146
|
+
// Enforces that a return statement is present in property getters
|
|
147
|
+
'getter-return': 'error',
|
|
148
|
+
// If a property has a getter and a setter, the setter should be defined
|
|
149
|
+
// right after the getter, or vice versa.
|
|
150
|
+
'grouped-accessor-pairs': 'error',
|
|
151
|
+
// This rule is aimed at preventing unexpected behavior that could arise
|
|
152
|
+
// from using a for in loop without filtering the results in the loop.
|
|
153
|
+
'guard-for-in': 'error',
|
|
154
|
+
// Disallows specified identifiers.
|
|
155
|
+
// Maybe turn this on when it's obvious which identifiers do not make sense.
|
|
156
|
+
// Rules like unicorn/catch-error-name look after some of these, anyway.
|
|
157
|
+
'id-denylist': 'off',
|
|
158
|
+
// Allow variables named with as little chars as you like
|
|
159
|
+
'id-length': 'off',
|
|
160
|
+
// Requires identifiers to match a specified regular expression.
|
|
161
|
+
// Mainly covered by rules like "camelcase". This could probably cause more
|
|
162
|
+
// trouble than it's worth.
|
|
163
|
+
'id-match': 'off',
|
|
164
|
+
// Initialise vairables however you like
|
|
165
|
+
'init-declarations': 'off',
|
|
166
|
+
// Enforces line comments positioned above code
|
|
167
|
+
'line-comment-position': 'error',
|
|
168
|
+
// Require an empty line between class members
|
|
169
|
+
'lines-between-class-members': 'warn',
|
|
170
|
+
'logical-assignment-operators': ['warn', 'always'],
|
|
171
|
+
// Organise classes how you see fit
|
|
172
|
+
'max-classes-per-file': 'off',
|
|
173
|
+
// This rule enforces a maximum depth that blocks can be nested to reduce
|
|
174
|
+
// code complexity. Just gets in the way too much.
|
|
175
|
+
'max-depth': 'off',
|
|
176
|
+
// Files can contain as many lines as you like
|
|
177
|
+
'max-lines': 'off',
|
|
178
|
+
// Functions can be as complicated as you like
|
|
179
|
+
'max-lines-per-function': 'off',
|
|
180
|
+
// This rule enforces a maximum depth that callbacks can be nested to
|
|
181
|
+
// increase code clarity. Defaults to 10.
|
|
182
|
+
'max-nested-callbacks': 'error',
|
|
183
|
+
// Enforces a maximum number of parameters allowed in function definitions.
|
|
184
|
+
// This is usually to help readability but TS self-documents this kind of thing.
|
|
185
|
+
'max-params': 'off',
|
|
186
|
+
// Statements can be as complicated as you like
|
|
187
|
+
'max-statements': 'off',
|
|
188
|
+
// Enforces maximum number of statements allowed per line to 1.
|
|
189
|
+
'max-statements-per-line': 'error',
|
|
190
|
+
// Allow any style of multiline comments
|
|
191
|
+
'multiline-comment-style': 'off',
|
|
192
|
+
// Require constructor names to begin with a capital letter
|
|
193
|
+
'new-cap': 'error',
|
|
194
|
+
// alert is often used while debugging code, which should be removed before
|
|
195
|
+
// deployment to production.
|
|
196
|
+
'no-alert': 'error',
|
|
197
|
+
// Use of the Array constructor to construct a new array is generally
|
|
198
|
+
// discouraged in favor of array literal notation because of the
|
|
199
|
+
// single-argument pitfall and because the Array global may be redefined.
|
|
200
|
+
// The exception is when the Array constructor is used to intentionally
|
|
201
|
+
// create sparse arrays of a specified size by giving the constructor a
|
|
202
|
+
// single numeric argument.
|
|
203
|
+
'no-array-constructor': 'error',
|
|
204
|
+
// The executor function can also be an async function.
|
|
205
|
+
// However, this is usually a mistake:
|
|
206
|
+
// https://eslint.org/docs/rules/no-async-promise-executor#top
|
|
207
|
+
'no-async-promise-executor': 'error',
|
|
208
|
+
// Use Promise.all() instead
|
|
209
|
+
'no-await-in-loop': 'error',
|
|
210
|
+
// Use of bitwise operators in JavaScript is very rare and often & or | is
|
|
211
|
+
// simply a mistyped && or ||, which will lead to unexpected behavior.
|
|
212
|
+
'no-bitwise': 'error',
|
|
213
|
+
// Use the producer methods Buffer.from, Buffer.alloc,
|
|
214
|
+
// and Buffer.allocUnsafe instead.
|
|
215
|
+
'no-buffer-constructor': 'error',
|
|
216
|
+
// arguments.caller and arguments.callee ave been deprecated in future
|
|
217
|
+
// versions of JavaScript and their use is forbidden in ECMAScript 5 while
|
|
218
|
+
// in strict mode.
|
|
219
|
+
'no-caller': 'error',
|
|
220
|
+
// Disallows lexical declarations (let, const, function and class) in
|
|
221
|
+
// case/default clauses. To ensure that the lexical declaration only applies
|
|
222
|
+
// to the current case clause wrap your clauses in blocks.
|
|
223
|
+
'no-case-declarations': 'error',
|
|
224
|
+
// Disallow modifying variables of class declarations
|
|
225
|
+
'no-class-assign': 'error',
|
|
226
|
+
// Disallow comparing against -0
|
|
227
|
+
'no-compare-neg-zero': 'error',
|
|
228
|
+
// Disallow assignment operators in conditional statements. e.g.
|
|
229
|
+
// if (user.jobTitle = "manager") { }
|
|
230
|
+
'no-cond-assign': 'error',
|
|
231
|
+
// Disallow the use of console
|
|
232
|
+
'no-console': 'warn',
|
|
233
|
+
// Disallow modifying variables that are declared using const
|
|
234
|
+
'no-const-assign': 'error',
|
|
235
|
+
// This rule identifies == and === comparisons which, based on the semantics
|
|
236
|
+
// of the JavaScript language, will always evaluate to true or false.
|
|
237
|
+
'no-constant-binary-expression': 'error',
|
|
238
|
+
// Disallow constant expressions in conditions
|
|
239
|
+
// if (true) {}
|
|
240
|
+
'no-constant-condition': 'error',
|
|
241
|
+
// Disallows return statements in the constructor of a class
|
|
242
|
+
'no-constructor-return': 'error',
|
|
243
|
+
// Disallow continue statements.
|
|
244
|
+
// When used incorrectly it makes code less testable, less readable and less
|
|
245
|
+
// maintainable. Structured control flow statements such as if should be
|
|
246
|
+
// used instead.
|
|
247
|
+
'no-continue': 'error',
|
|
248
|
+
// Control characters are special, invisible characters in the ASCII range
|
|
249
|
+
// 0-31. These characters are rarely used in JavaScript strings so a regular
|
|
250
|
+
// expression containing these characters is most likely a mistake.
|
|
251
|
+
'no-control-regex': 'error',
|
|
252
|
+
// The debugger statement is used to tell the executing JavaScript
|
|
253
|
+
// environment to stop execution and start up a debugger at the current
|
|
254
|
+
// point in the code. This has fallen out of favor as a good practice with
|
|
255
|
+
// the advent of modern debugging and development tools.
|
|
256
|
+
'no-debugger': 'error',
|
|
257
|
+
// The purpose of the delete operator is to remove a property from an
|
|
258
|
+
// object. Using the delete operator on a variable might lead to unexpected
|
|
259
|
+
// behavior.
|
|
260
|
+
'no-delete-var': 'error',
|
|
261
|
+
// Require regex literals to escape division operators.
|
|
262
|
+
'no-div-regex': 'warn',
|
|
263
|
+
// function foo(a, b, a) { } // duplicate "a" arg
|
|
264
|
+
'no-dupe-args': 'error',
|
|
265
|
+
// class Foo {
|
|
266
|
+
// bar() { console.log("hello") }
|
|
267
|
+
// bar() { console.log("goodbye") } // duplicate class member
|
|
268
|
+
// }
|
|
269
|
+
'no-dupe-class-members': 'error',
|
|
270
|
+
// if (isSomething(x)) {
|
|
271
|
+
// foo()
|
|
272
|
+
// } else if (isSomething(x)) { // duplicate condition
|
|
273
|
+
// bar()
|
|
274
|
+
// }
|
|
275
|
+
'no-dupe-else-if': 'error',
|
|
276
|
+
// const foo = {
|
|
277
|
+
// bar: "baz",
|
|
278
|
+
// bar: "qux" // duplicate key
|
|
279
|
+
// }
|
|
280
|
+
'no-dupe-keys': 'error',
|
|
281
|
+
// switch (a) {
|
|
282
|
+
// case 1:
|
|
283
|
+
// break
|
|
284
|
+
// case 2:
|
|
285
|
+
// break
|
|
286
|
+
// case 1: // duplicate test expression
|
|
287
|
+
// break
|
|
288
|
+
// default:
|
|
289
|
+
// break
|
|
290
|
+
// }
|
|
291
|
+
'no-duplicate-case': 'error',
|
|
292
|
+
// Combine named imports in single statement.
|
|
293
|
+
'no-duplicate-imports': 'error',
|
|
294
|
+
// If an `if` block contains a return statement, the else block becomes
|
|
295
|
+
// unnecessary. Its contents can be placed outside of the block.
|
|
296
|
+
'no-else-return': 'warn',
|
|
297
|
+
// Disallow empty block statements.
|
|
298
|
+
'no-empty': 'error',
|
|
299
|
+
// Disallow empty character classes in regular expressions.
|
|
300
|
+
'no-empty-character-class': 'error',
|
|
301
|
+
// Disallow empty functions.
|
|
302
|
+
'no-empty-function': 'error',
|
|
303
|
+
// Disallow empty destructuring patterns.
|
|
304
|
+
'no-empty-pattern': 'error',
|
|
305
|
+
'no-empty-static-block': 'error',
|
|
306
|
+
// Error: if (foo == null)
|
|
307
|
+
// Good: if (foo === null)
|
|
308
|
+
'no-eq-null': 'error',
|
|
309
|
+
// Disallow eval()
|
|
310
|
+
'no-eval': 'error',
|
|
311
|
+
// Disallow reassigning exceptions in catch clauses.
|
|
312
|
+
'no-ex-assign': 'error',
|
|
313
|
+
// Disallow extending of native objects.
|
|
314
|
+
'no-extend-native': 'error',
|
|
315
|
+
// Disallow unnecessary function binding
|
|
316
|
+
'no-extra-bind': 'warn',
|
|
317
|
+
// In contexts such as an if statement's test where the result of the
|
|
318
|
+
// expression will already be coerced to a Boolean, casting to a Boolean via
|
|
319
|
+
// double negation (!!) or a Boolean call is unnecessary.
|
|
320
|
+
'no-extra-boolean-cast': 'warn',
|
|
321
|
+
// If a loop contains no nested loops or switches, labeling the loop is unnecessary.
|
|
322
|
+
'no-extra-label': 'warn',
|
|
323
|
+
// Disallow case statement fallthrough.
|
|
324
|
+
'no-fallthrough': 'error',
|
|
325
|
+
// Disallow reassigning function declarations.
|
|
326
|
+
'no-func-assign': 'error',
|
|
327
|
+
// Disallow assignment to native objects or read-only global variables.
|
|
328
|
+
'no-global-assign': 'error',
|
|
329
|
+
// Disallow the type conversion with shorter notations.
|
|
330
|
+
'no-implicit-coercion': 'warn',
|
|
331
|
+
// Disallow declarations in the global scope.
|
|
332
|
+
'no-implicit-globals': 'error',
|
|
333
|
+
// There are some other ways to pass a string and have it interpreted as
|
|
334
|
+
// JavaScript code that have similar concerns.
|
|
335
|
+
// e.g. setTimeout("alert('Hi!');", 100);
|
|
336
|
+
'no-implied-eval': 'error',
|
|
337
|
+
// Disallow assigning to imported bindings.
|
|
338
|
+
'no-import-assign': 'error',
|
|
339
|
+
// Disallow inline comments after code.
|
|
340
|
+
'no-inline-comments': 'error',
|
|
341
|
+
// Disallow variable or function declarations in nested blocks.
|
|
342
|
+
'no-inner-declarations': 'error',
|
|
343
|
+
// Disallow invalid regular expression strings in RegExp constructors.
|
|
344
|
+
'no-invalid-regexp': 'error',
|
|
345
|
+
// Disallow this keywords outside of classes or class-like objects.
|
|
346
|
+
'no-invalid-this': 'error',
|
|
347
|
+
// Invalid or irregular whitespace causes issues with ECMAScript 5 parsers
|
|
348
|
+
// and also makes code harder to debug in a similar nature to mixed tabs and spaces.
|
|
349
|
+
'no-irregular-whitespace': 'error',
|
|
350
|
+
// The __iterator__ property was a SpiderMonkey extension to JavaScript that
|
|
351
|
+
// could be used to create custom iterators that are compatible with
|
|
352
|
+
// JavaScript's for in and for each constructs. However, this property is
|
|
353
|
+
// now obsolete, so it should not be used.
|
|
354
|
+
'no-iterator': 'error',
|
|
355
|
+
// Disallow labels that are variables names.
|
|
356
|
+
'no-label-var': 'error',
|
|
357
|
+
// While convenient in some cases, labels tend to be used only rarely and
|
|
358
|
+
// are frowned upon by some as a remedial form of flow control that is more
|
|
359
|
+
// error prone and harder to understand.
|
|
360
|
+
'no-labels': 'error',
|
|
361
|
+
// Disallow unnecessary nested blocks
|
|
362
|
+
'no-lone-blocks': 'error',
|
|
363
|
+
// Disallow if statements as the only statement in else blocks.
|
|
364
|
+
'no-lonely-if': 'warn',
|
|
365
|
+
// Writing functions within loops tends to result in errors due to the way
|
|
366
|
+
// the function creates a closure around the loop.
|
|
367
|
+
'no-loop-func': 'error',
|
|
368
|
+
// Disallow the use of number literals that immediately lose precision at
|
|
369
|
+
// runtime when converted to a JS Number due to 64-bit floating-point rounding.
|
|
370
|
+
'no-loss-of-precision': 'error',
|
|
371
|
+
// Disallowing magic numbers causes all sorts of problems
|
|
372
|
+
'no-magic-numbers': 'off',
|
|
373
|
+
// Disallow characters which are made with multiple code points in character class syntax.
|
|
374
|
+
'no-misleading-character-class': 'error',
|
|
375
|
+
// const foo = bar = "baz"
|
|
376
|
+
'no-multi-assign': 'error',
|
|
377
|
+
// var x = "Line 1 \
|
|
378
|
+
// Line 2"
|
|
379
|
+
'no-multi-str': 'error',
|
|
380
|
+
// Negated conditions are more difficult to understand. Code can be made
|
|
381
|
+
// more readable by inverting the condition instead.
|
|
382
|
+
// This is handled by unicorn.
|
|
383
|
+
'no-negated-condition': 'off',
|
|
384
|
+
// Disallow nested ternary expressions
|
|
385
|
+
'no-nested-ternary': 'error',
|
|
386
|
+
// Disallows constructor calls using the new keyword that do not assign
|
|
387
|
+
// the resulting object to a variable.
|
|
388
|
+
'no-new': 'error',
|
|
389
|
+
// ❌ Function()
|
|
390
|
+
// ✅ function()
|
|
391
|
+
'no-new-func': 'error',
|
|
392
|
+
// ❌ new BigInt(12344555)
|
|
393
|
+
// ✅ BigInt(12344555)
|
|
394
|
+
'no-new-native-nonconstructor': 'error',
|
|
395
|
+
// ❌ var myObject = new Object()
|
|
396
|
+
// ✅ var myObject = {}
|
|
397
|
+
'no-new-object': 'error',
|
|
398
|
+
// Symbol is not intended to be used with the new operator, but to be called
|
|
399
|
+
// as a function.
|
|
400
|
+
'no-new-symbol': 'error',
|
|
401
|
+
// This rule aims to eliminate the use of String, Number, and Boolean with
|
|
402
|
+
// the new operator. As such, it warns whenever it sees new String,
|
|
403
|
+
// new Number, or new Boolean.
|
|
404
|
+
'no-new-wrappers': 'error',
|
|
405
|
+
// Disallow \8 and \9 escape sequences in string literals
|
|
406
|
+
'no-nonoctal-decimal-escape': 'error',
|
|
407
|
+
// This rule disallows calling the Math, JSON, Reflect and Atomics objects as functions.
|
|
408
|
+
'no-obj-calls': 'error',
|
|
409
|
+
// the leading zero which identifies an octal literal has been a source of
|
|
410
|
+
// confusion and error in JavaScript code, ECMAScript 5 deprecates the use
|
|
411
|
+
// of octal numeric literals.
|
|
412
|
+
'no-octal': 'error',
|
|
413
|
+
// As of the ECMAScript 5 specification, octal escape sequences in string
|
|
414
|
+
// literals are deprecated and should not be used. Unicode escape sequences
|
|
415
|
+
// should be used instead.
|
|
416
|
+
'no-octal-escape': 'error',
|
|
417
|
+
// Assignment to variables declared as function parameters can be misleading
|
|
418
|
+
// and lead to confusing behavior, as modifying function parameters will
|
|
419
|
+
// also mutate the arguments object.
|
|
420
|
+
'no-param-reassign': 'error',
|
|
421
|
+
// Because the unary ++ and -- operators are subject to automatic semicolon
|
|
422
|
+
// insertion, differences in whitespace can change semantics of source code.
|
|
423
|
+
'no-plusplus': 'error',
|
|
424
|
+
// Disallow returning values from Promise executor functions
|
|
425
|
+
'no-promise-executor-return': 'error',
|
|
426
|
+
// __proto__ property has been deprecated as of ECMAScript 3.1 and shouldn't
|
|
427
|
+
// be used in the code. Use Object.getPrototypeOf and Object.setPrototypeOf instead.
|
|
428
|
+
'no-proto': 'error',
|
|
429
|
+
// Disallow use of Object.prototypes builtins directly.
|
|
430
|
+
'no-prototype-builtins': 'error',
|
|
431
|
+
// Disallow variable redeclaration.
|
|
432
|
+
'no-redeclare': 'error',
|
|
433
|
+
// Disallow multiple spaces in regular expression literals.
|
|
434
|
+
'no-regex-spaces': 'warn',
|
|
435
|
+
// No export names are restricted
|
|
436
|
+
'no-restricted-exports': 'off',
|
|
437
|
+
// Global variable names that are dangerous to use by mistake
|
|
438
|
+
'no-restricted-globals': ['error', ...restrictedGlobals],
|
|
439
|
+
// No imports are restricted
|
|
440
|
+
'no-restricted-imports': 'off',
|
|
441
|
+
// No properties are restricted
|
|
442
|
+
'no-restricted-properties': 'off',
|
|
443
|
+
// No syntax is restricted
|
|
444
|
+
'no-restricted-syntax': 'off',
|
|
445
|
+
// Disallow assignment in return statement
|
|
446
|
+
'no-return-assign': 'error',
|
|
447
|
+
// Disallows unnecessary return await
|
|
448
|
+
'no-return-await': 'error',
|
|
449
|
+
// ❌ location.href = "javascript:void(0)"
|
|
450
|
+
'no-script-url': 'error',
|
|
451
|
+
// Self assignments have no effect.
|
|
452
|
+
// ❌ foo = foo
|
|
453
|
+
'no-self-assign': 'error',
|
|
454
|
+
// Comparing a variable against itself is usually an error, either a typo or
|
|
455
|
+
// refactoring error.
|
|
456
|
+
'no-self-compare': 'error',
|
|
457
|
+
// Disallow use of the comma operator.
|
|
458
|
+
'no-sequences': 'error',
|
|
459
|
+
// Disallow returning values from setters.
|
|
460
|
+
'no-setter-return': 'error',
|
|
461
|
+
// Disallow variable declarations from shadowing variables declared in the outer scope.
|
|
462
|
+
'no-shadow': 'error',
|
|
463
|
+
// ES5 Value Properties of the Global Object (NaN, Infinity, undefined) as
|
|
464
|
+
// well as strict mode restricted identifiers eval and arguments are considered
|
|
465
|
+
// to be restricted names in JavaScript. Defining them to mean something
|
|
466
|
+
// else can have unintended consequences and confuse others reading the code.
|
|
467
|
+
'no-shadow-restricted-names': 'error',
|
|
468
|
+
// This rule disallows sparse array literals which have "holes" where commas
|
|
469
|
+
// are not preceded by elements. It does not apply to a trailing comma
|
|
470
|
+
// following the last element. Use ignored values instead.
|
|
471
|
+
'no-sparse-arrays': 'error',
|
|
472
|
+
// Disallow template literal placeholder syntax in regular strings.
|
|
473
|
+
'no-template-curly-in-string': 'error',
|
|
474
|
+
// Simple ternaries are okay
|
|
475
|
+
'no-ternary': 'off',
|
|
476
|
+
// Disallow use of this/super before calling super() in constructors.
|
|
477
|
+
'no-this-before-super': 'error',
|
|
478
|
+
// Maintain consistency when throwing exception by disallowing to throw
|
|
479
|
+
// literals and other expressions which cannot possibly be an Error object.
|
|
480
|
+
'no-throw-literal': 'error',
|
|
481
|
+
// Disallow undeclared variables.
|
|
482
|
+
'no-undef': 'error',
|
|
483
|
+
// Disallow initializing to undefined.
|
|
484
|
+
'no-undef-init': 'warn',
|
|
485
|
+
// Allow undefined. Use no-global-assign and no-shadow-restricted-names
|
|
486
|
+
// rules to prevent undefined from being shadowed or assigned a different value.
|
|
487
|
+
'no-undefined': 'off',
|
|
488
|
+
// Allow dangling underscores in identifiers.
|
|
489
|
+
'no-underscore-dangle': 'off',
|
|
490
|
+
// Disallow unmodified conditions of loops
|
|
491
|
+
'no-unmodified-loop-condition': 'error',
|
|
492
|
+
// Disallow ternary operators when simpler alternatives exist.
|
|
493
|
+
'no-unneeded-ternary': 'warn',
|
|
494
|
+
// Disallow unreachable code after return, throw, continue, and break statements.
|
|
495
|
+
'no-unreachable': 'error',
|
|
496
|
+
// Disallow loops with a body that allows only one iteration
|
|
497
|
+
'no-unreachable-loop': 'error',
|
|
498
|
+
// Disallow control flow statements in finally blocks.
|
|
499
|
+
'no-unsafe-finally': 'error',
|
|
500
|
+
// Disallow negating the left operand of relational operators.
|
|
501
|
+
'no-unsafe-negation': 'error',
|
|
502
|
+
// Disallow use of optional chaining in contexts where the `undefined` value is not allowed
|
|
503
|
+
'no-unsafe-optional-chaining': 'error',
|
|
504
|
+
// An unused expression which has no effect on the state of the program
|
|
505
|
+
// indicates a logic error.
|
|
506
|
+
'no-unused-expressions': 'error',
|
|
507
|
+
// Labels that are declared and not used anywhere in the code are most
|
|
508
|
+
// likely an error due to incomplete refactoring.
|
|
509
|
+
'no-unused-labels': 'warn',
|
|
510
|
+
'no-unused-private-class-members': 'error',
|
|
511
|
+
// Variables must be used unless name starts with "ignored"
|
|
512
|
+
'no-unused-vars': [
|
|
513
|
+
'error',
|
|
514
|
+
{
|
|
515
|
+
// Useful for extracting args from props and ignoring them:
|
|
516
|
+
// { style: _style, ...restProps }
|
|
517
|
+
argsIgnorePattern: '^_',
|
|
518
|
+
varsIgnorePattern: '[iI]gnored',
|
|
519
|
+
},
|
|
520
|
+
],
|
|
521
|
+
// It's possible to use identifiers before their formal declarations in code.
|
|
522
|
+
// This can be confusing and some believe it is best to always declare
|
|
523
|
+
// variables and functions before using them.
|
|
524
|
+
'no-use-before-define': 'error',
|
|
525
|
+
// Do I need this? https://eslint.org/docs/rules/no-useless-backreference
|
|
526
|
+
'no-useless-backreference': 'off',
|
|
527
|
+
// Function.prototype.call() and Function.prototype.apply() are slower than
|
|
528
|
+
// the normal function invocation.
|
|
529
|
+
'no-useless-call': 'error',
|
|
530
|
+
// A catch clause that only rethrows the original error is redundant, and
|
|
531
|
+
// has no effect on the runtime behavior of the program.
|
|
532
|
+
'no-useless-catch': 'error',
|
|
533
|
+
// ❌ var foo = {['a']: 'b'}
|
|
534
|
+
// ✅ var foo = {a: 'b'}
|
|
535
|
+
'no-useless-computed-key': 'error',
|
|
536
|
+
// ❌ var foo = 'a' + 'b'
|
|
537
|
+
// ✅ var foo = 'ab'
|
|
538
|
+
'no-useless-concat': 'error',
|
|
539
|
+
// ES2015 provides a default class constructor if one is not specified. As
|
|
540
|
+
// such, it isunnecessary to provide an empty constructor or one that simply
|
|
541
|
+
// delegates into its parent class.
|
|
542
|
+
'no-useless-constructor': 'error',
|
|
543
|
+
// Escaping non-special characters in strings, template literals, and
|
|
544
|
+
// regular expressions doesn't have any effect.
|
|
545
|
+
'no-useless-escape': 'error',
|
|
546
|
+
// Disallow renaming import, export, and destructured assignments to the same name.
|
|
547
|
+
'no-useless-rename': 'warn',
|
|
548
|
+
// A return; statement with nothing after it is redundant, and has no effect
|
|
549
|
+
// on the runtime behavior of a function. This can be confusing, so it's
|
|
550
|
+
// better to disallow these redundant statements.
|
|
551
|
+
'no-useless-return': 'warn',
|
|
552
|
+
// Require let or const instead of var.
|
|
553
|
+
'no-var': 'warn',
|
|
554
|
+
// Disallow use of the void operator.
|
|
555
|
+
'no-void': 'error',
|
|
556
|
+
// Allow TODOs and FIXMEs
|
|
557
|
+
'no-warning-comments': 'off',
|
|
558
|
+
// The with statement is potentially problematic because it adds members of
|
|
559
|
+
// an object to the current scope, making it impossible to tell what a
|
|
560
|
+
// variable inside the block actually refers to.
|
|
561
|
+
'no-with': 'error',
|
|
562
|
+
// Functions declared in object keys must conform to a certain style
|
|
563
|
+
// Capitalised functions are exempt as they are probably constructor functions
|
|
564
|
+
'object-shorthand': ['warn', 'always', { ignoreConstructors: true }],
|
|
565
|
+
// Prevent combined variable declarations
|
|
566
|
+
'one-var': ['warn', 'never'],
|
|
567
|
+
// Disallow assignment operator shorthand where possible.
|
|
568
|
+
'operator-assignment': ['warn', 'never'],
|
|
569
|
+
'padding-line-between-statements': [
|
|
570
|
+
'warn',
|
|
571
|
+
{ blankLine: 'always', next: '*', prev: 'multiline-block-like' },
|
|
572
|
+
{ blankLine: 'always', next: 'multiline-block-like', prev: '*' },
|
|
573
|
+
{ blankLine: 'always', next: '*', prev: 'multiline-const' },
|
|
574
|
+
{ blankLine: 'always', next: 'multiline-const', prev: '*' },
|
|
575
|
+
{ blankLine: 'always', next: '*', prev: 'multiline-let' },
|
|
576
|
+
{ blankLine: 'always', next: 'multiline-let', prev: '*' },
|
|
577
|
+
{ blankLine: 'always', next: '*', prev: 'multiline-var' },
|
|
578
|
+
{ blankLine: 'always', next: 'multiline-var', prev: '*' },
|
|
579
|
+
],
|
|
580
|
+
// Can cause issues when Prettier is enabled
|
|
581
|
+
'prefer-arrow-callback': 'off',
|
|
582
|
+
// If a variable is never reassigned, using the const declaration is better.
|
|
583
|
+
'prefer-const': 'warn',
|
|
584
|
+
// Make compatible with Unicorn's no-unreadable-array-destructuring
|
|
585
|
+
'prefer-destructuring': ['warn', { array: false, object: true }],
|
|
586
|
+
// Introduced in ES2016, the infix exponentiation operator ** is an
|
|
587
|
+
// alternative for the standard Math.pow function. Infix notation is
|
|
588
|
+
// considered to be more readable and thus more preferable than the function notation.
|
|
589
|
+
'prefer-exponentiation-operator': 'warn',
|
|
590
|
+
// Allow regex to be left as-is
|
|
591
|
+
'prefer-named-capture-group': 'off',
|
|
592
|
+
// This rule disallows calls to parseInt() or Number.parseInt() if called
|
|
593
|
+
// with two arguments: a string; and a radix option of 2 (binary), 8 (octal),
|
|
594
|
+
// or 16 (hexadecimal).
|
|
595
|
+
'prefer-numeric-literals': 'warn',
|
|
596
|
+
// Not supported by Typescript yet
|
|
597
|
+
'prefer-object-has-own': 'off',
|
|
598
|
+
// Prefer use of an object spread over Object.assign()
|
|
599
|
+
'prefer-object-spread': 'warn',
|
|
600
|
+
// It is considered good practice to only pass instances of the built-in
|
|
601
|
+
// Error object to the reject() function for user-defined errors in Promises.
|
|
602
|
+
// Error objects automatically store a stack trace, which can be used to
|
|
603
|
+
// debug an error by determining where it came from. If a Promise is rejected
|
|
604
|
+
// with a non-Error value, it can be difficult to determine where the rejection occurred.
|
|
605
|
+
'prefer-promise-reject-errors': 'error',
|
|
606
|
+
// Disallow use of the RegExp constructor in favor of regular expression literals.
|
|
607
|
+
'prefer-regex-literals': 'error',
|
|
608
|
+
// Suggest using the rest parameters instead of `arguments`.
|
|
609
|
+
'prefer-rest-params': 'error',
|
|
610
|
+
// Suggest using spread syntax instead of `.apply()`.
|
|
611
|
+
'prefer-spread': 'error',
|
|
612
|
+
// Suggest using template literals instead of string concatenation.
|
|
613
|
+
'prefer-template': 'warn',
|
|
614
|
+
// When using the parseInt() function it is common to omit the second argument,
|
|
615
|
+
// the radix, and let the function try to determine from the first argument
|
|
616
|
+
// what type of number it is. By default, parseInt() will autodetect decimal
|
|
617
|
+
// and hexadecimal (via 0x prefix). Prior to ECMAScript 5, parseInt() also
|
|
618
|
+
// autodetected octal literals, which caused problems because many developers
|
|
619
|
+
// assumed a leading 0 would be ignored.
|
|
620
|
+
'radix': 'error',
|
|
621
|
+
// Disallow assignments that can lead to race conditions due to usage of await or yield.
|
|
622
|
+
'require-atomic-updates': 'error',
|
|
623
|
+
// Disallow async functions which have no await expression.
|
|
624
|
+
'require-await': 'error',
|
|
625
|
+
// Enforce the use of 'u' flag on RegExp.
|
|
626
|
+
'require-unicode-regexp': 'error',
|
|
627
|
+
// Disallow generator functions that do not have yield.
|
|
628
|
+
'require-yield': 'error',
|
|
629
|
+
// Sorting imports is handled by simple-import-sort
|
|
630
|
+
'sort-imports': 'off',
|
|
631
|
+
'sort-keys': [
|
|
632
|
+
'error',
|
|
633
|
+
'asc',
|
|
634
|
+
{
|
|
635
|
+
allowLineSeparatedGroups: true,
|
|
636
|
+
caseSensitive: false,
|
|
637
|
+
natural: true,
|
|
638
|
+
},
|
|
639
|
+
],
|
|
640
|
+
// Not required as one-var rule is set to 'error' and so there will never be vars to sort.
|
|
641
|
+
'sort-vars': 'off',
|
|
642
|
+
// All comments must have a space after the //
|
|
643
|
+
// This also allows /// reference comments
|
|
644
|
+
'spaced-comment': ['warn', 'always', { markers: ['/'] }],
|
|
645
|
+
// As modules are used nearly all of the time, this probably isn't required,
|
|
646
|
+
// but leaving it on just in case.
|
|
647
|
+
'strict': 'warn',
|
|
648
|
+
// Using description promotes easier debugging.
|
|
649
|
+
// ✅ var foo = Symbol("some description")
|
|
650
|
+
'symbol-description': 'error',
|
|
651
|
+
// Require calls to isNaN() when checking for NaN.
|
|
652
|
+
'use-isnan': 'error',
|
|
653
|
+
// Enforce comparing typeof expressions against valid strings.
|
|
654
|
+
'valid-typeof': ['error', { requireStringLiterals: true }],
|
|
655
|
+
// By default variable declarations are always moved (“hoisted”) invisibly
|
|
656
|
+
// to the top of their containing scope by the JavaScript interpreter.
|
|
657
|
+
// This rule forces the programmer to represent that behavior by manually
|
|
658
|
+
// moving the variable declaration to the top of its containing scope.
|
|
659
|
+
'vars-on-top': 'error',
|
|
660
|
+
// ❌ if ('red' === color) {}
|
|
661
|
+
// ✅ if (color === 'red') {}
|
|
662
|
+
'yoda': 'warn',
|
|
663
|
+
}
|