@rhyster/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.
Files changed (44) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +7 -0
  3. package/dist/build.config.d.ts +3 -0
  4. package/dist/build.config.d.ts.map +1 -0
  5. package/dist/eslint.config.d.ts +853 -0
  6. package/dist/eslint.config.d.ts.map +1 -0
  7. package/dist/index.cjs +1911 -0
  8. package/dist/index.cjs.map +1 -0
  9. package/dist/index.d.cts +3731 -0
  10. package/dist/index.d.mts +3731 -0
  11. package/dist/index.d.ts +3731 -0
  12. package/dist/index.mjs +1898 -0
  13. package/dist/index.mjs.map +1 -0
  14. package/dist/src/airbnb/best-practices.d.ts +177 -0
  15. package/dist/src/airbnb/best-practices.d.ts.map +1 -0
  16. package/dist/src/airbnb/errors.d.ts +69 -0
  17. package/dist/src/airbnb/errors.d.ts.map +1 -0
  18. package/dist/src/airbnb/es6.d.ts +82 -0
  19. package/dist/src/airbnb/es6.d.ts.map +1 -0
  20. package/dist/src/airbnb/imports.d.ts +91 -0
  21. package/dist/src/airbnb/imports.d.ts.map +1 -0
  22. package/dist/src/airbnb/node.d.ts +19 -0
  23. package/dist/src/airbnb/node.d.ts.map +1 -0
  24. package/dist/src/airbnb/strict.d.ts +8 -0
  25. package/dist/src/airbnb/strict.d.ts.map +1 -0
  26. package/dist/src/airbnb/style.d.ts +310 -0
  27. package/dist/src/airbnb/style.d.ts.map +1 -0
  28. package/dist/src/airbnb/variables.d.ts +35 -0
  29. package/dist/src/airbnb/variables.d.ts.map +1 -0
  30. package/dist/src/index.d.ts +3729 -0
  31. package/dist/src/index.d.ts.map +1 -0
  32. package/dist/src/typescript.d.ts +49 -0
  33. package/dist/src/typescript.d.ts.map +1 -0
  34. package/package.json +59 -0
  35. package/src/airbnb/best-practices.ts +477 -0
  36. package/src/airbnb/errors.ts +215 -0
  37. package/src/airbnb/es6.ts +210 -0
  38. package/src/airbnb/imports.ts +288 -0
  39. package/src/airbnb/node.ts +54 -0
  40. package/src/airbnb/strict.ts +9 -0
  41. package/src/airbnb/style.ts +699 -0
  42. package/src/airbnb/variables.ts +74 -0
  43. package/src/index.ts +111 -0
  44. package/src/typescript.ts +90 -0
