-
Notifications
You must be signed in to change notification settings - Fork 9
/
.eslintrc.json
802 lines (802 loc) · 24.7 KB
/
.eslintrc.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
{
"env": {
"node": true,
"es6": true
},
"ignorePatterns": [
"dist",
"node_modules"
],
"globals": {
"main": false
},
"parserOptions": {
"ecmaVersion": "latest"
},
"plugins": [
"jsdoc",
"node",
"promise"
],
"root": true,
"rules": {
// There is not always a need for setters.
"accessor-pairs": "off",
"array-bracket-newline": [
"error",
"consistent"
],
"array-bracket-spacing": "error",
"array-callback-return": "error",
"array-element-newline": [
"error",
"consistent"
],
"arrow-body-style": [
"error",
"never"
],
"arrow-parens": [
"error",
"as-needed"
],
"arrow-spacing": [
"error",
{
"before": true,
"after": true
}
],
"block-scoped-var": "error",
"block-spacing": [
"error",
"always"
],
"brace-style": [
"error",
"1tbs"
],
"camelcase": "error",
// It does not work well for my use cases.
"capitalized-comments": "off",
"class-methods-use-this": "off",
"comma-dangle": [
"error",
"never"
],
"comma-spacing": [
"error",
{
"before": false,
"after": true
}
],
"comma-style": [
"error",
"last"
],
// This can be adjusted as needed.
"complexity": [
"error",
25
],
"computed-property-spacing": [
"error",
"never"
],
// Looks like this prevents me from returning different types from a function.
"consistent-return": "off",
"consistent-this": "error",
"constructor-super": "error",
"curly": "error",
"default-case": "error",
"default-case-last": "error",
"default-param-last": "error",
"dot-location": [
"error",
"property"
],
"dot-notation": "error",
"eol-last": [
"error",
"always"
],
"eqeqeq": "error",
"for-direction": "error",
"func-call-spacing": [
"error",
"never"
],
"func-name-matching": "error",
"func-names": [
"error",
"never"
],
// Both can be useful sometimes.
"func-style": "off",
"function-call-argument-newline": [
"error",
"consistent"
],
"function-paren-newline": [
"error",
"consistent"
],
"generator-star-spacing": [
"error",
{
"before": false,
"after": true,
"anonymous": {
"before": false,
"after": false
},
"method": {
"before": true,
"after": false
}
}
],
"getter-return": "error",
"grouped-accessor-pairs": "error",
// Sometimes I know I am iterating over a plain object.
"guard-for-in": "off",
// I do not have any particularly bad identifies.
"id-denylist": "off",
// Identifiers can be as long as I want.
"id-length": "off",
// My identifiers don't conform to any pattern.
"id-match": "off",
"implicit-arrow-linebreak": [
"error",
"beside"
],
// There were too many false positives.
"indent": "off",
"init-declarations": "error",
"jsx-quotes": [
"error",
"prefer-double"
],
"key-spacing": [
"error",
{
"beforeColon": false,
"afterColon": true,
"mode": "strict"
}
],
"keyword-spacing": [
"error",
{
"before": true,
"after": true
}
],
"line-comment-position": [
"error",
"above"
],
"linebreak-style": [
"error",
"unix"
],
// Spacing *around* comments is not required.
"lines-around-comment": "off",
"lines-between-class-members": [
"error",
"never"
],
"max-classes-per-file": [
"error",
1
],
"max-depth": [
"error",
4
],
"max-len": [
"error",
{
// This can be adjusted as needed.
"code": 80,
"ignoreTemplateLiterals": true,
"ignoreRegExpLiterals": true
}
],
"max-lines": [
"error",
1000
],
"max-lines-per-function": [
"error",
100
],
"max-nested-callbacks": [
"error",
3
],
"max-params": [
"error",
5
],
"max-statements": [
"error",
30
],
"max-statements-per-line": [
"error",
{
"max": 1
}
],
"multiline-comment-style": [
"error",
"starred-block"
],
// Sometimes it's better with, and sometimes it's better without newlines.
"multiline-ternary": "off",
// False positives: express.Router, TypeScript annotations
"new-cap": "error",
"new-parens": [
"error",
"always"
],
"newline-per-chained-call": [
"error",
{
"ignoreChainWithDepth": 4
}
],
"no-alert": "error",
"no-array-constructor": "error",
"no-async-promise-executor": "error",
// Awaiting tasks in a loop is one of await's big advantages.
"no-await-in-loop": "off",
// Why wouldn't I want to use bitwise operations?
"no-bitwise": "off",
"no-caller": "error",
"no-case-declarations": "error",
"no-class-assign": "error",
"no-compare-neg-zero": "error",
"no-cond-assign": "error",
"no-confusing-arrow": "error",
"no-console": [
"error",
{
"allow": [
"assert",
"clear",
"count",
"countReset",
"debug",
"dir",
"dirxml",
"error",
"group",
"groupCollapsed",
"groupEnd",
"info",
"table",
"time",
"timeEnd",
"timeLog",
"trace",
"warn"
]
}
],
"no-const-assign": "error",
"no-constant-condition": "error",
"no-constructor-return": "error",
// When used correctly, `continue` can make things clearer.
"no-continue": "off",
"no-control-regex": "off",
"no-debugger": "error",
"no-delete-var": "error",
"no-div-regex": "error",
"no-dupe-args": "error",
"no-dupe-class-members": "error",
"no-dupe-else-if": "error",
"no-dupe-keys": "error",
"no-duplicate-case": "error",
"no-duplicate-imports": "error",
"no-else-return": "error",
"no-empty": "error",
"no-empty-character-class": "error",
"no-empty-function": "error",
"no-empty-pattern": "error",
"no-eq-null": "error",
"no-eval": "error",
"no-ex-assign": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-boolean-cast": "error",
"no-extra-label": "error",
"no-extra-parens": [
"error",
"all",
{
"enforceForArrowConditionals": false
}
],
"no-extra-semi": "error",
"no-fallthrough": "error",
"no-floating-decimal": "error",
"no-func-assign": "error",
"no-global-assign": "error",
"no-implicit-coercion": "error",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-import-assign": "error",
"no-inline-comments": "error",
"no-inner-declarations": "error",
"no-invalid-regexp": "error",
"no-invalid-this": "error",
"no-irregular-whitespace": "error",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-lonely-if": "error",
"no-loop-func": "error",
"no-loss-of-precision": "error",
// Some numbers are pretty clear when used.
"no-magic-numbers": "off",
"no-misleading-character-class": "error",
// When surrounded by brackets, mixing operators is fine.
"no-mixed-operators": "off",
"no-mixed-spaces-and-tabs": "error",
"no-multi-assign": "error",
"no-multi-spaces": "error",
// This is fine on web.
"no-multi-str": "error",
"no-multiple-empty-lines": [
"error",
{
"max": 1,
"maxEOF": 1,
"maxBOF": 0
}
],
"no-negated-condition": "error",
// Ternaries can be ugly, but I don't need to completely disallow nesting.
"no-nested-ternary": "off",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-symbol": "error",
"no-new-wrappers": "error",
"no-nonoctal-decimal-escape": "error",
"no-obj-calls": "error",
"no-octal": "error",
"no-octal-escape": "error",
"no-param-reassign": "error",
// There is no reason to disallow ++ and --.
"no-plusplus": "off",
"no-promise-executor-return": "error",
"no-proto": "error",
"no-prototype-builtins": "error",
"no-redeclare": "error",
"no-regex-spaces": "error",
// I do not restrict any of the below.
"no-restricted-exports": "off",
"no-restricted-globals": "off",
"no-restricted-imports": "off",
"no-restricted-properties": "off",
"no-restricted-syntax": "off",
"no-return-assign": "error",
"no-return-await": "error",
"no-script-url": "error",
"no-self-assign": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-setter-return": "error",
// In TypeScript this should be replaced with @typescript-eslint/no-shadow.
"no-shadow": "error",
"no-shadow-restricted-names": "error",
"no-sparse-arrays": "error",
"no-tabs": "error",
"no-template-curly-in-string": "error",
// Ternaries can be useful.
"no-ternary": "off",
"no-this-before-super": "error",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef": "error",
"no-undef-init": "error",
// There are still a lot of cases where the `undefined` literal is needed.
"no-undefined": "off",
// I used to do this. I should probably stop, but until then, I'm disabling this.
"no-underscore-dangle": "off",
"no-unexpected-multiline": "error",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "error",
"no-unreachable": "error",
"no-unreachable-loop": "error",
"no-unsafe-finally": "error",
"no-unsafe-negation": "error",
"no-unsafe-optional-chaining": "error",
"no-unused-expressions": "error",
"no-unused-labels": "error",
"no-unused-private-class-members": "error",
// In TypeScript this should be replaced with @typescript-eslint/no-unused-vars.
"no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"caughtErrors": "all",
"caughtErrorsIgnorePattern": "^_",
"destructuredArrayIgnorePattern": "^_"
}
],
"no-use-before-define": "error",
"no-useless-call": "error",
"no-useless-catch": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-escape": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
// This is fine on web.
"no-var": "error",
"no-void": "error",
// I still warn myself in comments often.
"no-warning-comments": "off",
"no-whitespace-before-property": "error",
"no-with": "error",
"nonblock-statement-body-position": [
"error",
"beside"
],
"object-curly-newline": [
"error",
{
"consistent": true
}
],
"object-curly-spacing": [
"error",
"never"
],
"object-property-newline": "error",
"object-shorthand": "error",
"one-var": [
"error",
"never"
],
"one-var-declaration-per-line": [
"error",
"always"
],
"operator-assignment": "error",
"operator-linebreak": [
"error",
"after"
],
"padded-blocks": [
"error",
"never"
],
// I don't see any rules regarding when should newlines be inserted.
"padding-line-between-statements": "off",
// I prefer extracting the callback functions.
"prefer-arrow-callback": "off",
"prefer-const": "error",
"prefer-destructuring": [
"error",
{
"array": true,
"object": true
}
],
// This is fine on web, because it was introduced in ES2016.
"prefer-exponentiation-operator": "error",
// While this sounds like a good idea in theory, it can easily make regexes very long and even more unreadable.
"prefer-named-capture-group": "off",
"prefer-numeric-literals": "error",
"prefer-object-has-own": "error",
// This is fine on web.
"prefer-object-spread": "error",
"prefer-promise-reject-errors": "error",
"prefer-regex-literals": "error",
// This is fine on web.
"prefer-rest-params": "error",
// This is fine on web.
"prefer-spread": "error",
// This is fine on web.
"prefer-template": "error",
"quote-props": [
"error",
"consistent-as-needed"
],
"quotes": [
"error",
"single"
],
"radix": "error",
"require-atomic-updates": "error",
"require-await": "error",
// This is fine on web.
"require-unicode-regexp": "error",
"require-yield": "error",
"rest-spread-spacing": "error",
"semi": [
"error",
"always"
],
"semi-spacing": "error",
"semi-style": "error",
"sort-imports": "error",
"sort-keys": "error",
// There is no good reason to sort variables by name instead of their logical order.
"sort-vars": "off",
"space-before-blocks": [
"error",
"always"
],
"space-before-function-paren": [
"error",
{
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}
],
"space-in-parens": "error",
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": "error",
"strict": "error",
"switch-colon-spacing": "error",
"symbol-description": "error",
"template-curly-spacing": "error",
"template-tag-spacing": "error",
"unicode-bom": "error",
"use-isnan": "error",
"valid-typeof": "error",
"vars-on-top": "error",
"wrap-iife": "error",
// I do not need parenthesis around regex.
"wrap-regex": "off",
"yield-star-spacing": [
"error",
{
"before": false,
"after": true
}
],
"yoda": [
"error",
"never"
],
"jsdoc/check-access": "error",
"jsdoc/check-alignment": "error",
// Does not work on ESLint 8: https://github.com/eslint/eslint/issues/14745
"jsdoc/check-examples": [
"off",
{
"captionRequired": true,
"paddedIndent": 4,
"reportUnusedDisableDirectives": true
}
],
"jsdoc/check-indentation": "error",
"jsdoc/check-line-alignment": "error",
"jsdoc/check-param-names": [
"error",
{
"enableFixer": true
}
],
"jsdoc/check-property-names": [
"error",
{
"enableFixer": true
}
],
"jsdoc/check-syntax": "error",
"jsdoc/check-tag-names": "error",
"jsdoc/check-types": "error",
"jsdoc/check-values": "error",
"jsdoc/empty-tags": "error",
"jsdoc/implements-on-classes": "error",
// There is no particular pattern that descriptions or names should adhere to.
"jsdoc/match-description": "off",
"jsdoc/match-name": "off",
"jsdoc/multiline-blocks": [
"error",
{
"noZeroLineText": true,
"noFinalLineText": true,
"noSingleLineBlocks": true
}
],
"jsdoc/no-bad-blocks": "error",
"jsdoc/no-defaults": "error",
// I don't have any required syntax right now.
"jsdoc/no-missing-syntax": "off",
"jsdoc/no-multi-asterisks": [
"error",
{
"allowWhitespace": true
}
],
// I don't have any syntax to restrict.
"jsdoc/no-restricted-syntax": "off",
// This should be turned on for TypeScript.
"jsdoc/no-types": "off",
"jsdoc/no-undefined-types": "error",
"jsdoc/require-asterisk-prefix": "error",
// This throws false positives.
"jsdoc/require-description-complete-sentence": "off",
"jsdoc/require-description": "error",
// Not every function needs an example.
"jsdoc/require-example": "off",
// I don't see an option to make this accept regular descriptions without tags.
"jsdoc/require-file-overview": "off",
"jsdoc/require-hyphen-before-param-description": [
"error",
"never"
],
"jsdoc/require-jsdoc": [
"error",
{
"require": {
"ArrowFunctionExpression": false,
"ClassDeclaration": true,
"ClassExpression": false,
"FunctionDeclaration": true,
"FunctionExpression": false,
"MethodDefinition": true
}
}
],
"jsdoc/require-param-description": "error",
"jsdoc/require-param-name": "error",
// This should be turned off for TypeScript.
"jsdoc/require-param-type": "error",
"jsdoc/require-param": [
"error",
{
"checkRestProperty": true,
"checkSetters": true,
"unnamedRootBase": ["options"]
}
],
"jsdoc/require-property": "error",
"jsdoc/require-property-description": "error",
"jsdoc/require-property-name": "error",
// This can be turned off for TypeScript.
"jsdoc/require-property-type": "error",
"jsdoc/require-returns-check": "error",
"jsdoc/require-returns-description": "error",
// This can be turned off for TypeScript.
"jsdoc/require-returns-type": "error",
"jsdoc/require-returns": "error",
"jsdoc/require-throws": "error",
"jsdoc/require-yields": "error",
"jsdoc/require-yields-check": "error",
"jsdoc/sort-tags": "error",
"jsdoc/tag-lines": [
"error",
"never"
],
"jsdoc/valid-types": "error",
"node/callback-return": "error",
"node/exports-style": [
"error",
"module.exports"
],
"node/file-extension-in-import": [
"error",
"always",
{
".ts": "never"
}
],
// I sometimes want to dynamically require().
"node/global-require": "off",
"node/handle-callback-err": "error",
"node/no-callback-literal": "error",
"node/no-deprecated-api": "error",
"node/no-exports-assign": "error",
"node/no-extraneous-import": "error",
"node/no-extraneous-require": "error",
// This should be turned off for TypeScript.
"node/no-missing-import": "error",
"node/no-missing-require": "error",
"node/no-mixed-requires": "error",
"node/no-new-require": "error",
"node/no-path-concat": "error",
// Sometimes, we do want to read environment variables.
"node/no-process-env": "off",
// I know when is process.exit() acceptable and when it is not.
"node/no-process-exit": "off",
// No modules to restrict from importing or requiring.
"node/no-restricted-import": "off",
"node/no-restricted-require": "off",
"node/no-sync": "error",
"node/no-unpublished-bin": "error",
"node/no-unpublished-import": "error",
"node/no-unpublished-require": "error",
"node/no-unsupported-features/es-builtins": "error",
// This does not work: https://github.com/mysticatea/eslint-plugin-node/issues/216
"node/no-unsupported-features/es-syntax": "off",
"node/no-unsupported-features/node-builtins": "error",
"node/prefer-global/buffer": [
"error",
"never"
],
"node/prefer-global/console": [
"error",
"always"
],
"node/prefer-global/process": [
"error",
"never"
],
"node/prefer-global/text-decoder": [
"error",
"never"
],
"node/prefer-global/text-encoder": [
"error",
"never"
],
"node/prefer-global/url-search-params": [
"error",
"never"
],
"node/prefer-global/url": [
"error",
"never"
],
"node/prefer-promises/dns": "error",
"node/prefer-promises/fs": "error",
"node/process-exit-as-throw": "error",
"node/shebang": "error",
// Why would every promise need a return value?
"promise/always-return": "off",
// I think I know when is creating new Promise objects needed.
"promise/avoid-new": "off",
"promise/catch-or-return": "error",
"promise/no-callback-in-promise": "error",
// Rule is broken: https://github.com/xjamundx/eslint-plugin-promise/issues/205
"promise/no-native": "off",
"promise/no-nesting": "error",
"promise/no-new-statics": "error",
"promise/no-promise-in-callback": "error",
"promise/no-return-in-finally": "error",
"promise/no-return-wrap": "error",
"promise/param-names": "error",
"promise/prefer-await-to-callbacks": "error",
"promise/prefer-await-to-then": "error",
"promise/valid-params": "error"
},
"settings": {
"jsdoc": {
"mode": "typescript",
"tagNamePreference": {
"virtual": "abstract",
"extends": "augments",
"class": "constructor",
"const": "constant",
"defaultvalue": "default",
"desc": "description",
"host": "external",
"fileoverview": "file",
"overview": "file",
"emits": "fires",
"func": "function",
"method": "function",
"var": "member",
"prop": "property",
"return": "returns",
"exception": "throws",
"yield": "yields"
}
}
}
}