@singlepixellab/eslint-config 1.0.0
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/.editorconfig +11 -0
- package/.eslintrc +3 -0
- package/.github/workflows/publish.yml +21 -0
- package/.vscode/extensions.json +7 -0
- package/.vscode/settings.json +8 -0
- package/LICENSE +21 -0
- package/README.md +22 -0
- package/eslint.config.js +30 -0
- package/index.js +20 -0
- package/package.json +49 -0
- package/rules/core.js +757 -0
- package/rules/ignores.js +17 -0
- package/rules/imports.js +130 -0
- package/rules/jsdoc.js +12 -0
- package/rules/prettier.js +18 -0
- package/rules/react.js +397 -0
- package/rules/styles.js +542 -0
package/rules/core.js
ADDED
|
@@ -0,0 +1,757 @@
|
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
|
|
4
|
+
/** @type {import('eslint').Linter.Config[]} */
|
|
5
|
+
export default [
|
|
6
|
+
{
|
|
7
|
+
name: "eslint/js/recommended",
|
|
8
|
+
...js.configs.recommended,
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
name: "spl/base",
|
|
12
|
+
files: ["**/*.{js,mjs,cjs}"],
|
|
13
|
+
languageOptions: {
|
|
14
|
+
ecmaVersion: "latest",
|
|
15
|
+
sourceType: "module",
|
|
16
|
+
globals: {
|
|
17
|
+
...globals.browser,
|
|
18
|
+
...globals.node,
|
|
19
|
+
document: "readonly",
|
|
20
|
+
navigator: "readonly",
|
|
21
|
+
window: "readonly",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
linterOptions: {
|
|
25
|
+
reportUnusedDisableDirectives: "warn",
|
|
26
|
+
reportUnusedInlineConfigs: "warn",
|
|
27
|
+
},
|
|
28
|
+
rules: {
|
|
29
|
+
// Allow implicit return in array callbacks for brevity and flexibility
|
|
30
|
+
"array-callback-return": ["error", { allowImplicit: true }],
|
|
31
|
+
|
|
32
|
+
// Enforce block scoping to prevent variable hoisting issues
|
|
33
|
+
"block-scoped-var": "error",
|
|
34
|
+
|
|
35
|
+
// Disable capitalized comments for flexibility
|
|
36
|
+
"capitalized-comments": "off",
|
|
37
|
+
|
|
38
|
+
// Enforce class methods to use `this`, unless explicitly exempted
|
|
39
|
+
"class-methods-use-this": ["error", { exceptMethods: [] }],
|
|
40
|
+
|
|
41
|
+
// Disable complexity rule to allow freedom in control flow design
|
|
42
|
+
"complexity": ["off", 20],
|
|
43
|
+
|
|
44
|
+
// Require return statements for all code paths to avoid undefined returns
|
|
45
|
+
"consistent-return": "error",
|
|
46
|
+
|
|
47
|
+
// Enforce calling super() in constructors to ensure proper initialization
|
|
48
|
+
"constructor-super": "error",
|
|
49
|
+
|
|
50
|
+
// Require a default case in switch statements unless explicitly commented
|
|
51
|
+
"default-case": ["error", { commentPattern: "^no default$" }],
|
|
52
|
+
|
|
53
|
+
// Enforce placing default case last for readability
|
|
54
|
+
"default-case-last": "error",
|
|
55
|
+
|
|
56
|
+
// Require default parameters to be last for consistency
|
|
57
|
+
"default-param-last": "error",
|
|
58
|
+
|
|
59
|
+
// Prefer dot notation for cleaner, more readable code
|
|
60
|
+
"dot-notation": ["error", { allowKeywords: true }],
|
|
61
|
+
|
|
62
|
+
// Enforce strict equality but allow loose null comparisons for
|
|
63
|
+
// convenience
|
|
64
|
+
"eqeqeq": ["error", "always", { null: "ignore" }],
|
|
65
|
+
|
|
66
|
+
// Requires function names to match the name of the variable or property
|
|
67
|
+
// to which they are assigned
|
|
68
|
+
"func-name-matching": [
|
|
69
|
+
"off",
|
|
70
|
+
"always",
|
|
71
|
+
{
|
|
72
|
+
includeCommonJSModuleExports: false,
|
|
73
|
+
considerPropertyDescriptor: true,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
|
|
77
|
+
// Require function expressions to have a name
|
|
78
|
+
"func-names": "warn",
|
|
79
|
+
|
|
80
|
+
// Enforces use of function declarations or expressions
|
|
81
|
+
// TODO: enable
|
|
82
|
+
"func-style": ["off", "expression"],
|
|
83
|
+
|
|
84
|
+
// Getter must always return a value to ensure correctness
|
|
85
|
+
"getter-return": ["error", { allowImplicit: true }],
|
|
86
|
+
|
|
87
|
+
// Enforce grouping of getter/setter pairs for clarity and maintenance
|
|
88
|
+
"grouped-accessor-pairs": "error",
|
|
89
|
+
|
|
90
|
+
// Disallow specified identifiers
|
|
91
|
+
"id-denylist": "off",
|
|
92
|
+
|
|
93
|
+
// This option enforces minimum and maximum identifier lengths
|
|
94
|
+
"id-length": "off",
|
|
95
|
+
|
|
96
|
+
// Require identifiers to match the provided regular expression
|
|
97
|
+
"id-match": "off",
|
|
98
|
+
|
|
99
|
+
// Require or disallow logical assignment logical operator shorthand
|
|
100
|
+
"logical-assignment-operators": [
|
|
101
|
+
"off",
|
|
102
|
+
"always",
|
|
103
|
+
{
|
|
104
|
+
enforceForIfStatements: true,
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
|
|
108
|
+
// Specify the maximum depth that blocks can be nested
|
|
109
|
+
"max-depth": ["off", 4],
|
|
110
|
+
|
|
111
|
+
// Specify the max number of lines in a file
|
|
112
|
+
"max-lines": [
|
|
113
|
+
"off",
|
|
114
|
+
{
|
|
115
|
+
max: 300,
|
|
116
|
+
skipBlankLines: true,
|
|
117
|
+
skipComments: true,
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
|
|
121
|
+
// Enforce a maximum function length
|
|
122
|
+
"max-lines-per-function": [
|
|
123
|
+
"off",
|
|
124
|
+
{
|
|
125
|
+
max: 50,
|
|
126
|
+
skipBlankLines: true,
|
|
127
|
+
skipComments: true,
|
|
128
|
+
IIFEs: true,
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
|
|
132
|
+
// Specify the maximum depth callbacks can be nested
|
|
133
|
+
"max-nested-callbacks": "off",
|
|
134
|
+
|
|
135
|
+
// Limits the number of parameters that can be used in the function
|
|
136
|
+
// declaration
|
|
137
|
+
"max-params": ["off", 3],
|
|
138
|
+
|
|
139
|
+
// Specify the maximum number of statement allowed in a function
|
|
140
|
+
"max-statements": ["off", 10],
|
|
141
|
+
|
|
142
|
+
// Require a capital letter for constructors
|
|
143
|
+
"new-cap": [
|
|
144
|
+
"error",
|
|
145
|
+
{
|
|
146
|
+
newIsCap: true,
|
|
147
|
+
newIsCapExceptions: [],
|
|
148
|
+
capIsNew: false,
|
|
149
|
+
capIsNewExceptions: [
|
|
150
|
+
"Immutable.Map",
|
|
151
|
+
"Immutable.Set",
|
|
152
|
+
"Immutable.List",
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
|
|
157
|
+
// Warn on `alert` usage instead of error to allow debugging in
|
|
158
|
+
// development
|
|
159
|
+
"no-alert": "warn",
|
|
160
|
+
|
|
161
|
+
// Disallow use of the Array constructor
|
|
162
|
+
"no-array-constructor": "error",
|
|
163
|
+
|
|
164
|
+
// Disallow async functions with promise constructors — confusing and
|
|
165
|
+
// unnecessary
|
|
166
|
+
"no-async-promise-executor": "error",
|
|
167
|
+
|
|
168
|
+
// Avoid using `await` in loops to prevent performance issues
|
|
169
|
+
"no-await-in-loop": "error",
|
|
170
|
+
|
|
171
|
+
// Disallow use of bitwise operators
|
|
172
|
+
"no-bitwise": "error",
|
|
173
|
+
|
|
174
|
+
// Disallow use of the continue statement
|
|
175
|
+
"no-continue": "error",
|
|
176
|
+
|
|
177
|
+
// Disallow use of deprecated `arguments.caller` and `callee`
|
|
178
|
+
"no-caller": "error",
|
|
179
|
+
|
|
180
|
+
// Disallow case declarations inside `switch` for predictable scoping
|
|
181
|
+
"no-case-declarations": "error",
|
|
182
|
+
|
|
183
|
+
// Disallow assigning to classes to prevent errors
|
|
184
|
+
"no-class-assign": "error",
|
|
185
|
+
|
|
186
|
+
// Catch unnecessary checks like `x !== -0`
|
|
187
|
+
"no-compare-neg-zero": "error",
|
|
188
|
+
|
|
189
|
+
// Disallow assignments in conditionals to prevent bugs
|
|
190
|
+
"no-cond-assign": ["error", "always"],
|
|
191
|
+
|
|
192
|
+
// Warn on console except allow console.error for error logging
|
|
193
|
+
"no-console": ["warn", { allow: ["error"] }],
|
|
194
|
+
|
|
195
|
+
// Disallow reassigning const variables to prevent bugs
|
|
196
|
+
"no-const-assign": "error",
|
|
197
|
+
|
|
198
|
+
// Avoid ambiguous binary conditions like `a && b === c`
|
|
199
|
+
"no-constant-binary-expression": "error",
|
|
200
|
+
|
|
201
|
+
// Warn on conditions that are always truthy/falsy to avoid logic errors
|
|
202
|
+
"no-constant-condition": "warn",
|
|
203
|
+
|
|
204
|
+
// Disallow constructors that return values for clarity and correctness
|
|
205
|
+
"no-constructor-return": "error",
|
|
206
|
+
|
|
207
|
+
// Disallow invalid characters in regex
|
|
208
|
+
"no-control-regex": "error",
|
|
209
|
+
|
|
210
|
+
// Prevent `debugger` statements from slipping into production
|
|
211
|
+
"no-debugger": "error",
|
|
212
|
+
|
|
213
|
+
// Disallow duplicate function arguments to avoid parameter overwriting
|
|
214
|
+
// bugs
|
|
215
|
+
"no-dupe-args": "error",
|
|
216
|
+
|
|
217
|
+
// Disallow duplicate class members to avoid conflicts
|
|
218
|
+
"no-dupe-class-members": "error",
|
|
219
|
+
|
|
220
|
+
// Disallow duplicate else-if conditions to prevent unreachable code
|
|
221
|
+
"no-dupe-else-if": "error",
|
|
222
|
+
|
|
223
|
+
// Disallow duplicate keys in objects to avoid unexpected property
|
|
224
|
+
// overwrites
|
|
225
|
+
"no-dupe-keys": "error",
|
|
226
|
+
|
|
227
|
+
// Disallow duplicate switch cases to prevent unreachable code
|
|
228
|
+
"no-duplicate-case": "error",
|
|
229
|
+
|
|
230
|
+
// Disallow `else` after `return` to reduce unnecessary nesting
|
|
231
|
+
"no-else-return": ["error", { allowElseIf: false }],
|
|
232
|
+
|
|
233
|
+
// Disallow empty blocks to catch incomplete or missing code
|
|
234
|
+
"no-empty": "error",
|
|
235
|
+
|
|
236
|
+
// Disallow empty character classes in regex to prevent syntax errors
|
|
237
|
+
"no-empty-character-class": "error",
|
|
238
|
+
|
|
239
|
+
// Allow empty functions only when they serve as placeholders or overrides
|
|
240
|
+
"no-empty-function": [
|
|
241
|
+
"error",
|
|
242
|
+
{ allow: ["arrowFunctions", "functions", "methods"] },
|
|
243
|
+
],
|
|
244
|
+
|
|
245
|
+
// Disallow empty object/array patterns to avoid confusion
|
|
246
|
+
"no-empty-pattern": "error",
|
|
247
|
+
|
|
248
|
+
// Allow `== null` for loose null checks (undefined or null)
|
|
249
|
+
"no-eq-null": "off",
|
|
250
|
+
|
|
251
|
+
// Disallow `eval()` for security and performance reasons
|
|
252
|
+
"no-eval": "error",
|
|
253
|
+
|
|
254
|
+
// Disallow reassignment of catch clause exceptions to preserve error info
|
|
255
|
+
"no-ex-assign": "error",
|
|
256
|
+
|
|
257
|
+
// Prevent extension of native prototypes for consistency and reliability
|
|
258
|
+
"no-extend-native": "error",
|
|
259
|
+
|
|
260
|
+
// Disallow unnecessary use of `bind` to avoid confusing context
|
|
261
|
+
"no-extra-bind": "error",
|
|
262
|
+
|
|
263
|
+
// Disallow unnecessary boolean casts to simplify code
|
|
264
|
+
"no-extra-boolean-cast": "error",
|
|
265
|
+
|
|
266
|
+
// Disallow unused labels to prevent dead code
|
|
267
|
+
"no-extra-label": "error",
|
|
268
|
+
|
|
269
|
+
// Disallow fallthroughs in `switch` to avoid bugs
|
|
270
|
+
"no-fallthrough": "error",
|
|
271
|
+
|
|
272
|
+
// Disallow function reassignments to prevent accidental overwrites
|
|
273
|
+
"no-func-assign": "error",
|
|
274
|
+
|
|
275
|
+
// Allow type coercion for readability in some cases
|
|
276
|
+
"no-implicit-coercion": [
|
|
277
|
+
"off",
|
|
278
|
+
{
|
|
279
|
+
boolean: false,
|
|
280
|
+
number: true,
|
|
281
|
+
string: true,
|
|
282
|
+
allow: [],
|
|
283
|
+
},
|
|
284
|
+
],
|
|
285
|
+
|
|
286
|
+
// Disallow `eval`-like behavior for safety
|
|
287
|
+
"no-implied-eval": "error",
|
|
288
|
+
|
|
289
|
+
// Disallow comments inline after code
|
|
290
|
+
"no-inline-comments": "off",
|
|
291
|
+
|
|
292
|
+
// Disallow assigning to imports to maintain module immutability
|
|
293
|
+
"no-import-assign": "error",
|
|
294
|
+
|
|
295
|
+
// Disallow variable/function declarations inside blocks for clarity
|
|
296
|
+
"no-inner-declarations": "error",
|
|
297
|
+
|
|
298
|
+
// Disallow invalid regex to avoid runtime errors
|
|
299
|
+
"no-invalid-regexp": "error",
|
|
300
|
+
|
|
301
|
+
// Disallow irregular whitespace to prevent hard-to-find bugs
|
|
302
|
+
"no-irregular-whitespace": "error",
|
|
303
|
+
|
|
304
|
+
// Disallow legacy iterator protocol for modern JS practices
|
|
305
|
+
"no-iterator": "error",
|
|
306
|
+
|
|
307
|
+
// Disallow labels named as variables to avoid confusion
|
|
308
|
+
"no-label-var": "error",
|
|
309
|
+
|
|
310
|
+
// Disallow labeled statements to prevent goto-like logic
|
|
311
|
+
"no-labels": ["error", { allowLoop: false, allowSwitch: false }],
|
|
312
|
+
|
|
313
|
+
// Disallow lone blocks which serve no purpose
|
|
314
|
+
"no-lone-blocks": "error",
|
|
315
|
+
|
|
316
|
+
// Disallow if as the only statement in an else block
|
|
317
|
+
"no-lonely-if": "error",
|
|
318
|
+
|
|
319
|
+
// Disallow functions inside loops to avoid unexpected closures
|
|
320
|
+
"no-loop-func": "error",
|
|
321
|
+
|
|
322
|
+
// Disallow loss of precision in numeric literals to maintain accuracy
|
|
323
|
+
"no-loss-of-precision": "error",
|
|
324
|
+
|
|
325
|
+
// Disallow misleading character classes in regex to avoid matching errors
|
|
326
|
+
"no-misleading-character-class": "error",
|
|
327
|
+
|
|
328
|
+
// Disallow use of chained assignment expressions
|
|
329
|
+
"no-multi-assign": ["error"],
|
|
330
|
+
|
|
331
|
+
// Disallow multiline strings with backslash for clarity
|
|
332
|
+
"no-multi-str": "error",
|
|
333
|
+
|
|
334
|
+
// Disallow negated conditions
|
|
335
|
+
"no-negated-condition": "off",
|
|
336
|
+
|
|
337
|
+
// Disallow nested ternary expressions
|
|
338
|
+
"no-nested-ternary": "error",
|
|
339
|
+
|
|
340
|
+
// Disallow use of `new` without assignment to avoid side effects
|
|
341
|
+
"no-new": "error",
|
|
342
|
+
|
|
343
|
+
// Disallow `Function` constructor for security and readability
|
|
344
|
+
"no-new-func": "error",
|
|
345
|
+
|
|
346
|
+
// Disallow using new on native non-constructors to prevent errors
|
|
347
|
+
"no-new-native-nonconstructor": "error",
|
|
348
|
+
|
|
349
|
+
// Disallow wrapper object usage (e.g. `new Number`) for primitives
|
|
350
|
+
"no-new-wrappers": "error",
|
|
351
|
+
|
|
352
|
+
// Disallow legacy octal escapes in strings
|
|
353
|
+
"no-nonoctal-decimal-escape": "error",
|
|
354
|
+
|
|
355
|
+
// Disallow calling global objects as functions to prevent runtime errors
|
|
356
|
+
"no-obj-calls": "error",
|
|
357
|
+
|
|
358
|
+
// Disallow legacy octal literals
|
|
359
|
+
"no-octal": "error",
|
|
360
|
+
|
|
361
|
+
// Disallow octal escape sequences for clarity
|
|
362
|
+
"no-octal-escape": "error",
|
|
363
|
+
|
|
364
|
+
// Prevent mutation of parameters except for known use-cases
|
|
365
|
+
"no-param-reassign": [
|
|
366
|
+
"error",
|
|
367
|
+
{
|
|
368
|
+
props: true,
|
|
369
|
+
ignorePropertyModificationsFor: [
|
|
370
|
+
"acc", // reduce accumulators
|
|
371
|
+
"accumulator", // reduce accumulators
|
|
372
|
+
"e", // e.returnvalue
|
|
373
|
+
"req", // Express requests
|
|
374
|
+
"request", // Express requests
|
|
375
|
+
"res", // Express responses
|
|
376
|
+
"response", // Express responses
|
|
377
|
+
"$scope", // Angular 1 scopes
|
|
378
|
+
"staticContext", // ReactRouter context
|
|
379
|
+
],
|
|
380
|
+
},
|
|
381
|
+
],
|
|
382
|
+
|
|
383
|
+
// Disallow returning from Promise executor to avoid unpredictable
|
|
384
|
+
// behavior
|
|
385
|
+
"no-promise-executor-return": "error",
|
|
386
|
+
|
|
387
|
+
// Disallow use of unary operators, ++ and --
|
|
388
|
+
"no-plusplus": "error",
|
|
389
|
+
|
|
390
|
+
// Disallow usage of deprecated `__proto__` accessor
|
|
391
|
+
"no-proto": "error",
|
|
392
|
+
|
|
393
|
+
// Disallow direct calls to Object.prototype methods to avoid bugs
|
|
394
|
+
"no-prototype-builtins": "error",
|
|
395
|
+
|
|
396
|
+
// Prevent redeclaration of variables to avoid accidental overwrites
|
|
397
|
+
"no-redeclare": "error",
|
|
398
|
+
|
|
399
|
+
// Disallow multiple spaces in regex to prevent unintended matching
|
|
400
|
+
"no-regex-spaces": "error",
|
|
401
|
+
|
|
402
|
+
// Disable restricted imports for flexibility
|
|
403
|
+
"no-restricted-imports": "off",
|
|
404
|
+
|
|
405
|
+
// Restrict usage of legacy and unsafe properties with better alternatives
|
|
406
|
+
"no-restricted-properties": [
|
|
407
|
+
"error",
|
|
408
|
+
{
|
|
409
|
+
object: "arguments",
|
|
410
|
+
property: "callee",
|
|
411
|
+
message: "arguments.callee is deprecated",
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
object: "Math",
|
|
415
|
+
property: "pow",
|
|
416
|
+
message: "Use the exponentiation operator (**) instead.",
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
property: "__defineGetter__",
|
|
420
|
+
message: "Use Object.defineProperty instead.",
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
property: "__defineSetter__",
|
|
424
|
+
message: "Use Object.defineProperty instead.",
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
object: "global",
|
|
428
|
+
property: "isFinite",
|
|
429
|
+
message: "Use Number.isFinite instead",
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
object: "window",
|
|
433
|
+
property: "isFinite",
|
|
434
|
+
message: "Use Number.isFinite instead",
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
object: "self",
|
|
438
|
+
property: "isFinite",
|
|
439
|
+
message: "Use Number.isFinite instead",
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
object: "global",
|
|
443
|
+
property: "isNaN",
|
|
444
|
+
message: "Use Number.isNaN instead",
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
object: "window",
|
|
448
|
+
property: "isNaN",
|
|
449
|
+
message: "Use Number.isNaN instead",
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
object: "self",
|
|
453
|
+
property: "isNaN",
|
|
454
|
+
message: "Use Number.isNaN instead",
|
|
455
|
+
},
|
|
456
|
+
],
|
|
457
|
+
|
|
458
|
+
// Disallow certain syntax forms
|
|
459
|
+
"no-restricted-syntax": [
|
|
460
|
+
"error",
|
|
461
|
+
{
|
|
462
|
+
selector: "ForInStatement",
|
|
463
|
+
message:
|
|
464
|
+
"for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.",
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
selector: "ForOfStatement",
|
|
468
|
+
message:
|
|
469
|
+
"iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.",
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
selector: "LabeledStatement",
|
|
473
|
+
message:
|
|
474
|
+
"Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.",
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
selector: "WithStatement",
|
|
478
|
+
message:
|
|
479
|
+
"`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
|
|
480
|
+
},
|
|
481
|
+
],
|
|
482
|
+
|
|
483
|
+
// Disallow assignments in return statements to prevent confusion
|
|
484
|
+
"no-return-assign": ["error", "always"],
|
|
485
|
+
|
|
486
|
+
// Disallow use of `javascript:` URLs for security reasons
|
|
487
|
+
"no-script-url": "error",
|
|
488
|
+
|
|
489
|
+
// Prevent self-assignment bugs (e.g. `foo = foo`)
|
|
490
|
+
"no-self-assign": ["error", { props: true }],
|
|
491
|
+
|
|
492
|
+
// Disallow self-comparisons like `x === x`
|
|
493
|
+
"no-self-compare": "error",
|
|
494
|
+
|
|
495
|
+
// Disallow comma operator for readability
|
|
496
|
+
"no-sequences": "error",
|
|
497
|
+
|
|
498
|
+
// Disallow returning from setters to prevent unexpected behavior
|
|
499
|
+
"no-setter-return": "error",
|
|
500
|
+
|
|
501
|
+
// Disallow variable shadowing to prevent bugs from hiding variables
|
|
502
|
+
"no-shadow": "error",
|
|
503
|
+
|
|
504
|
+
// Disallow shadowing of restricted names to avoid errors
|
|
505
|
+
"no-shadow-restricted-names": "error",
|
|
506
|
+
|
|
507
|
+
// Disallow the use of ternary operators
|
|
508
|
+
"no-ternary": "off",
|
|
509
|
+
|
|
510
|
+
// Disallow sparse arrays to avoid unexpected holes in arrays
|
|
511
|
+
"no-sparse-arrays": "error",
|
|
512
|
+
|
|
513
|
+
// Disallow template curly in strings to catch probable typos
|
|
514
|
+
"no-template-curly-in-string": "error",
|
|
515
|
+
|
|
516
|
+
// Only throw actual `Error` objects
|
|
517
|
+
"no-throw-literal": "error",
|
|
518
|
+
|
|
519
|
+
// Disallow use of undeclared variables to avoid runtime errors
|
|
520
|
+
"no-undef": "error",
|
|
521
|
+
|
|
522
|
+
// Disallow initializing variables to undefined to avoid redundancy
|
|
523
|
+
"no-undef-init": "error",
|
|
524
|
+
|
|
525
|
+
// Disallow use of undefined variable to prevent bugs
|
|
526
|
+
"no-undefined": "error",
|
|
527
|
+
|
|
528
|
+
// Disallow dangling underscores in identifiers
|
|
529
|
+
"no-underscore-dangle": [
|
|
530
|
+
"error",
|
|
531
|
+
{
|
|
532
|
+
allow: [],
|
|
533
|
+
allowAfterThis: false,
|
|
534
|
+
allowAfterSuper: false,
|
|
535
|
+
enforceInMethodNames: true,
|
|
536
|
+
},
|
|
537
|
+
],
|
|
538
|
+
|
|
539
|
+
// Disallow the use of Boolean literals in conditional expressions
|
|
540
|
+
// also, prefer `a || b` over `a ? a : b`
|
|
541
|
+
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
542
|
+
|
|
543
|
+
// Disallow confusing multiline expressions to prevent bugs
|
|
544
|
+
"no-unexpected-multiline": "error",
|
|
545
|
+
|
|
546
|
+
// Disallow unreachable code to avoid dead code
|
|
547
|
+
"no-unreachable": "error",
|
|
548
|
+
|
|
549
|
+
// Disallow unreachable loops except for specified loop types
|
|
550
|
+
"no-unreachable-loop": "error",
|
|
551
|
+
|
|
552
|
+
// Disallow unsafe finally blocks to avoid confusing control flow
|
|
553
|
+
"no-unsafe-finally": "error",
|
|
554
|
+
|
|
555
|
+
// Disallow unsafe negations to prevent logic errors
|
|
556
|
+
"no-unsafe-negation": "error",
|
|
557
|
+
|
|
558
|
+
// Disallow unsafe optional chaining with arithmetic to avoid bugs
|
|
559
|
+
"no-unsafe-optional-chaining": [
|
|
560
|
+
"error",
|
|
561
|
+
{ disallowArithmeticOperators: true },
|
|
562
|
+
],
|
|
563
|
+
|
|
564
|
+
// Disallow expressions as statements for clarity
|
|
565
|
+
"no-unused-expressions": [
|
|
566
|
+
"error",
|
|
567
|
+
{
|
|
568
|
+
allowShortCircuit: false,
|
|
569
|
+
allowTernary: false,
|
|
570
|
+
allowTaggedTemplates: false,
|
|
571
|
+
},
|
|
572
|
+
],
|
|
573
|
+
|
|
574
|
+
// Disallow unused labels to prevent unreachable code
|
|
575
|
+
"no-unused-labels": "error",
|
|
576
|
+
|
|
577
|
+
// Disallow unused private class members to keep code clean
|
|
578
|
+
"no-unused-private-class-members": "error",
|
|
579
|
+
|
|
580
|
+
// Disallow unused variables but allow rest siblings for cleaner code
|
|
581
|
+
"no-unused-vars": [
|
|
582
|
+
"error",
|
|
583
|
+
{
|
|
584
|
+
vars: "local",
|
|
585
|
+
args: "none",
|
|
586
|
+
},
|
|
587
|
+
],
|
|
588
|
+
|
|
589
|
+
// Disallow use before definition for functions, classes, and variables
|
|
590
|
+
"no-use-before-define": [
|
|
591
|
+
"error",
|
|
592
|
+
{
|
|
593
|
+
functions: true,
|
|
594
|
+
classes: true,
|
|
595
|
+
variables: true,
|
|
596
|
+
},
|
|
597
|
+
],
|
|
598
|
+
|
|
599
|
+
// Disallow useless backreferences in regex to prevent errors
|
|
600
|
+
"no-useless-backreference": "error",
|
|
601
|
+
|
|
602
|
+
// Disallow try/catch blocks that don't do anything meaningful
|
|
603
|
+
"no-useless-catch": "error",
|
|
604
|
+
|
|
605
|
+
// Disallow useless computed keys to simplify objects
|
|
606
|
+
"no-useless-computed-key": "error",
|
|
607
|
+
|
|
608
|
+
// Disallow unnecessary string concatenation
|
|
609
|
+
"no-useless-concat": "error",
|
|
610
|
+
|
|
611
|
+
// Disallow useless constructors to keep code minimal
|
|
612
|
+
"no-useless-constructor": "error",
|
|
613
|
+
|
|
614
|
+
// Disallow escape characters that don’t do anything
|
|
615
|
+
"no-useless-escape": "error",
|
|
616
|
+
|
|
617
|
+
// Disallow unnecessary renaming to improve clarity
|
|
618
|
+
"no-useless-rename": [
|
|
619
|
+
"error",
|
|
620
|
+
{
|
|
621
|
+
ignoreDestructuring: false,
|
|
622
|
+
ignoreImport: false,
|
|
623
|
+
ignoreExport: false,
|
|
624
|
+
},
|
|
625
|
+
],
|
|
626
|
+
|
|
627
|
+
// Disallow redundant return statements
|
|
628
|
+
"no-useless-return": "error",
|
|
629
|
+
|
|
630
|
+
// Disallow var to enforce modern let/const usage
|
|
631
|
+
"no-var": "error",
|
|
632
|
+
|
|
633
|
+
// Disallow use of `void` for expressions — often a sign of poor code
|
|
634
|
+
"no-void": "error",
|
|
635
|
+
|
|
636
|
+
// Disable warnings on TODOs etc. to allow use in code reviews
|
|
637
|
+
"no-warning-comments": [
|
|
638
|
+
"off",
|
|
639
|
+
{
|
|
640
|
+
terms: ["todo", "bug", "fixme", "hack", "xxx"],
|
|
641
|
+
location: "start",
|
|
642
|
+
},
|
|
643
|
+
],
|
|
644
|
+
|
|
645
|
+
// Disallow the `with` statement, which makes code unpredictable
|
|
646
|
+
"no-with": "error",
|
|
647
|
+
|
|
648
|
+
// Enforce object shorthand syntax for cleaner code
|
|
649
|
+
"object-shorthand": [
|
|
650
|
+
"error",
|
|
651
|
+
"always",
|
|
652
|
+
{
|
|
653
|
+
ignoreConstructors: false,
|
|
654
|
+
avoidQuotes: true,
|
|
655
|
+
},
|
|
656
|
+
],
|
|
657
|
+
|
|
658
|
+
// Allow just one var statement per function
|
|
659
|
+
"one-var": ["error", "never"],
|
|
660
|
+
|
|
661
|
+
// Require assignment operator shorthand where possible or prohibit it
|
|
662
|
+
// entirely
|
|
663
|
+
"operator-assignment": ["error", "always"],
|
|
664
|
+
|
|
665
|
+
// Prefer const when variables are never reassigned to improve
|
|
666
|
+
// immutability
|
|
667
|
+
"prefer-const": [
|
|
668
|
+
"error",
|
|
669
|
+
{
|
|
670
|
+
destructuring: "any",
|
|
671
|
+
ignoreReadBeforeAssign: true,
|
|
672
|
+
},
|
|
673
|
+
],
|
|
674
|
+
|
|
675
|
+
// Prefer destructuring from objects/arrays for clearer assignments
|
|
676
|
+
"prefer-destructuring": [
|
|
677
|
+
"error",
|
|
678
|
+
{
|
|
679
|
+
VariableDeclarator: {
|
|
680
|
+
array: false,
|
|
681
|
+
object: true,
|
|
682
|
+
},
|
|
683
|
+
AssignmentExpression: {
|
|
684
|
+
array: true,
|
|
685
|
+
object: false,
|
|
686
|
+
},
|
|
687
|
+
},
|
|
688
|
+
{ enforceForRenamedProperties: false },
|
|
689
|
+
],
|
|
690
|
+
|
|
691
|
+
// Disallow the use of Math.pow in favor of the ** operator
|
|
692
|
+
"prefer-exponentiation-operator": "error",
|
|
693
|
+
|
|
694
|
+
// Prefer numeric literals instead of parseInt/Number for clarity
|
|
695
|
+
"prefer-numeric-literals": "error",
|
|
696
|
+
|
|
697
|
+
// Enforce modern `Object.hasOwn()` over `hasOwnProperty` for accuracy
|
|
698
|
+
"prefer-object-has-own": "error",
|
|
699
|
+
|
|
700
|
+
// Prefer use of an object spread over Object.assign
|
|
701
|
+
"prefer-object-spread": "error",
|
|
702
|
+
|
|
703
|
+
// Ensure rejected promises are `Error` instances
|
|
704
|
+
"prefer-promise-reject-errors": ["error", { allowEmptyReject: true }],
|
|
705
|
+
|
|
706
|
+
// Prefer regex literals for performance and readability
|
|
707
|
+
"prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
|
|
708
|
+
|
|
709
|
+
// Prefer rest parameters over arguments for better clarity and
|
|
710
|
+
// performance
|
|
711
|
+
"prefer-rest-params": "error",
|
|
712
|
+
|
|
713
|
+
// Prefer spread syntax over apply for readability
|
|
714
|
+
"prefer-spread": "error",
|
|
715
|
+
|
|
716
|
+
// Prefer template literals over string concatenation for clarity
|
|
717
|
+
"prefer-template": "error",
|
|
718
|
+
|
|
719
|
+
// Enforce specifying radix with `parseInt()` for clarity
|
|
720
|
+
"radix": "error",
|
|
721
|
+
|
|
722
|
+
// Allow atomic updates to be off for flexibility
|
|
723
|
+
"require-atomic-updates": "off",
|
|
724
|
+
|
|
725
|
+
// Allow async functions that don’t `await` for flexibility
|
|
726
|
+
"require-await": "off",
|
|
727
|
+
|
|
728
|
+
// Disable import sorting
|
|
729
|
+
"sort-imports": "off",
|
|
730
|
+
|
|
731
|
+
// Requires object keys to be sorted
|
|
732
|
+
"sort-keys": ["off", "asc", { caseSensitive: false, natural: true }],
|
|
733
|
+
|
|
734
|
+
// Sort variables within the same declaration block
|
|
735
|
+
"sort-vars": "off",
|
|
736
|
+
|
|
737
|
+
// Require symbol descriptions to improve debugging
|
|
738
|
+
"symbol-description": "error",
|
|
739
|
+
|
|
740
|
+
// Enforce using isNaN properly to avoid incorrect NaN checks
|
|
741
|
+
"use-isnan": "error",
|
|
742
|
+
|
|
743
|
+
// Enforce valid typeof comparisons requiring string literals
|
|
744
|
+
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
745
|
+
|
|
746
|
+
// Require all vars to be declared at the top to avoid hoisting surprises
|
|
747
|
+
"vars-on-top": "error",
|
|
748
|
+
|
|
749
|
+
// Enforce literal on right in Yoda conditions (`if (42 === x)`) for
|
|
750
|
+
// clarity
|
|
751
|
+
"yoda": "error",
|
|
752
|
+
|
|
753
|
+
// Require or disallow the Unicode Byte Order Mark
|
|
754
|
+
"unicode-bom": ["error", "never"],
|
|
755
|
+
},
|
|
756
|
+
},
|
|
757
|
+
];
|