package/dist/index.mjs ADDED
@@ -0,0 +1,1898 @@
1
+ import stylistic from '@stylistic/eslint-plugin';
2
+ import importx from 'eslint-plugin-import-x';
3
+ import nodePlugin from 'eslint-plugin-n';
4
+ import globals from 'globals';
5
+ import tseslint from 'typescript-eslint';
6
+ import confusingBrowserGlobals from 'confusing-browser-globals';
7
+
8
+ const bestPractices = {
9
+ name: "@rhyster/eslint-config/airbnb/best-practices",
10
+ rules: {
11
+ // enforces getter/setter pairs in objects
12
+ // https://eslint.org/docs/rules/accessor-pairs
13
+ "accessor-pairs": "off",
14
+ // enforces return statements in callbacks of array's methods
15
+ // https://eslint.org/docs/rules/array-callback-return
16
+ "array-callback-return": ["error", { allowImplicit: true }],
17
+ // treat var statements as if they were block scoped
18
+ // https://eslint.org/docs/rules/block-scoped-var
19
+ "block-scoped-var": "error",
20
+ // specify the maximum cyclomatic complexity allowed in a program
21
+ // https://eslint.org/docs/rules/complexity
22
+ complexity: ["off", 20],
23
+ // enforce that class methods use "this"
24
+ // https://eslint.org/docs/rules/class-methods-use-this
25
+ "class-methods-use-this": [
26
+ "error",
27
+ {
28
+ exceptMethods: []
29
+ }
30
+ ],
31
+ // require return statements to either always or never specify values
32
+ // https://eslint.org/docs/rules/consistent-return
33
+ "consistent-return": "error",
34
+ // specify curly brace conventions for all control statements
35
+ // https://eslint.org/docs/rules/curly
36
+ curly: ["error", "multi-line"],
37
+ // multiline
38
+ // require default case in switch statements
39
+ // https://eslint.org/docs/rules/default-case
40
+ "default-case": ["error", { commentPattern: "^no default$" }],
41
+ // Enforce default clauses in switch statements to be last
42
+ // https://eslint.org/docs/rules/default-case-last
43
+ "default-case-last": "error",
44
+ // https://eslint.org/docs/rules/default-param-last
45
+ "default-param-last": "error",
46
+ // encourages use of dot notation whenever possible
47
+ // https://eslint.org/docs/rules/dot-notation
48
+ "dot-notation": ["error", { allowKeywords: true }],
49
+ // enforces consistent newlines before or after dots
50
+ // https://eslint.style/rules/default/dot-location
51
+ "@stylistic/dot-location": ["error", "property"],
52
+ // require the use of === and !==
53
+ // https://eslint.org/docs/rules/eqeqeq
54
+ eqeqeq: [
55
+ "error",
56
+ "always",
57
+ { null: "ignore" }
58
+ ],
59
+ // Require grouped accessor pairs in object literals and classes
60
+ // https://eslint.org/docs/rules/grouped-accessor-pairs
61
+ "grouped-accessor-pairs": "error",
62
+ // make sure for-in loops have an if statement
63
+ // https://eslint.org/docs/rules/guard-for-in
64
+ "guard-for-in": "error",
65
+ // enforce a maximum number of classes per file
66
+ // https://eslint.org/docs/rules/max-classes-per-file
67
+ "max-classes-per-file": ["error", 1],
68
+ // disallow the use of alert, confirm, and prompt
69
+ // https://eslint.org/docs/rules/no-alert
70
+ "no-alert": "error",
71
+ // disallow use of arguments.caller or arguments.callee
72
+ // https://eslint.org/docs/rules/no-caller
73
+ "no-caller": "error",
74
+ // disallow lexical declarations in case/default clauses
75
+ // https://eslint.org/docs/rules/no-case-declarations
76
+ "no-case-declarations": "error",
77
+ // Disallow returning value in constructor
78
+ // https://eslint.org/docs/rules/no-constructor-return
79
+ "no-constructor-return": "error",
80
+ // disallow division operators explicitly at beginning of regular expression
81
+ // https://eslint.org/docs/rules/no-div-regex
82
+ "no-div-regex": "off",
83
+ // disallow else after a return in an if
84
+ // https://eslint.org/docs/rules/no-else-return
85
+ "no-else-return": ["error", { allowElseIf: false }],
86
+ // disallow empty functions, except for standalone funcs/arrows
87
+ // https://eslint.org/docs/rules/no-empty-function
88
+ "no-empty-function": [
89
+ "error",
90
+ {
91
+ allow: [
92
+ "arrowFunctions",
93
+ "functions",
94
+ "methods"
95
+ ]
96
+ }
97
+ ],
98
+ // disallow empty destructuring patterns
99
+ // https://eslint.org/docs/rules/no-empty-pattern
100
+ "no-empty-pattern": "error",
101
+ // Disallow empty static blocks
102
+ // https://eslint.org/docs/rules/no-empty-static-block
103
+ "no-empty-static-block": "error",
104
+ // disallow comparisons to null without a type-checking operator
105
+ // https://eslint.org/docs/rules/no-eq-null
106
+ "no-eq-null": "off",
107
+ // disallow use of eval()
108
+ // https://eslint.org/docs/rules/no-eval
109
+ "no-eval": "error",
110
+ // disallow adding to native types
111
+ // https://eslint.org/docs/rules/no-extend-native
112
+ "no-extend-native": "error",
113
+ // disallow unnecessary function binding
114
+ // https://eslint.org/docs/rules/no-extra-bind
115
+ "no-extra-bind": "error",
116
+ // disallow Unnecessary Labels
117
+ // https://eslint.org/docs/rules/no-extra-label
118
+ "no-extra-label": "error",
119
+ // disallow fallthrough of case statements
120
+ // https://eslint.org/docs/rules/no-fallthrough
121
+ "no-fallthrough": "error",
122
+ // disallow the use of leading or trailing decimal points in numeric literals
123
+ // https://eslint.style/rules/default/no-floating-decimal
124
+ "@stylistic/no-floating-decimal": "error",
125
+ // disallow reassignments of native objects or read-only globals
126
+ // https://eslint.org/docs/rules/no-global-assign
127
+ "no-global-assign": ["error", { exceptions: [] }],
128
+ // disallow implicit type conversions
129
+ // https://eslint.org/docs/rules/no-implicit-coercion
130
+ "no-implicit-coercion": [
131
+ "off",
132
+ {
133
+ boolean: false,
134
+ number: true,
135
+ string: true,
136
+ allow: []
137
+ }
138
+ ],
139
+ // disallow var and named functions in global scope
140
+ // https://eslint.org/docs/rules/no-implicit-globals
141
+ "no-implicit-globals": "off",
142
+ // disallow use of eval()-like methods
143
+ // https://eslint.org/docs/rules/no-implied-eval
144
+ "no-implied-eval": "error",
145
+ // disallow this keywords outside of classes or class-like objects
146
+ // https://eslint.org/docs/rules/no-invalid-this
147
+ "no-invalid-this": "off",
148
+ // disallow usage of __iterator__ property
149
+ // https://eslint.org/docs/rules/no-iterator
150
+ "no-iterator": "error",
151
+ // disallow use of labels for anything other than loops and switches
152
+ // https://eslint.org/docs/rules/no-labels
153
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
154
+ // disallow unnecessary nested blocks
155
+ // https://eslint.org/docs/rules/no-lone-blocks
156
+ "no-lone-blocks": "error",
157
+ // disallow creation of functions within loops
158
+ // https://eslint.org/docs/rules/no-loop-func
159
+ "no-loop-func": "error",
160
+ // disallow magic numbers
161
+ // https://eslint.org/docs/rules/no-magic-numbers
162
+ "no-magic-numbers": [
163
+ "off",
164
+ {
165
+ ignore: [],
166
+ ignoreArrayIndexes: true,
167
+ enforceConst: true,
168
+ detectObjects: false
169
+ }
170
+ ],
171
+ // disallow use of multiple spaces
172
+ // https://eslint.style/rules/default/no-multi-spaces
173
+ "@stylistic/no-multi-spaces": [
174
+ "error",
175
+ {
176
+ ignoreEOLComments: false
177
+ }
178
+ ],
179
+ // disallow use of multiline strings
180
+ // https://eslint.org/docs/rules/no-multi-str
181
+ "no-multi-str": "error",
182
+ // disallow use of new operator when not part of the assignment or comparison
183
+ // https://eslint.org/docs/rules/no-new
184
+ "no-new": "error",
185
+ // disallow use of new operator for Function object
186
+ // https://eslint.org/docs/rules/no-new-func
187
+ "no-new-func": "error",
188
+ // disallows creating new instances of String, Number, and Boolean
189
+ // https://eslint.org/docs/rules/no-new-wrappers
190
+ "no-new-wrappers": "error",
191
+ // Disallow \8 and \9 escape sequences in string literals
192
+ // https://eslint.org/docs/rules/no-nonoctal-decimal-escape
193
+ "no-nonoctal-decimal-escape": "error",
194
+ // Disallow calls to the Object constructor without an argument
195
+ // https://eslint.org/docs/rules/no-object-constructor
196
+ "no-object-constructor": "error",
197
+ // disallow use of (old style) octal literals
198
+ // https://eslint.org/docs/rules/no-octal
199
+ "no-octal": "error",
200
+ // disallow use of octal escape sequences in string literals, such as
201
+ // var foo = 'Copyright \251';
202
+ // https://eslint.org/docs/rules/no-octal-escape
203
+ "no-octal-escape": "error",
204
+ // disallow reassignment of function parameters
205
+ // disallow parameter object manipulation except for specific exclusions
206
+ // rule: https://eslint.org/docs/rules/no-param-reassign.html
207
+ "no-param-reassign": [
208
+ "error",
209
+ {
210
+ props: true,
211
+ ignorePropertyModificationsFor: [
212
+ "acc",
213
+ // for reduce accumulators
214
+ "accumulator",
215
+ // for reduce accumulators
216
+ "e",
217
+ // for e.returnvalue
218
+ "ctx",
219
+ // for Koa routing
220
+ "context",
221
+ // for Koa routing
222
+ "req",
223
+ // for Express requests
224
+ "request",
225
+ // for Express requests
226
+ "res",
227
+ // for Express responses
228
+ "response",
229
+ // for Express responses
230
+ "$scope",
231
+ // for Angular 1 scopes
232
+ "staticContext"
233
+ // for ReactRouter context
234
+ ]
235
+ }
236
+ ],
237
+ // disallow usage of __proto__ property
238
+ // https://eslint.org/docs/rules/no-proto
239
+ "no-proto": "error",
240
+ // disallow declaring the same variable more than once
241
+ // https://eslint.org/docs/rules/no-redeclare
242
+ "no-redeclare": "error",
243
+ // disallow certain object properties
244
+ // https://eslint.org/docs/rules/no-restricted-properties
245
+ "no-restricted-properties": [
246
+ "error",
247
+ {
248
+ object: "arguments",
249
+ property: "callee",
250
+ message: "arguments.callee is deprecated"
251
+ },
252
+ {
253
+ object: "global",
254
+ property: "isFinite",
255
+ message: "Please use Number.isFinite instead"
256
+ },
257
+ {
258
+ object: "self",
259
+ property: "isFinite",
260
+ message: "Please use Number.isFinite instead"
261
+ },
262
+ {
263
+ object: "window",
264
+ property: "isFinite",
265
+ message: "Please use Number.isFinite instead"
266
+ },
267
+ {
268
+ object: "global",
269
+ property: "isNaN",
270
+ message: "Please use Number.isNaN instead"
271
+ },
272
+ {
273
+ object: "self",
274
+ property: "isNaN",
275
+ message: "Please use Number.isNaN instead"
276
+ },
277
+ {
278
+ object: "window",
279
+ property: "isNaN",
280
+ message: "Please use Number.isNaN instead"
281
+ },
282
+ {
283
+ property: "__defineGetter__",
284
+ message: "Please use Object.defineProperty instead."
285
+ },
286
+ {
287
+ property: "__defineSetter__",
288
+ message: "Please use Object.defineProperty instead."
289
+ },
290
+ {
291
+ object: "Math",
292
+ property: "pow",
293
+ message: "Use the exponentiation operator (**) instead."
294
+ }
295
+ ],
296
+ // disallow use of assignment in return statement
297
+ // https://eslint.org/docs/rules/no-return-assign
298
+ "no-return-assign": ["error", "always"],
299
+ // disallow redundant `return await`
300
+ // https://eslint.org/docs/rules/no-return-await
301
+ "no-return-await": "error",
302
+ // disallow use of `javascript:` urls.
303
+ // https://eslint.org/docs/rules/no-script-url
304
+ "no-script-url": "error",
305
+ // disallow self assignment
306
+ // https://eslint.org/docs/rules/no-self-assign
307
+ "no-self-assign": [
308
+ "error",
309
+ {
310
+ props: true
311
+ }
312
+ ],
313
+ // disallow comparisons where both sides are exactly the same
314
+ // https://eslint.org/docs/rules/no-self-compare
315
+ "no-self-compare": "error",
316
+ // disallow use of comma operator
317
+ // https://eslint.org/docs/rules/no-sequences
318
+ "no-sequences": "error",
319
+ // restrict what can be thrown as an exception
320
+ // https://eslint.org/docs/rules/no-throw-literal
321
+ "no-throw-literal": "error",
322
+ // disallow unmodified conditions of loops
323
+ // https://eslint.org/docs/rules/no-unmodified-loop-condition
324
+ "no-unmodified-loop-condition": "off",
325
+ // disallow usage of expressions in statement position
326
+ // https://eslint.org/docs/rules/no-unused-expressions
327
+ "no-unused-expressions": [
328
+ "error",
329
+ {
330
+ allowShortCircuit: false,
331
+ allowTernary: false,
332
+ allowTaggedTemplates: false
333
+ }
334
+ ],
335
+ // disallow unused labels
336
+ // https://eslint.org/docs/rules/no-unused-labels
337
+ "no-unused-labels": "error",
338
+ // disallow unnecessary .call() and .apply()
339
+ // https://eslint.org/docs/rules/no-useless-call
340
+ "no-useless-call": "off",
341
+ // Disallow unnecessary catch clauses
342
+ // https://eslint.org/docs/rules/no-useless-catch
343
+ "no-useless-catch": "error",
344
+ // disallow useless string concatenation
345
+ // https://eslint.org/docs/rules/no-useless-concat
346
+ "no-useless-concat": "error",
347
+ // disallow unnecessary string escaping
348
+ // https://eslint.org/docs/rules/no-useless-escape
349
+ "no-useless-escape": "error",
350
+ // disallow redundant return; keywords
351
+ // https://eslint.org/docs/rules/no-useless-return
352
+ "no-useless-return": "error",
353
+ // disallow use of void operator
354
+ // https://eslint.org/docs/rules/no-void
355
+ "no-void": "error",
356
+ // disallow usage of configurable warning terms in comments: e.g. todo
357
+ // https://eslint.org/docs/rules/no-warning-comments
358
+ "no-warning-comments": [
359
+ "off",
360
+ {
361
+ terms: [
362
+ "todo",
363
+ "fixme",
364
+ "xxx"
365
+ ],
366
+ location: "start"
367
+ }
368
+ ],
369
+ // disallow use of the with statement
370
+ // https://eslint.org/docs/rules/no-with
371
+ "no-with": "error",
372
+ // require using Error objects as Promise rejection reasons
373
+ // https://eslint.org/docs/rules/prefer-promise-reject-errors
374
+ "prefer-promise-reject-errors": ["error", { allowEmptyReject: true }],
375
+ // Suggest using named capture group in regular expression
376
+ // https://eslint.org/docs/rules/prefer-named-capture-group
377
+ "prefer-named-capture-group": "off",
378
+ // Prefer Object.hasOwn() over Object.prototype.hasOwnProperty.call()
379
+ // https://eslint.org/docs/rules/prefer-object-has-own
380
+ "prefer-object-has-own": "error",
381
+ // https://eslint.org/docs/rules/prefer-regex-literals
382
+ "prefer-regex-literals": [
383
+ "error",
384
+ {
385
+ disallowRedundantWrapping: true
386
+ }
387
+ ],
388
+ // require use of the second argument for parseInt()
389
+ // https://eslint.org/docs/rules/radix
390
+ radix: "error",
391
+ // require `await` in `async function`
392
+ // (note: this is a horrible rule that should never be used)
393
+ // https://eslint.org/docs/rules/require-await
394
+ "require-await": "off",
395
+ // Enforce the use of u flag on RegExp
396
+ // https://eslint.org/docs/rules/require-unicode-regexp
397
+ "require-unicode-regexp": "off",
398
+ // requires to declare all vars on top of their containing scope
399
+ // https://eslint.org/docs/rules/vars-on-top
400
+ "vars-on-top": "error",
401
+ // require immediate function invocation to be wrapped in parentheses
402
+ // https://eslint.style/rules/default/wrap-iife
403
+ "@stylistic/wrap-iife": [
404
+ "error",
405
+ "outside",
406
+ { functionPrototypeMethods: false }
407
+ ],
408
+ // require or disallow Yoda conditions
409
+ // https://eslint.org/docs/rules/yoda
410
+ yoda: "error"
411
+ }
412
+ };
413
+
414
+ const errors = {
415
+ name: "@rhyster/eslint-config/airbnb/errors",
416
+ rules: {
417
+ // Enforce “for” loop update clause moving the counter in the right direction
418
+ // https://eslint.org/docs/rules/for-direction
419
+ "for-direction": "error",
420
+ // Enforces that a return statement is present in property getters
421
+ // https://eslint.org/docs/rules/getter-return
422
+ "getter-return": ["error", { allowImplicit: true }],
423
+ // disallow using an async function as a Promise executor
424
+ // https://eslint.org/docs/rules/no-async-promise-executor
425
+ "no-async-promise-executor": "error",
426
+ // Disallow await inside of loops
427
+ // https://eslint.org/docs/rules/no-await-in-loop
428
+ "no-await-in-loop": "error",
429
+ // Disallow comparisons to negative zero
430
+ // https://eslint.org/docs/rules/no-compare-neg-zero
431
+ "no-compare-neg-zero": "error",
432
+ // disallow assignment in conditional expressions
433
+ // https://eslint.org/docs/rules/no-cond-assign
434
+ "no-cond-assign": ["error", "always"],
435
+ // disallow use of console
436
+ // https://eslint.org/docs/rules/no-console
437
+ "no-console": [
438
+ "error",
439
+ {
440
+ allow: ["warn", "error"]
441
+ }
442
+ ],
443
+ // Disallows expressions where the operation doesn't affect the value
444
+ // https://eslint.org/docs/rules/no-constant-binary-expression
445
+ "no-constant-binary-expression": "error",
446
+ // disallow use of constant expressions in conditions
447
+ // https://eslint.org/docs/rules/no-constant-condition
448
+ "no-constant-condition": "error",
449
+ // disallow control characters in regular expressions
450
+ // https://eslint.org/docs/rules/no-control-regex
451
+ "no-control-regex": "error",
452
+ // disallow use of debugger
453
+ // https://eslint.org/docs/rules/no-debugger
454
+ "no-debugger": "error",
455
+ // disallow duplicate arguments in functions
456
+ // https://eslint.org/docs/rules/no-dupe-args
457
+ "no-dupe-args": "error",
458
+ // Disallow duplicate conditions in if-else-if chains
459
+ // https://eslint.org/docs/rules/no-dupe-else-if
460
+ "no-dupe-else-if": "error",
461
+ // disallow duplicate keys when creating object literals
462
+ // https://eslint.org/docs/rules/no-dupe-keys
463
+ "no-dupe-keys": "error",
464
+ // disallow a duplicate case label.
465
+ // https://eslint.org/docs/rules/no-duplicate-case
466
+ "no-duplicate-case": "error",
467
+ // disallow empty statements
468
+ // https://eslint.org/docs/rules/no-empty
469
+ "no-empty": "error",
470
+ // disallow the use of empty character classes in regular expressions
471
+ // https://eslint.org/docs/rules/no-empty-character-class
472
+ "no-empty-character-class": "error",
473
+ // disallow assigning to the exception in a catch block
474
+ // https://eslint.org/docs/rules/no-ex-assign
475
+ "no-ex-assign": "error",
476
+ // disallow double-negation boolean casts in a boolean context
477
+ // https://eslint.org/docs/rules/no-extra-boolean-cast
478
+ "no-extra-boolean-cast": "error",
479
+ // disallow unnecessary parentheses
480
+ // https://eslint.style/rules/default/no-extra-parens
481
+ "@stylistic/no-extra-parens": [
482
+ "off",
483
+ "all",
484
+ {
485
+ conditionalAssign: true,
486
+ nestedBinaryExpressions: false,
487
+ returnAssign: false,
488
+ enforceForArrowConditionals: false
489
+ }
490
+ ],
491
+ // disallow unnecessary semicolons
492
+ // https://eslint.style/rules/default/no-extra-semi
493
+ "@stylistic/no-extra-semi": "error",
494
+ // disallow overwriting functions written as function declarations
495
+ // https://eslint.org/docs/rules/no-func-assign
496
+ "no-func-assign": "error",
497
+ // disallow assigning to imported bindings
498
+ // https://eslint.org/docs/rules/no-import-assign
499
+ "no-import-assign": "error",
500
+ // disallow function or variable declarations in nested blocks
501
+ // https://eslint.org/docs/rules/no-inner-declarations
502
+ "no-inner-declarations": "error",
503
+ // disallow invalid regular expression strings in the RegExp constructor
504
+ // https://eslint.org/docs/rules/no-invalid-regexp
505
+ "no-invalid-regexp": "error",
506
+ // disallow irregular whitespace outside of strings and comments
507
+ // https://eslint.org/docs/rules/no-irregular-whitespace
508
+ "no-irregular-whitespace": "error",
509
+ // Disallow Number Literals That Lose Precision
510
+ // https://eslint.org/docs/rules/no-loss-of-precision
511
+ "no-loss-of-precision": "error",
512
+ // Disallow characters which are made with multiple code points in character class syntax
513
+ // https://eslint.org/docs/rules/no-misleading-character-class
514
+ "no-misleading-character-class": "error",
515
+ // disallow the use of object properties of the global object (Math and JSON) as functions
516
+ // https://eslint.org/docs/rules/no-obj-calls
517
+ "no-obj-calls": "error",
518
+ // Disallow new operators with global non-constructor functions
519
+ // https://eslint.org/docs/rules/no-new-native-nonconstructor
520
+ "no-new-native-nonconstructor": "error",
521
+ // Disallow returning values from Promise executor functions
522
+ // https://eslint.org/docs/rules/no-promise-executor-return
523
+ "no-promise-executor-return": "error",
524
+ // disallow use of Object.prototypes builtins directly
525
+ // https://eslint.org/docs/rules/no-prototype-builtins
526
+ "no-prototype-builtins": "error",
527
+ // disallow multiple spaces in a regular expression literal
528
+ // https://eslint.org/docs/rules/no-regex-spaces
529
+ "no-regex-spaces": "error",
530
+ // Disallow returning values from setters
531
+ // https://eslint.org/docs/rules/no-setter-return
532
+ "no-setter-return": "error",
533
+ // disallow sparse arrays
534
+ // https://eslint.org/docs/rules/no-sparse-arrays
535
+ "no-sparse-arrays": "error",
536
+ // Disallow template literal placeholder syntax in regular strings
537
+ // https://eslint.org/docs/rules/no-template-curly-in-string
538
+ "no-template-curly-in-string": "error",
539
+ // Avoid code that looks like two expressions but is actually one
540
+ // https://eslint.org/docs/rules/no-unexpected-multiline
541
+ "no-unexpected-multiline": "error",
542
+ // disallow unreachable statements after a return, throw, continue, or break statement
543
+ // https://eslint.org/docs/rules/no-unreachable
544
+ "no-unreachable": "error",
545
+ // Disallow loops with a body that allows only one iteration
546
+ // https://eslint.org/docs/rules/no-unreachable-loop
547
+ "no-unreachable-loop": [
548
+ "error",
549
+ {
550
+ ignore: []
551
+ // WhileStatement, DoWhileStatement, ForStatement, ForInStatement, ForOfStatement
552
+ }
553
+ ],
554
+ // disallow return/throw/break/continue inside finally blocks
555
+ // https://eslint.org/docs/rules/no-unsafe-finally
556
+ "no-unsafe-finally": "error",
557
+ // disallow negating the left operand of relational operators
558
+ // https://eslint.org/docs/rules/no-unsafe-negation
559
+ "no-unsafe-negation": "error",
560
+ // disallow use of optional chaining in contexts where the undefined value is not allowed
561
+ // https://eslint.org/docs/rules/no-unsafe-optional-chaining
562
+ "no-unsafe-optional-chaining": ["error", { disallowArithmeticOperators: true }],
563
+ // Disallow Unused Private Class Members
564
+ // https://eslint.org/docs/rules/no-unused-private-class-members
565
+ "no-unused-private-class-members": "error",
566
+ // Disallow useless backreferences in regular expressions
567
+ // https://eslint.org/docs/rules/no-useless-backreference
568
+ "no-useless-backreference": "error",
569
+ // Disallow assignments that can lead to race conditions due to usage of await or yield
570
+ // https://eslint.org/docs/rules/require-atomic-updates
571
+ // note: not enabled because it is very buggy
572
+ "require-atomic-updates": "off",
573
+ // disallow comparisons with the value NaN
574
+ // https://eslint.org/docs/rules/use-isnan
575
+ "use-isnan": "error",
576
+ // ensure that the results of typeof are compared against a valid string
577
+ // https://eslint.org/docs/rules/valid-typeof
578
+ "valid-typeof": ["error", { requireStringLiterals: true }]
579
+ }
580
+ };
581
+
582
+ const es6 = {
583
+ name: "@rhyster/eslint-config/airbnb/es6",
584
+ rules: {
585
+ // enforces no braces where they can be omitted
586
+ // https://eslint.org/docs/rules/arrow-body-style
587
+ "arrow-body-style": [
588
+ "error",
589
+ "as-needed",
590
+ {
591
+ requireReturnForObjectLiteral: false
592
+ }
593
+ ],
594
+ // require parens in arrow function arguments
595
+ // https://eslint.style/rules/default/arrow-parens
596
+ "@stylistic/arrow-parens": ["error", "always"],
597
+ // require space before/after arrow function's arrow
598
+ // https://eslint.style/rules/default/arrow-spacing
599
+ "@stylistic/arrow-spacing": ["error", { before: true, after: true }],
600
+ // verify super() callings in constructors
601
+ // https://eslint.org/docs/rules/constructor-super
602
+ "constructor-super": "error",
603
+ // enforce the spacing around the * in generator functions
604
+ // https://eslint.style/rules/default/generator-star-spacing
605
+ "@stylistic/generator-star-spacing": ["error", { before: false, after: true }],
606
+ // disallow modifying variables of class declarations
607
+ // https://eslint.org/docs/rules/no-class-assign
608
+ "no-class-assign": "error",
609
+ // disallow arrow functions where they could be confused with comparisons
610
+ // https://eslint.style/rules/default/no-confusing-arrow
611
+ "@stylistic/no-confusing-arrow": [
612
+ "error",
613
+ {
614
+ allowParens: true
615
+ }
616
+ ],
617
+ // disallow modifying variables that are declared using const
618
+ // https://eslint.org/docs/rules/no-const-assign
619
+ "no-const-assign": "error",
620
+ // disallow duplicate class members
621
+ // https://eslint.org/docs/rules/no-dupe-class-members
622
+ "no-dupe-class-members": "error",
623
+ // disallow importing from the same path more than once
624
+ // https://eslint.org/docs/rules/no-duplicate-imports
625
+ // replaced by https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-duplicates.md
626
+ "no-duplicate-imports": "off",
627
+ // Disallow specified names in exports
628
+ // https://eslint.org/docs/rules/no-restricted-exports
629
+ "no-restricted-exports": [
630
+ "error",
631
+ {
632
+ restrictedNamedExports: [
633
+ "default",
634
+ // use `export default` to provide a default export
635
+ "then"
636
+ // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
637
+ ]
638
+ }
639
+ ],
640
+ // disallow specific imports
641
+ // https://eslint.org/docs/rules/no-restricted-imports
642
+ "no-restricted-imports": [
643
+ "off",
644
+ {
645
+ paths: [],
646
+ patterns: []
647
+ }
648
+ ],
649
+ // disallow to use this/super before super() calling in constructors.
650
+ // https://eslint.org/docs/rules/no-this-before-super
651
+ "no-this-before-super": "error",
652
+ // disallow useless computed property keys
653
+ // https://eslint.org/docs/rules/no-useless-computed-key
654
+ "no-useless-computed-key": "error",
655
+ // disallow unnecessary constructor
656
+ // https://eslint.org/docs/rules/no-useless-constructor
657
+ "no-useless-constructor": "error",
658
+ // disallow renaming import, export, and destructured assignments to the same name
659
+ // https://eslint.org/docs/rules/no-useless-rename
660
+ "no-useless-rename": [
661
+ "error",
662
+ {
663
+ ignoreDestructuring: false,
664
+ ignoreImport: false,
665
+ ignoreExport: false
666
+ }
667
+ ],
668
+ // require let or const instead of var
669
+ // https://eslint.org/docs/rules/no-var
670
+ "no-var": "error",
671
+ // require method and property shorthand syntax for object literals
672
+ // https://eslint.org/docs/rules/object-shorthand
673
+ "object-shorthand": [
674
+ "error",
675
+ "always",
676
+ {
677
+ ignoreConstructors: false,
678
+ avoidQuotes: true
679
+ }
680
+ ],
681
+ // suggest using arrow functions as callbacks
682
+ // https://eslint.org/docs/rules/prefer-arrow-callback
683
+ "prefer-arrow-callback": [
684
+ "error",
685
+ {
686
+ allowNamedFunctions: false,
687
+ allowUnboundThis: true
688
+ }
689
+ ],
690
+ // suggest using of const declaration for variables that are never modified after declared
691
+ // https://eslint.org/docs/rules/prefer-const
692
+ "prefer-const": [
693
+ "error",
694
+ {
695
+ destructuring: "any",
696
+ ignoreReadBeforeAssign: true
697
+ }
698
+ ],
699
+ // Prefer destructuring from arrays and objects
700
+ // https://eslint.org/docs/rules/prefer-destructuring
701
+ "prefer-destructuring": [
702
+ "error",
703
+ {
704
+ VariableDeclarator: {
705
+ array: false,
706
+ object: true
707
+ },
708
+ AssignmentExpression: {
709
+ array: true,
710
+ object: false
711
+ }
712
+ },
713
+ {
714
+ enforceForRenamedProperties: false
715
+ }
716
+ ],
717
+ // disallow parseInt() in favor of binary, octal, and hexadecimal literals
718
+ // https://eslint.org/docs/rules/prefer-numeric-literals
719
+ "prefer-numeric-literals": "error",
720
+ // use rest parameters instead of arguments
721
+ // https://eslint.org/docs/rules/prefer-rest-params
722
+ "prefer-rest-params": "error",
723
+ // suggest using the spread syntax instead of .apply()
724
+ // https://eslint.org/docs/rules/prefer-spread
725
+ "prefer-spread": "error",
726
+ // suggest using template literals instead of string concatenation
727
+ // https://eslint.org/docs/rules/prefer-template
728
+ "prefer-template": "error",
729
+ // disallow generator functions that do not have yield
730
+ // https://eslint.org/docs/rules/require-yield
731
+ "require-yield": "error",
732
+ // enforce spacing between object rest-spread
733
+ // https://eslint.style/rules/default/rest-spread-spacing
734
+ "@stylistic/rest-spread-spacing": ["error", "never"],
735
+ // import sorting
736
+ // https://eslint.org/docs/rules/sort-imports
737
+ "sort-imports": [
738
+ "off",
739
+ {
740
+ ignoreCase: false,
741
+ ignoreDeclarationSort: false,
742
+ ignoreMemberSort: false,
743
+ memberSyntaxSortOrder: [
744
+ "none",
745
+ "all",
746
+ "multiple",
747
+ "single"
748
+ ]
749
+ }
750
+ ],
751
+ // require a Symbol description
752
+ // https://eslint.org/docs/rules/symbol-description
753
+ "symbol-description": "error",
754
+ // enforce usage of spacing in template strings
755
+ // https://eslint.style/rules/default/template-curly-spacing
756
+ "@stylistic/template-curly-spacing": "error",
757
+ // enforce spacing around the * in yield* expressions
758
+ // https://eslint.style/rules/default/yield-star-spacing
759
+ "@stylistic/yield-star-spacing": ["error", "after"]
760
+ }
761
+ };
762
+
763
+ const imports = {
764
+ name: "@rhyster/eslint-config/airbnb/imports",
765
+ rules: {
766
+ // Static analysis:
767
+ // ensure imports point to files/modules that can be resolved
768
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-unresolved.md
769
+ "import-x/no-unresolved": [
770
+ "error",
771
+ { commonjs: true, caseSensitive: true }
772
+ ],
773
+ // ensure named imports coupled with named exports
774
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/named.md
775
+ "import-x/named": "error",
776
+ // ensure default import coupled with default export
777
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/default.md
778
+ "import-x/default": "off",
779
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/namespace.md
780
+ "import-x/namespace": "off",
781
+ // Helpful warnings:
782
+ // disallow invalid exports, e.g. multiple defaults
783
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/export.md
784
+ "import-x/export": "error",
785
+ // do not allow a default import name to match a named export
786
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-named-as-default.md
787
+ "import-x/no-named-as-default": "error",
788
+ // warn on accessing default export property names that are also named exports
789
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-named-as-default-member.md
790
+ "import-x/no-named-as-default-member": "error",
791
+ // disallow use of jsdoc-marked-deprecated imports
792
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-deprecated.md
793
+ "import-x/no-deprecated": "off",
794
+ // Forbid the use of extraneous packages
795
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-extraneous-dependencies.md
796
+ // paths are treated both as absolute paths, and relative to process.cwd()
797
+ "import-x/no-extraneous-dependencies": [
798
+ "error",
799
+ {
800
+ devDependencies: [
801
+ "test/**",
802
+ // tape, common npm pattern
803
+ "tests/**",
804
+ // also common npm pattern
805
+ "spec/**",
806
+ // mocha, rspec-like pattern
807
+ "**/__tests__/**",
808
+ // jest pattern
809
+ "**/__mocks__/**",
810
+ // jest pattern
811
+ "test.{js,ts}",
812
+ // repos with a single test file
813
+ "test-*.{js,ts}",
814
+ // repos with multiple top-level test files
815
+ "**/*{.,_}{test,spec}.{js,ts}",
816
+ // tests where the extension or filename suffix denotes that it is a test
817
+ "**/jest.config.js",
818
+ // jest config
819
+ "**/jest.setup.js",
820
+ // jest setup
821
+ "**/vue.config.js",
822
+ // vue-cli config
823
+ "**/webpack.config.js",
824
+ // webpack config
825
+ "**/webpack.config.*.js",
826
+ // webpack config
827
+ "**/rollup.config.js",
828
+ // rollup config
829
+ "**/rollup.config.*.js",
830
+ // rollup config
831
+ "**/gulpfile.js",
832
+ // gulp config
833
+ "**/gulpfile.*.js",
834
+ // gulp config
835
+ "**/Gruntfile{,.js}",
836
+ // grunt config
837
+ "**/protractor.conf.js",
838
+ // protractor config
839
+ "**/protractor.conf.*.js",
840
+ // protractor config
841
+ "**/karma.conf.js",
842
+ // karma config
843
+ "**/.eslintrc.js"
844
+ // eslint config
845
+ ],
846
+ optionalDependencies: false
847
+ }
848
+ ],
849
+ // Forbid mutable exports
850
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-mutable-exports.md
851
+ "import-x/no-mutable-exports": "error",
852
+ // Module systems:
853
+ // disallow require()
854
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-commonjs.md
855
+ "import-x/no-commonjs": "error",
856
+ // disallow AMD require/define
857
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-amd.md
858
+ "import-x/no-amd": "error",
859
+ // No Node.js builtin modules
860
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-nodejs-modules.md
861
+ "import-x/no-nodejs-modules": "error",
862
+ // Style guide:
863
+ // disallow non-import statements appearing before import statements
864
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/first.md
865
+ "import-x/first": "error",
866
+ // disallow duplicate imports
867
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-duplicates.md
868
+ "import-x/no-duplicates": "error",
869
+ // disallow namespace imports
870
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-namespace.md
871
+ "import-x/no-namespace": "error",
872
+ // Ensure consistent use of file extension within the import path
873
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/extensions.md
874
+ "import-x/extensions": [
875
+ "error",
876
+ "always",
877
+ {
878
+ ignorePackages: true,
879
+ checkTypeImports: true
880
+ }
881
+ ],
882
+ // ensure absolute imports are above relative imports and
883
+ // that unassigned imports are ignored
884
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/order.md
885
+ "import-x/order": [
886
+ "error",
887
+ {
888
+ groups: [
889
+ "builtin",
890
+ "external",
891
+ "internal",
892
+ "parent",
893
+ "sibling",
894
+ "index",
895
+ "object",
896
+ "type"
897
+ ],
898
+ "newlines-between": "always",
899
+ alphabetize: {
900
+ order: "asc",
901
+ orderImportKind: "asc"
902
+ }
903
+ }
904
+ ],
905
+ // Require a newline after the last import-x/require in a group
906
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/newline-after-import.md
907
+ "import-x/newline-after-import": "error",
908
+ // Require modules with a single export to use a default export
909
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/prefer-default-export.md
910
+ "import-x/prefer-default-export": "error",
911
+ // Restrict which files can be imported in a given folder
912
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-restricted-paths.md
913
+ "import-x/no-restricted-paths": "off",
914
+ // Forbid modules to have too many dependencies
915
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/max-dependencies.md
916
+ "import-x/max-dependencies": ["off", { max: 10 }],
917
+ // Forbid import of modules using absolute paths
918
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-absolute-path.md
919
+ "import-x/no-absolute-path": "error",
920
+ // Forbid require() calls with expressions
921
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-dynamic-require.md
922
+ "import-x/no-dynamic-require": "error",
923
+ // prevent importing the submodules of other modules
924
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-internal-modules.md
925
+ "import-x/no-internal-modules": [
926
+ "off",
927
+ {
928
+ allow: []
929
+ }
930
+ ],
931
+ // Warn if a module could be mistakenly parsed as a script by a consumer
932
+ // leveraging Unambiguous JavaScript Grammar
933
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/unambiguous.md
934
+ // this should not be enabled until this proposal has at least been *presented* to TC39.
935
+ // At the moment, it's not a thing.
936
+ "import-x/unambiguous": "off",
937
+ // Forbid Webpack loader syntax in imports
938
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-webpack-loader-syntax.md
939
+ "import-x/no-webpack-loader-syntax": "error",
940
+ // Prevent unassigned imports
941
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-unassigned-import.md
942
+ // importing for side effects is perfectly acceptable, if you need side effects.
943
+ "import-x/no-unassigned-import": "off",
944
+ // Prevent importing the default as if it were named
945
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-named-default.md
946
+ "import-x/no-named-default": "error",
947
+ // Reports if a module's default export is unnamed
948
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-anonymous-default-export.md
949
+ "import-x/no-anonymous-default-export": [
950
+ "off",
951
+ {
952
+ allowArray: false,
953
+ allowArrowFunction: false,
954
+ allowAnonymousClass: false,
955
+ allowAnonymousFunction: false,
956
+ allowLiteral: false,
957
+ allowObject: false
958
+ }
959
+ ],
960
+ // This rule enforces that all exports are declared at the bottom of the file.
961
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/exports-last.md
962
+ "import-x/exports-last": "error",
963
+ // Reports when named exports are not grouped together in a single export declaration
964
+ // or when multiple assignments to CommonJS module.exports or exports object are present
965
+ // in a single file.
966
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/group-exports.md
967
+ "import-x/group-exports": "off",
968
+ // forbid default exports. this is a terrible rule, do not use it.
969
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-default-export.md
970
+ "import-x/no-default-export": "off",
971
+ // Prohibit named exports. this is a terrible rule, do not use it.
972
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-named-export.md
973
+ "import-x/no-named-export": "off",
974
+ // Forbid a module from importing itself
975
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-self-import.md
976
+ "import-x/no-self-import": "error",
977
+ // Forbid cyclical dependencies between modules
978
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-cycle.md
979
+ "import-x/no-cycle": ["error", { maxDepth: "\u221E" }],
980
+ // Ensures that there are no useless path segments
981
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-useless-path-segments.md
982
+ "import-x/no-useless-path-segments": ["error", { commonjs: true }],
983
+ // dynamic imports require a leading comment with a webpackChunkName
984
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/dynamic-import-chunkname.md
985
+ "import-x/dynamic-import-chunkname": [
986
+ "off",
987
+ {
988
+ importFunctions: [],
989
+ webpackChunknameFormat: "[0-9a-zA-Z-_/.]+"
990
+ }
991
+ ],
992
+ // Use this rule to prevent imports to folders in relative parent paths.
993
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-relative-parent-imports.md
994
+ "import-x/no-relative-parent-imports": "off",
995
+ // Reports modules without any exports, or with unused exports
996
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-unused-modules.md
997
+ "import-x/no-unused-modules": [
998
+ "error",
999
+ {
1000
+ ignoreExports: [],
1001
+ missingExports: true,
1002
+ unusedExports: true
1003
+ }
1004
+ ],
1005
+ // Reports the use of import declarations with CommonJS exports
1006
+ // in any module except for the main module.
1007
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-import-module-exports.md
1008
+ "import-x/no-import-module-exports": [
1009
+ "error",
1010
+ {
1011
+ exceptions: []
1012
+ }
1013
+ ],
1014
+ // Use this rule to prevent importing packages through relative paths.
1015
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-relative-packages.md
1016
+ "import-x/no-relative-packages": "error",
1017
+ // enforce a consistent style for type specifiers (inline or top-level)
1018
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/consistent-type-specifier-style.md
1019
+ "import-x/consistent-type-specifier-style": ["error", "prefer-top-level"],
1020
+ // Reports the use of empty named import blocks.
1021
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-empty-named-blocks.md
1022
+ "import-x/no-empty-named-blocks": "error"
1023
+ }
1024
+ };
1025
+
1026
+ const nodeRules = {
1027
+ name: "@rhyster/eslint-config/airbnb/node",
1028
+ rules: {
1029
+ // enforce return after a callback
1030
+ // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/callback-return.md
1031
+ "n/callback-return": "off",
1032
+ // require all requires be top-level
1033
+ // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/global-require.md
1034
+ "n/global-require": "error",
1035
+ // enforces error handling in callbacks (node environment)
1036
+ // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/handle-callback-err.md
1037
+ "n/handle-callback-err": "off",
1038
+ // disallow use of the Buffer() constructor
1039
+ // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-deprecated-api.md
1040
+ "n/no-deprecated-api": "error",
1041
+ // disallow mixing regular variable and require declarations
1042
+ // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-mixed-requires.md
1043
+ "n/no-mixed-requires": ["off", false],
1044
+ // disallow use of new operator with the require function
1045
+ // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-new-require.md
1046
+ "n/no-new-require": "error",
1047
+ // disallow string concatenation with __dirname and __filename
1048
+ // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-path-concat.md
1049
+ "n/no-path-concat": "error",
1050
+ // disallow use of process.env
1051
+ // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-process-env.md
1052
+ "n/no-process-env": "off",
1053
+ // disallow process.exit()
1054
+ // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-process-exit.md
1055
+ "n/no-process-exit": "off",
1056
+ // restrict usage of specified node modules
1057
+ // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-restricted-modules.md
1058
+ "n/no-restricted-modules": "off",
1059
+ // disallow use of synchronous methods (off by default)
1060
+ // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-sync.md
1061
+ "n/no-sync": "off",
1062
+ // No Node.js builtin modules
1063
+ // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-nodejs-modules.md
1064
+ "import-x/no-nodejs-modules": "off"
1065
+ }
1066
+ };
1067
+
1068
+ const strict = {
1069
+ name: "@rhyster/eslint-config/airbnb/strict",
1070
+ rules: {
1071
+ // babel inserts `'use strict';` for us
1072
+ strict: ["error", "never"]
1073
+ }
1074
+ };
1075
+
1076
+ const style = {
1077
+ name: "@rhyster/eslint-config/airbnb/style",
1078
+ rules: {
1079
+ // enforce line breaks after opening and before closing array brackets
1080
+ // https://eslint.style/rules/default/array-bracket-newline
1081
+ "@stylistic/array-bracket-newline": ["error", "consistent"],
1082
+ // object option alternative: { multiline: true, minItems: 3 }
1083
+ // enforce line breaks between array elements
1084
+ // https://eslint.style/rules/default/array-element-newline
1085
+ "@stylistic/array-element-newline": ["error", { consistent: true, multiline: true, minItems: 3 }],
1086
+ // enforce spacing inside array brackets
1087
+ // https://eslint.style/rules/default/array-bracket-spacing
1088
+ "@stylistic/array-bracket-spacing": ["error", "never"],
1089
+ // enforce spacing inside single-line blocks
1090
+ // https://eslint.style/rules/default/block-spacing
1091
+ "@stylistic/block-spacing": ["error", "always"],
1092
+ // enforce one true brace style
1093
+ // https://eslint.style/rules/default/brace-style
1094
+ "@stylistic/brace-style": [
1095
+ "error",
1096
+ "1tbs",
1097
+ { allowSingleLine: true }
1098
+ ],
1099
+ // require camel case names
1100
+ // https://eslint.org/docs/rules/camelcase
1101
+ camelcase: "error",
1102
+ // enforce or disallow capitalization of the first letter of a comment
1103
+ // https://eslint.org/docs/rules/capitalized-comments
1104
+ "capitalized-comments": [
1105
+ "off",
1106
+ "never",
1107
+ {
1108
+ line: {
1109
+ ignorePattern: ".*",
1110
+ ignoreInlineComments: true,
1111
+ ignoreConsecutiveComments: true
1112
+ },
1113
+ block: {
1114
+ ignorePattern: ".*",
1115
+ ignoreInlineComments: true,
1116
+ ignoreConsecutiveComments: true
1117
+ }
1118
+ }
1119
+ ],
1120
+ // require trailing commas in multiline object literals
1121
+ // https://eslint.style/rules/default/comma-dangle
1122
+ "@stylistic/comma-dangle": [
1123
+ "error",
1124
+ {
1125
+ arrays: "always-multiline",
1126
+ objects: "always-multiline",
1127
+ imports: "always-multiline",
1128
+ exports: "always-multiline",
1129
+ functions: "always-multiline",
1130
+ enums: "always-multiline",
1131
+ generics: "always-multiline",
1132
+ tuples: "always-multiline"
1133
+ }
1134
+ ],
1135
+ // enforce spacing before and after comma
1136
+ // https://eslint.style/rules/default/comma-spacing
1137
+ "@stylistic/comma-spacing": ["error", { before: false, after: true }],
1138
+ // enforce one true comma style
1139
+ // https://eslint.style/rules/default/comma-style
1140
+ "@stylistic/comma-style": [
1141
+ "error",
1142
+ "last",
1143
+ {
1144
+ exceptions: {
1145
+ ArrayExpression: false,
1146
+ ArrayPattern: false,
1147
+ ArrowFunctionExpression: false,
1148
+ CallExpression: false,
1149
+ FunctionDeclaration: false,
1150
+ FunctionExpression: false,
1151
+ ImportDeclaration: false,
1152
+ ObjectExpression: false,
1153
+ ObjectPattern: false,
1154
+ VariableDeclaration: false,
1155
+ NewExpression: false
1156
+ }
1157
+ }
1158
+ ],
1159
+ // disallow padding inside computed properties
1160
+ // https://eslint.style/rules/default/computed-property-spacing
1161
+ "@stylistic/computed-property-spacing": ["error", "never"],
1162
+ // enforces consistent naming when capturing the current execution context
1163
+ // https://eslint.org/docs/rules/consistent-this
1164
+ "consistent-this": "off",
1165
+ // enforce newline at the end of file, with no multiple empty lines
1166
+ // https://eslint.style/rules/default/eol-last
1167
+ "@stylistic/eol-last": ["error", "always"],
1168
+ // https://eslint.style/rules/default/function-call-argument-newline
1169
+ "@stylistic/function-call-argument-newline": ["error", "consistent"],
1170
+ // enforce spacing between functions and their invocations
1171
+ // https://eslint.style/rules/default/func-call-spacing
1172
+ "@stylistic/func-call-spacing": ["error", "never"],
1173
+ // requires function names to match the name of the variable or property to which they are
1174
+ // assigned
1175
+ // https://eslint.org/docs/rules/func-name-matching
1176
+ "func-name-matching": [
1177
+ "off",
1178
+ "always",
1179
+ {
1180
+ includeCommonJSModuleExports: false,
1181
+ considerPropertyDescriptor: true
1182
+ }
1183
+ ],
1184
+ // require function expressions to have a name
1185
+ // https://eslint.org/docs/rules/func-names
1186
+ "func-names": "error",
1187
+ // enforces use of function declarations or expressions
1188
+ // https://eslint.org/docs/rules/func-style
1189
+ "func-style": ["error", "expression"],
1190
+ // require line breaks inside function parentheses
1191
+ // if there are line breaks between parameters
1192
+ // https://eslint.style/rules/default/function-paren-newline
1193
+ "@stylistic/function-paren-newline": ["error", "multiline-arguments"],
1194
+ // disallow specified identifiers
1195
+ // https://eslint.org/docs/rules/id-denylist
1196
+ "id-denylist": "off",
1197
+ // this option enforces minimum and maximum identifier lengths
1198
+ // (variable names, property names etc.)
1199
+ // https://eslint.org/docs/rules/id-length
1200
+ "id-length": "off",
1201
+ // require identifiers to match the provided regular expression
1202
+ // https://eslint.org/docs/rules/id-match
1203
+ "id-match": "off",
1204
+ // Enforce the location of arrow function bodies with implicit returns
1205
+ // https://eslint.style/rules/default/implicit-arrow-linebreak
1206
+ "@stylistic/implicit-arrow-linebreak": ["error", "beside"],
1207
+ // this option sets a specific tab width for your code
1208
+ // https://eslint.style/rules/default/indent
1209
+ "@stylistic/indent": [
1210
+ "error",
1211
+ 4,
1212
+ {
1213
+ SwitchCase: 1,
1214
+ VariableDeclarator: 1,
1215
+ outerIIFEBody: 1,
1216
+ // MemberExpression: null,
1217
+ FunctionDeclaration: {
1218
+ parameters: 1,
1219
+ body: 1
1220
+ },
1221
+ FunctionExpression: {
1222
+ parameters: 1,
1223
+ body: 1
1224
+ },
1225
+ CallExpression: {
1226
+ arguments: 1
1227
+ },
1228
+ ArrayExpression: 1,
1229
+ ObjectExpression: 1,
1230
+ ImportDeclaration: 1,
1231
+ flatTernaryExpressions: false,
1232
+ ignoreComments: false
1233
+ }
1234
+ ],
1235
+ // specify whether double or single quotes should be used in JSX attributes
1236
+ // https://eslint.style/rules/default/jsx-quotes
1237
+ "@stylistic/jsx-quotes": ["off", "prefer-double"],
1238
+ // enforces spacing between keys and values in object literal properties
1239
+ // https://eslint.style/rules/default/key-spacing
1240
+ "@stylistic/key-spacing": ["error", { beforeColon: false, afterColon: true }],
1241
+ // require a space before & after certain keywords
1242
+ // https://eslint.style/rules/default/keyword-spacing
1243
+ "@stylistic/keyword-spacing": [
1244
+ "error",
1245
+ {
1246
+ before: true,
1247
+ after: true,
1248
+ overrides: {
1249
+ return: { after: true },
1250
+ throw: { after: true },
1251
+ case: { after: true }
1252
+ }
1253
+ }
1254
+ ],
1255
+ // enforce position of line comments
1256
+ // https://eslint.style/rules/default/line-comment-position
1257
+ "@stylistic/line-comment-position": [
1258
+ "off",
1259
+ {
1260
+ position: "above",
1261
+ ignorePattern: "",
1262
+ applyDefaultIgnorePatterns: true
1263
+ }
1264
+ ],
1265
+ // disallow mixed 'LF' and 'CRLF' as linebreaks
1266
+ // https://eslint.style/rules/default/linebreak-style
1267
+ "@stylistic/linebreak-style": ["error", "unix"],
1268
+ // require or disallow an empty line between class members
1269
+ // https://eslint.style/rules/default/lines-between-class-members
1270
+ "@stylistic/lines-between-class-members": [
1271
+ "error",
1272
+ "always",
1273
+ { exceptAfterSingleLine: false }
1274
+ ],
1275
+ // enforces empty lines around comments
1276
+ // https://eslint.style/rules/default/lines-around-comment
1277
+ "@stylistic/lines-around-comment": "off",
1278
+ // Require or disallow logical assignment logical operator shorthand
1279
+ // https://eslint.org/docs/rules/logical-assignment-operators
1280
+ "logical-assignment-operators": [
1281
+ "error",
1282
+ "always",
1283
+ {
1284
+ enforceForIfStatements: true
1285
+ }
1286
+ ],
1287
+ // specify the maximum depth that blocks can be nested
1288
+ // https://eslint.org/docs/rules/max-depth
1289
+ "max-depth": ["off", 4],
1290
+ // specify the maximum length of a line in your program
1291
+ // https://eslint.style/rules/default/max-len
1292
+ "@stylistic/max-len": [
1293
+ "error",
1294
+ 100,
1295
+ 4,
1296
+ {
1297
+ ignoreUrls: true,
1298
+ ignoreComments: false,
1299
+ ignoreRegExpLiterals: true,
1300
+ ignoreStrings: true,
1301
+ ignoreTemplateLiterals: true
1302
+ }
1303
+ ],
1304
+ // specify the max number of lines in a file
1305
+ // https://eslint.org/docs/rules/max-lines
1306
+ "max-lines": [
1307
+ "off",
1308
+ {
1309
+ max: 300,
1310
+ skipBlankLines: true,
1311
+ skipComments: true
1312
+ }
1313
+ ],
1314
+ // enforce a maximum function length
1315
+ // https://eslint.org/docs/rules/max-lines-per-function
1316
+ "max-lines-per-function": [
1317
+ "off",
1318
+ {
1319
+ max: 50,
1320
+ skipBlankLines: true,
1321
+ skipComments: true,
1322
+ IIFEs: true
1323
+ }
1324
+ ],
1325
+ // specify the maximum depth callbacks can be nested
1326
+ // https://eslint.org/docs/rules/max-nested-callbacks
1327
+ "max-nested-callbacks": "off",
1328
+ // limits the number of parameters that can be used in the function declaration.
1329
+ // https://eslint.org/docs/rules/max-params
1330
+ "max-params": ["off", 3],
1331
+ // specify the maximum number of statement allowed in a function
1332
+ // https://eslint.org/docs/rules/max-statements
1333
+ "max-statements": ["off", 10],
1334
+ // restrict the number of statements per line
1335
+ // https://eslint.style/rules/default/max-statements-per-line
1336
+ "@stylistic/max-statements-per-line": ["off", { max: 1 }],
1337
+ // enforce a particular style for multiline comments
1338
+ // https://eslint.style/rules/default/multiline-comment-style
1339
+ "@stylistic/multiline-comment-style": ["off", "starred-block"],
1340
+ // require multiline ternary
1341
+ // https://eslint.style/rules/default/multiline-ternary
1342
+ "@stylistic/multiline-ternary": ["error", "never"],
1343
+ // require a capital letter for constructors
1344
+ // https://eslint.org/docs/rules/new-cap
1345
+ "new-cap": [
1346
+ "error",
1347
+ {
1348
+ newIsCap: true,
1349
+ newIsCapExceptions: [],
1350
+ capIsNew: false,
1351
+ capIsNewExceptions: [
1352
+ "Immutable.Map",
1353
+ "Immutable.Set",
1354
+ "Immutable.List"
1355
+ ]
1356
+ }
1357
+ ],
1358
+ // disallow the omission of parentheses when invoking a constructor with no arguments
1359
+ // https://eslint.style/rules/default/new-parens
1360
+ "@stylistic/new-parens": "error",
1361
+ // enforces new line after each method call in the chain to make it
1362
+ // more readable and easy to maintain
1363
+ // https://eslint.style/rules/default/newline-per-chained-call
1364
+ "@stylistic/newline-per-chained-call": ["error", { ignoreChainWithDepth: 4 }],
1365
+ // disallow use of the Array constructor
1366
+ // https://eslint.org/docs/rules/no-array-constructor
1367
+ "no-array-constructor": "error",
1368
+ // disallow use of bitwise operators
1369
+ // https://eslint.org/docs/rules/no-bitwise
1370
+ "no-bitwise": "error",
1371
+ // disallow use of the continue statement
1372
+ // https://eslint.org/docs/rules/no-continue
1373
+ "no-continue": "error",
1374
+ // disallow comments inline after code
1375
+ // https://eslint.org/docs/rules/no-inline-comments
1376
+ "no-inline-comments": "off",
1377
+ // disallow if as the only statement in an else block
1378
+ // https://eslint.org/docs/rules/no-lonely-if
1379
+ "no-lonely-if": "error",
1380
+ // disallow un-paren'd mixes of different operators
1381
+ // httphttps://eslint.style/rules/default/no-mixed-operators
1382
+ "@stylistic/no-mixed-operators": [
1383
+ "error",
1384
+ {
1385
+ // the list of arithmetic groups disallows mixing `%` and `**`
1386
+ // with other arithmetic operators.
1387
+ groups: [
1388
+ ["%", "**"],
1389
+ ["%", "+"],
1390
+ ["%", "-"],
1391
+ ["%", "*"],
1392
+ ["%", "/"],
1393
+ ["/", "*"],
1394
+ [
1395
+ "&",
1396
+ "|",
1397
+ "<<",
1398
+ ">>",
1399
+ ">>>"
1400
+ ],
1401
+ [
1402
+ "==",
1403
+ "!=",
1404
+ "===",
1405
+ "!=="
1406
+ ],
1407
+ ["&&", "||"]
1408
+ ],
1409
+ allowSamePrecedence: false
1410
+ }
1411
+ ],
1412
+ // disallow mixed spaces and tabs for indentation
1413
+ // https://eslint.style/rules/default/no-mixed-spaces-and-tabs
1414
+ "@stylistic/no-mixed-spaces-and-tabs": "error",
1415
+ // disallow use of chained assignment expressions
1416
+ // https://eslint.org/docs/rules/no-multi-assign
1417
+ "no-multi-assign": ["error"],
1418
+ // disallow multiple empty lines
1419
+ // only one newline at the end
1420
+ // and no new lines at the beginning
1421
+ // https://eslint.style/rules/default/no-multiple-empty-lines
1422
+ "@stylistic/no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }],
1423
+ // disallow negated conditions
1424
+ // https://eslint.org/docs/rules/no-negated-condition
1425
+ "no-negated-condition": "off",
1426
+ // disallow nested ternary expressions
1427
+ // https://eslint.org/docs/rules/no-nested-ternary
1428
+ "no-nested-ternary": "error",
1429
+ // disallow calls to the Object constructor without an argument
1430
+ // https://eslint.org/docs/rules/no-object-constructor
1431
+ "no-object-constructor": "error",
1432
+ // disallow use of unary operators, ++ and --
1433
+ // https://eslint.org/docs/rules/no-plusplus
1434
+ "no-plusplus": "error",
1435
+ // disallow certain syntax forms
1436
+ // https://eslint.org/docs/rules/no-restricted-syntax
1437
+ "no-restricted-syntax": [
1438
+ "error",
1439
+ {
1440
+ selector: "ForInStatement",
1441
+ message: "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."
1442
+ },
1443
+ // {
1444
+ // selector: 'ForOfStatement',
1445
+ // message:
1446
+ // 'iterators/generators require regenerator-runtime,
1447
+ // which is too heavyweight for this guide to allow them.
1448
+ // Separately, loops should be avoided in favor of array iterations.',
1449
+ // },
1450
+ {
1451
+ selector: "LabeledStatement",
1452
+ message: "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand."
1453
+ },
1454
+ {
1455
+ selector: "WithStatement",
1456
+ message: "`with` is disallowed in strict mode because it makes code impossible to predict and optimize."
1457
+ }
1458
+ ],
1459
+ // disallow tab characters entirely
1460
+ // https://eslint.style/rules/default/no-tabs
1461
+ "@stylistic/no-tabs": "error",
1462
+ // disallow the use of ternary operators
1463
+ // https://eslint.org/docs/rules/no-ternary
1464
+ "no-ternary": "off",
1465
+ // disallow trailing whitespace at the end of lines
1466
+ // https://eslint.style/rules/default/no-trailing-spaces
1467
+ "@stylistic/no-trailing-spaces": [
1468
+ "error",
1469
+ {
1470
+ skipBlankLines: false,
1471
+ ignoreComments: false
1472
+ }
1473
+ ],
1474
+ // disallow dangling underscores in identifiers
1475
+ // https://eslint.org/docs/rules/no-underscore-dangle
1476
+ "no-underscore-dangle": [
1477
+ "error",
1478
+ {
1479
+ allow: [],
1480
+ allowAfterThis: false,
1481
+ allowAfterSuper: false,
1482
+ enforceInMethodNames: true
1483
+ }
1484
+ ],
1485
+ // disallow the use of Boolean literals in conditional expressions
1486
+ // also, prefer `a || b` over `a ? a : b`
1487
+ // https://eslint.org/docs/rules/no-unneeded-ternary
1488
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
1489
+ // disallow whitespace before properties
1490
+ // https://eslint.style/rules/default/no-whitespace-before-property
1491
+ "@stylistic/no-whitespace-before-property": "error",
1492
+ // enforce the location of single-line statements
1493
+ // https://eslint.style/rules/default/nonblock-statement-body-position
1494
+ "@stylistic/nonblock-statement-body-position": [
1495
+ "error",
1496
+ "beside",
1497
+ { overrides: {} }
1498
+ ],
1499
+ // require padding inside curly braces
1500
+ // https://eslint.style/rules/default/object-curly-spacing
1501
+ "@stylistic/object-curly-spacing": ["error", "always"],
1502
+ // enforce line breaks between braces
1503
+ // https://eslint.style/rules/default/object-curly-newline
1504
+ "@stylistic/object-curly-newline": [
1505
+ "error",
1506
+ {
1507
+ ObjectExpression: {
1508
+ minProperties: 4,
1509
+ multiline: true,
1510
+ consistent: true
1511
+ },
1512
+ ObjectPattern: {
1513
+ minProperties: 4,
1514
+ multiline: true,
1515
+ consistent: true
1516
+ },
1517
+ ImportDeclaration: {
1518
+ minProperties: 4,
1519
+ multiline: true,
1520
+ consistent: true
1521
+ },
1522
+ ExportDeclaration: {
1523
+ minProperties: 4,
1524
+ multiline: true,
1525
+ consistent: true
1526
+ }
1527
+ }
1528
+ ],
1529
+ // enforce "same line" or "multiple line" on object properties.
1530
+ // https://eslint.style/rules/default/object-property-newline
1531
+ "@stylistic/object-property-newline": [
1532
+ "error",
1533
+ {
1534
+ allowAllPropertiesOnSameLine: true
1535
+ }
1536
+ ],
1537
+ // allow just one var statement per function
1538
+ // https://eslint.org/docs/rules/one-var
1539
+ "one-var": ["error", "never"],
1540
+ // require a newline around variable declaration
1541
+ // https://eslint.style/rules/default/one-var-declaration-per-line
1542
+ "@stylistic/one-var-declaration-per-line": ["error", "always"],
1543
+ // require assignment operator shorthand where possible or prohibit it entirely
1544
+ // https://eslint.org/docs/rules/operator-assignment
1545
+ "operator-assignment": ["error", "always"],
1546
+ // Requires operator at the beginning of the line in multiline statements
1547
+ // https://eslint.style/rules/default/operator-linebreak
1548
+ "@stylistic/operator-linebreak": [
1549
+ "error",
1550
+ "before",
1551
+ { overrides: { "=": "none" } }
1552
+ ],
1553
+ // disallow padding within blocks
1554
+ // https://eslint.style/rules/default/padded-blocks
1555
+ "@stylistic/padded-blocks": [
1556
+ "error",
1557
+ {
1558
+ blocks: "never",
1559
+ classes: "never",
1560
+ switches: "never"
1561
+ },
1562
+ {
1563
+ allowSingleLineBlocks: true
1564
+ }
1565
+ ],
1566
+ // Require or disallow padding lines between statements
1567
+ // https://eslint.style/rules/default/padding-line-between-statements
1568
+ "@stylistic/padding-line-between-statements": "off",
1569
+ // Disallow the use of Math.pow in favor of the ** operator
1570
+ // https://eslint.org/docs/rules/prefer-exponentiation-operator
1571
+ "prefer-exponentiation-operator": "error",
1572
+ // Prefer use of an object spread over Object.assign
1573
+ // https://eslint.org/docs/rules/prefer-object-spread
1574
+ "prefer-object-spread": "error",
1575
+ // require quotes around object literal property names
1576
+ // https://eslint.style/rules/default/quote-props
1577
+ "@stylistic/quote-props": [
1578
+ "error",
1579
+ "as-needed",
1580
+ { keywords: false, unnecessary: true, numbers: false }
1581
+ ],
1582
+ // specify whether double or single quotes should be used
1583
+ // https://eslint.style/rules/default/quotes
1584
+ "@stylistic/quotes": [
1585
+ "error",
1586
+ "single",
1587
+ { avoidEscape: true }
1588
+ ],
1589
+ // require or disallow use of semicolons instead of ASI
1590
+ // https://eslint.style/rules/default/semi
1591
+ "@stylistic/semi": ["error", "always"],
1592
+ // enforce spacing before and after semicolons
1593
+ // https://eslint.style/rules/default/semi-spacing
1594
+ "@stylistic/semi-spacing": ["error", { before: false, after: true }],
1595
+ // Enforce location of semicolons
1596
+ // https://eslint.style/rules/default/semi-style
1597
+ "@stylistic/semi-style": ["error", "last"],
1598
+ // requires object keys to be sorted
1599
+ // https://eslint.org/docs/rules/sort-keys
1600
+ "sort-keys": [
1601
+ "off",
1602
+ "asc",
1603
+ { caseSensitive: false, natural: true }
1604
+ ],
1605
+ // sort variables within the same declaration block
1606
+ // https://eslint.org/docs/rules/sort-vars
1607
+ "sort-vars": "off",
1608
+ // require or disallow space before blocks
1609
+ // https://eslint.style/rules/default/space-before-blocks
1610
+ "@stylistic/space-before-blocks": "error",
1611
+ // require or disallow space before function opening parenthesis
1612
+ // https://eslint.style/rules/default/space-before-function-paren
1613
+ "@stylistic/space-before-function-paren": [
1614
+ "error",
1615
+ {
1616
+ anonymous: "always",
1617
+ named: "never",
1618
+ asyncArrow: "always"
1619
+ }
1620
+ ],
1621
+ // require or disallow spaces inside parentheses
1622
+ // https://eslint.style/rules/default/space-in-parens
1623
+ "@stylistic/space-in-parens": ["error", "never"],
1624
+ // require spaces around operators
1625
+ // https://eslint.style/rules/default/space-infix-ops
1626
+ "@stylistic/space-infix-ops": "error",
1627
+ // Require or disallow spaces before/after unary operators
1628
+ // https://eslint.style/rules/default/space-unary-ops
1629
+ "@stylistic/space-unary-ops": [
1630
+ "error",
1631
+ {
1632
+ words: true,
1633
+ nonwords: false,
1634
+ overrides: {}
1635
+ }
1636
+ ],
1637
+ // require or disallow a space immediately following the // or /* in a comment
1638
+ // https://eslint.style/rules/default/spaced-comment
1639
+ "@stylistic/spaced-comment": [
1640
+ "error",
1641
+ "always",
1642
+ {
1643
+ line: {
1644
+ exceptions: ["-", "+"],
1645
+ markers: [
1646
+ "=",
1647
+ "!",
1648
+ "/"
1649
+ ]
1650
+ // space here to support sprockets directives, slash for TS /// comments
1651
+ },
1652
+ block: {
1653
+ exceptions: ["-", "+"],
1654
+ markers: [
1655
+ "=",
1656
+ "!",
1657
+ ":",
1658
+ "::"
1659
+ ],
1660
+ // space here to support sprockets directives and flow comment types
1661
+ balanced: true
1662
+ }
1663
+ }
1664
+ ],
1665
+ // Enforce spacing around colons of switch statements
1666
+ // https://eslint.style/rules/default/switch-colon-spacing
1667
+ "@stylistic/switch-colon-spacing": ["error", { after: true, before: false }],
1668
+ // Require or disallow spacing between template tags and their literals
1669
+ // https://eslint.style/rules/default/template-tag-spacing
1670
+ "@stylistic/template-tag-spacing": ["error", "never"],
1671
+ // require or disallow the Unicode Byte Order Mark
1672
+ // https://eslint.org/docs/rules/unicode-bom
1673
+ "unicode-bom": ["error", "never"],
1674
+ // require regex literals to be wrapped in parentheses
1675
+ // https://eslint.style/rules/default/wrap-regex
1676
+ "@stylistic/wrap-regex": "off"
1677
+ }
1678
+ };
1679
+
1680
+ const variables = {
1681
+ name: "@rhyster/eslint-config/airbnb/variables",
1682
+ rules: {
1683
+ // enforce or disallow variable initializations at definition
1684
+ // https://eslint.org/docs/rules/init-declarations
1685
+ "init-declarations": "off",
1686
+ // disallow deletion of variables
1687
+ // https://eslint.org/docs/rules/no-delete-var
1688
+ "no-delete-var": "error",
1689
+ // disallow labels that share a name with a variable
1690
+ // https://eslint.org/docs/rules/no-label-var
1691
+ "no-label-var": "error",
1692
+ // disallow specific globals
1693
+ // https://eslint.org/docs/rules/no-restricted-globals
1694
+ "no-restricted-globals": [
1695
+ "error",
1696
+ {
1697
+ name: "isFinite",
1698
+ message: "Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite"
1699
+ },
1700
+ {
1701
+ name: "isNaN",
1702
+ message: "Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan"
1703
+ },
1704
+ ...confusingBrowserGlobals.map((g) => ({
1705
+ name: g,
1706
+ message: `Use window.${g} instead. https://github.com/facebook/create-react-app/blob/HEAD/packages/confusing-browser-globals/README.md`
1707
+ }))
1708
+ ],
1709
+ // disallow declaration of variables already declared in the outer scope
1710
+ // https://eslint.org/docs/rules/no-shadow
1711
+ "no-shadow": "error",
1712
+ // disallow shadowing of names such as arguments
1713
+ // https://eslint.org/docs/rules/no-shadow-restricted-names
1714
+ "no-shadow-restricted-names": "error",
1715
+ // disallow use of undeclared variables unless mentioned in a /*global */ block
1716
+ // https://eslint.org/docs/rules/no-undef
1717
+ "no-undef": "error",
1718
+ // disallow use of undefined when initializing variables
1719
+ // https://eslint.org/docs/rules/no-undef-init
1720
+ "no-undef-init": "error",
1721
+ // disallow use of undefined variable
1722
+ // https://eslint.org/docs/rules/no-undefined
1723
+ "no-undefined": "off",
1724
+ // disallow declaration of variables that are not used in the code
1725
+ // https://eslint.org/docs/rules/no-unused-vars
1726
+ "no-unused-vars": [
1727
+ "error",
1728
+ { vars: "all", args: "after-used", ignoreRestSiblings: true }
1729
+ ],
1730
+ // disallow use of variables before they are defined
1731
+ // https://eslint.org/docs/rules/no-use-before-define
1732
+ "no-use-before-define": [
1733
+ "error",
1734
+ { functions: true, classes: true, variables: true }
1735
+ ]
1736
+ }
1737
+ };
1738
+
1739
+ const typescript = {
1740
+ name: "@rhyster/eslint-config/typescript",
1741
+ rules: {
1742
+ // https://typescript-eslint.io/rules/naming-convention
1743
+ "@typescript-eslint/naming-convention": "error",
1744
+ camelcase: "off",
1745
+ // https://typescript-eslint.io/rules/default-param-last
1746
+ "@typescript-eslint/default-param-last": "error",
1747
+ "default-param-last": "off",
1748
+ // https://typescript-eslint.io/rules/dot-notation
1749
+ "@typescript-eslint/dot-notation": "error",
1750
+ "dot-notation": "off",
1751
+ // https://typescript-eslint.io/rules/no-array-constructor
1752
+ "@typescript-eslint/no-array-constructor": "error",
1753
+ "no-array-constructor": "off",
1754
+ // https://typescript-eslint.io/rules/no-empty-function
1755
+ "@typescript-eslint/no-empty-function": "error",
1756
+ "no-empty-function": "off",
1757
+ // https://typescript-eslint.io/rules/no-implied-eval
1758
+ "@typescript-eslint/no-implied-eval": "error",
1759
+ "no-implied-eval": "off",
1760
+ "no-new-func": "off",
1761
+ // https://typescript-eslint.io/rules/no-loop-func
1762
+ "@typescript-eslint/no-loop-func": "error",
1763
+ "no-loop-func": "off",
1764
+ // https://typescript-eslint.io/rules/no-magic-numbers
1765
+ "@typescript-eslint/no-magic-numbers": "off",
1766
+ "no-magic-numbers": "off",
1767
+ // https://typescript-eslint.io/rules/no-shadow
1768
+ "@typescript-eslint/no-shadow": "error",
1769
+ "no-shadow": "off",
1770
+ // https://typescript-eslint.io/rules/only-throw-error
1771
+ "@typescript-eslint/only-throw-error": "error",
1772
+ "no-throw-literal": "off",
1773
+ // https://typescript-eslint.io/rules/no-unused-expressions
1774
+ "@typescript-eslint/no-unused-expressions": "error",
1775
+ "no-unused-expressions": "off",
1776
+ // https://typescript-eslint.io/rules/no-unused-vars
1777
+ "@typescript-eslint/no-unused-vars": "error",
1778
+ "no-unused-vars": "off",
1779
+ // https://typescript-eslint.io/rules/no-use-before-define
1780
+ "@typescript-eslint/no-use-before-define": "error",
1781
+ "no-use-before-define": "off",
1782
+ // https://typescript-eslint.io/rules/no-useless-constructor
1783
+ "@typescript-eslint/no-useless-constructor": "error",
1784
+ "no-useless-constructor": "off",
1785
+ // https://typescript-eslint.io/rules/prefer-promise-reject-errors
1786
+ "@typescript-eslint/prefer-promise-reject-errors": "error",
1787
+ "prefer-promise-reject-errors": "off",
1788
+ // https://typescript-eslint.io/rules/require-await
1789
+ "@typescript-eslint/require-await": "off",
1790
+ "require-await": "off",
1791
+ // https://typescript-eslint.io/rules/return-await
1792
+ "@typescript-eslint/return-await": ["error", "in-try-catch"],
1793
+ "no-return-await": "off",
1794
+ // https://typescript-eslint.io/rules/no-dupe-class-members
1795
+ // checked by the TypeScript compiler
1796
+ "no-dupe-class-members": "off",
1797
+ // https://typescript-eslint.io/rules/no-redeclare
1798
+ // checked by the TypeScript compiler
1799
+ "no-redeclare": "off",
1800
+ // https://typescript-eslint.io/troubleshooting/typed-linting/performance/#eslint-plugin-import
1801
+ "import-x/named": "off",
1802
+ "import-x/namespace": "off",
1803
+ "import-x/default": "off",
1804
+ "import-x/no-named-as-default-member": "off",
1805
+ "import-x/no-unresolved": "off"
1806
+ }
1807
+ };
1808
+
1809
+ const general = {
1810
+ name: "@rhyster/eslint-config/airbnb/general",
1811
+ plugins: {
1812
+ "@typescript-eslint": tseslint.plugin,
1813
+ "@stylistic": stylistic,
1814
+ "import-x": importx
1815
+ },
1816
+ languageOptions: {
1817
+ parser: tseslint.parser,
1818
+ parserOptions: {
1819
+ projectService: true
1820
+ }
1821
+ },
1822
+ settings: {
1823
+ "import-x/parsers": {
1824
+ espree: [
1825
+ ".js",
1826
+ ".mjs"
1827
+ ],
1828
+ "@typescript-eslint/parser": [
1829
+ ".ts",
1830
+ ".d.ts"
1831
+ ]
1832
+ },
1833
+ "import-x/resolver": {
1834
+ node: {
1835
+ extensions: [
1836
+ ".mjs",
1837
+ ".js",
1838
+ ".json",
1839
+ ".ts",
1840
+ ".d.ts"
1841
+ ]
1842
+ }
1843
+ },
1844
+ "import-x/extensions": [
1845
+ ".js",
1846
+ ".mjs",
1847
+ ".ts",
1848
+ ".d.ts"
1849
+ ],
1850
+ "import-x/core-modules": [],
1851
+ "import-x/ignore": [
1852
+ "node_modules",
1853
+ "\\.(coffee|scss|css|less|hbs|svg|json)$"
1854
+ ],
1855
+ "import-x/external-module-folders": [
1856
+ "node_modules",
1857
+ "node_modules/@types"
1858
+ ]
1859
+ }
1860
+ };
1861
+ const core = [
1862
+ {
1863
+ name: "@rhyster/eslint-config/files-ts",
1864
+ files: ["**/*.ts"]
1865
+ },
1866
+ general,
1867
+ bestPractices,
1868
+ errors,
1869
+ style,
1870
+ variables,
1871
+ es6,
1872
+ imports,
1873
+ strict,
1874
+ typescript
1875
+ ];
1876
+ const node = [
1877
+ ...core,
1878
+ {
1879
+ languageOptions: {
1880
+ globals: globals.node
1881
+ },
1882
+ plugins: {
1883
+ n: nodePlugin
1884
+ },
1885
+ ...nodeRules
1886
+ }
1887
+ ];
1888
+ const browser = [
1889
+ ...core,
1890
+ {
1891
+ languageOptions: {
1892
+ globals: globals.browser
1893
+ }
1894
+ }
1895
+ ];
1896
+
1897
+ export { browser, core, node };
1898
+ //# sourceMappingURL=index.mjs.map