-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint-base.ts
1640 lines (1383 loc) · 56.2 KB
/
eslint-base.ts
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
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// the global list of restricted terms that airbnb uses
import globals = require('eslint-restricted-globals')
// we remove some because of how the eslint TS parser interacts with eslint when using interfaces
const pseudoAllowedGlobals = ['name', 'status', 'location', 'open', 'close', 'event']
const restrictedGlobals = globals.filter(g => pseudoAllowedGlobals.indexOf(g) === -1)
const rules: Rules.Eslint = {
// This rule warns if setters are defined without getters
// https://eslint.org/docs/rules/accessor-pairs
'accessor-pairs': [
'error',
{
setWithoutGet: true,
getWithoutSet: false,
},
],
// This rule enforces line breaks after opening and before closing array brackets.
// https://eslint.org/docs/rules/array-bracket-newline
'array-bracket-newline': [
'error',
'consistent',
],
// This rule enforces consistent spacing inside array brackets.
// https://eslint.org/docs/rules/array-bracket-spacing
'array-bracket-spacing': [
'error',
'never',
],
// This rule finds callback functions of the following methods, then checks usage of return statement
// https://eslint.org/docs/rules/array-callback-return
'array-callback-return': 'error',
// This rule enforces line breaks between array elements.
// https://eslint.org/docs/rules/array-element-newline
'array-element-newline': 'off',
// This rule can enforce or disallow the use of braces around arrow function body.
// https://eslint.org/docs/rules/arrow-body-style
'arrow-body-style': [
'error',
'as-needed',
],
// This rule enforces parentheses around arrow function parameters regardless of arity.
// https://eslint.org/docs/rules/arrow-parens
'arrow-parens': [
'error',
'as-needed',
{
requireForBlockBody: true,
},
],
// This rule takes an object argument with before and after properties, each with a Boolean value.
// https://eslint.org/docs/rules/arrow-spacing
'arrow-spacing': [
'error',
{
before: true,
after: true,
},
],
// This rule aims to reduce the usage of variables outside of their binding context and emulate
// traditional block scope from other languages.
// https://eslint.org/docs/rules/block-scoped-var
'block-scoped-var': 'error',
// This rule enforces consistent spacing inside an open block token and the next token on the same line.
// This rule also enforces consistent spacing inside a close block token and previous token on the same line.
// https://eslint.org/docs/rules/block-spacing
'block-spacing': [
'error',
'always',
],
// This rule enforces consistent brace style for blocks.
// https://eslint.org/docs/rules/brace-style
'brace-style': [
'error',
'1tbs',
],
// This rule is aimed at ensuring that callbacks used outside of the main function block are always part-of
// or immediately preceding a return statement.
// This rule decides what is a callback based on the name of the function being called.
// https://eslint.org/docs/rules/callback-return
'callback-return': 'off',
// This rule looks for any underscores (_) located within the source code.
// It ignores leading and trailing underscores and only checks those in the middle of a variable name.
// If ESLint decides that the variable is a constant (all uppercase), then no warning will be thrown.
// Otherwise, a warning will be thrown. This rule only flags definitions and assignments but not function calls.
// In case of ES6 import statements, this rule only targets the name of the variable that will be imported into the local module scope.
// https://eslint.org/docs/rules/camelcase
camelcase: 'off',
// This rule aims to enforce a consistent style of comments across your codebase.
// https://eslint.org/docs/rules/capitalized-comments
'capitalized-comments': 'off',
// This rule is aimed to flag class methods that do not use this.
// https://eslint.org/docs/rules/class-methods-use-this
'class-methods-use-this': 'off',
// This rule enforces consistent use of trailing commas in object and array literals.
// https://eslint.org/docs/rules/comma-dangle
'comma-dangle': [
'error',
{
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'always-multiline',
},
],
// This rule enforces consistent spacing before and after commas in variable declarations,
// array literals, object literals, function parameters, and sequences.
// https://eslint.org/docs/rules/comma-spacing
'comma-spacing': [
'error',
{
before: false,
after: true,
},
],
// This rule enforce consistent comma style in array literals, object literals, and variable declarations.
// https://eslint.org/docs/rules/comma-style
'comma-style': [
'error',
'last',
{
exceptions: {
ArrayExpression: false,
ArrayPattern: false,
ArrowFunctionExpression: false,
CallExpression: false,
FunctionDeclaration: false,
FunctionExpression: false,
ImportDeclaration: false,
ObjectExpression: false,
ObjectPattern: false,
VariableDeclaration: false,
NewExpression: false,
},
},
],
// This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program.
// https://eslint.org/docs/rules/complexity
complexity: [
'error',
12,
],
// This rule enforces consistent spacing inside computed property brackets.
// https://eslint.org/docs/rules/computed-property-spacing
'computed-property-spacing': [
'error',
'never',
],
// This rule requires return statements to either always or never specify values.
// https://eslint.org/docs/rules/consistent-return
'consistent-return': [
'error',
{
treatUndefinedAsUnspecified: false,
},
],
// This rule enforces two things about variables with the designated alias names for this:
// - If a variable with a designated name is declared, it must be either initialized (in the declaration) or assigned (in the same scope as the declaration) the value this.
// - If a variable is initialized or assigned the value this, the name of the variable must be a designated alias.
// https://eslint.org/docs/rules/consistent-this
'consistent-this': [
'error',
'that',
],
// This rule is aimed to flag invalid/missing super() calls.
// https://eslint.org/docs/rules/constructor-super
'constructor-super': 'error',
// This rule is aimed at preventing bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces.
// https://eslint.org/docs/rules/curly
curly: [
'error',
'all',
],
// This rule aims to require default case in switch statements.
// https://eslint.org/docs/rules/default-case
'default-case': [
'error',
{
commentPattern: '^no default$',
},
],
// enforces consistent newlines before or after dots
// https://eslint.org/docs/rules/dot-location
'dot-location': [
'error',
'property',
],
// encourages use of dot notation whenever possible
// https://eslint.org/docs/rules/dot-notation
'dot-notation': [
'error',
{
allowKeywords: true,
},
],
// enforce newline at the end of file, with no multiple empty lines
// https://eslint.org/docs/rules/eol-last
'eol-last': [
'error',
'always',
],
// require the use of === and !==
// https://eslint.org/docs/rules/eqeqeq
eqeqeq: [
'error',
'always',
{
null: 'ignore',
},
],
// Enforce “for” loop update clause moving the counter in the right direction
// https://eslint.org/docs/rules/for-direction
'for-direction': 'error',
// enforce spacing between functions and their invocations
// https://eslint.org/docs/rules/func-call-spacing
'func-call-spacing': [
'error',
'never',
],
// requires function names to match the name of the variable or property to which they are assigned
// https://eslint.org/docs/rules/func-name-matching
'func-name-matching': [
'off',
'always',
{
includeCommonJSModuleExports: false,
},
],
// require function expressions to have a name
// https://eslint.org/docs/rules/func-names
'func-names': 'warn',
// This rule enforces a particular type of function style throughout a JavaScript file, either declarations or expressions
// https://eslint.org/docs/rules/func-style
'func-style': [
'error',
'declaration',
{
allowArrowFunctions: true,
},
],
// This rule enforces consistent line breaks inside parentheses of function parameters or arguments.
// https://eslint.org/docs/rules/function-paren-newline
'function-paren-newline': [
'error',
'consistent',
],
// Enforce spacing around the * in generator functions
// https://eslint.org/docs/rules/generator-star-spacing
'generator-star-spacing': [
'error',
{
before: false,
after: true,
},
],
// This rule enforces that a return statement is present in property getters.
// https://eslint.org/docs/rules/getter-return
'getter-return': [
'error',
{
allowImplicit: false,
},
],
// This rule requires all calls to require() to be at the top level of the module, similar to ES6 import and export statements.
// https://eslint.org/docs/rules/global-require
'global-require': 'error',
// make sure for-in loops have an if statement
// https://eslint.org/docs/rules/guard-for-in
'guard-for-in': 'error',
// enforces error handling in callbacks (node environment)
// https://eslint.org/docs/rules/handle-callback-err
'handle-callback-err': 'off',
// This rule disallows specified identifiers in assignments and function definitions.
// https://eslint.org/docs/rules/id-blacklist
'id-blacklist': 'off',
// this option enforces minimum and maximum identifier lengths (variable names, property names etc.)
// https://eslint.org/docs/rules/id-length
'id-length': 'off',
// require identifiers to match the provided regular expression
// https://eslint.org/docs/rules/id-match
'id-match': 'off',
// This rule aims to enforce a consistent location for an arrow function containing an implicit return.
// https://eslint.org/docs/rules/implicit-arrow-linebreak
// In testing - this rule is again just plain annoying because it prevents you from breaking a line if it's long
'implicit-arrow-linebreak': 'off',
// This rule enforces a consistent indentation style.
// https://eslint.org/docs/rules/indent
indent: 'off',
// This rule is aimed at enforcing or eliminating variable initializations during declaration.
// https://eslint.org/docs/rules/init-declarations
'init-declarations': 'off',
// specify whether double or single quotes should be used in JSX attributes
// https://eslint.org/docs/rules/jsx-quotes
'jsx-quotes': [
'error',
'prefer-single',
],
// This rule enforces consistent spacing between keys and values in object literal properties
// https://eslint.org/docs/rules/key-spacing
'key-spacing': [
'error',
{
beforeColon: false,
afterColon: true,
},
],
// This rule enforces consistent spacing around keywords and keyword-like tokens.
// https://eslint.org/docs/rules/keyword-spacing
'keyword-spacing': [
'error',
{
before: true,
after: true,
overrides: {
return: {
after: true,
},
throw: {
after: true,
},
case: {
after: true,
},
},
},
],
// This rule enforces consistent position of line comments.
// https://eslint.org/docs/rules/line-comment-position
'line-comment-position': 'off',
// This rule enforces consistent line endings across your codebase.
// https://eslint.org/docs/rules/linebreak-style
'linebreak-style': [
'error',
'unix',
],
// enforces empty lines around comments
// https://eslint.org/docs/rules/lines-around-comment
'lines-around-comment': 'off',
// require or disallow an empty line between class members
// https://eslint.org/docs/rules/lines-between-class-members
// In testing - this rule is just plain annoying and bloats the class defs, esp if there are a number of getter/setters
'lines-between-class-members': 'off',
// This rule enforces that each file may contain only a particular number of classes and no more.
// https://eslint.org/docs/rules/max-classes-per-file
'max-classes-per-file': [
'error',
1,
],
// This rule enforces a maximum depth that blocks can be nested to reduce code complexity.
// https://eslint.org/docs/rules/max-depth
'max-depth': [
'error',
4,
],
// This rule enforces a maximum line length to increase code readability and maintainability.
// The length of a line is defined as the number of Unicode characters in the line.
// https://eslint.org/docs/rules/max-len
'max-len': [
'warn',
{
code: 120,
tabWidth: 4,
ignoreComments: true,
ignoreUrls: true,
},
],
// This rule enforces a maximum number of lines per file, in order to aid in maintainability and reduce complexity.
// https://eslint.org/docs/rules/max-lines
'max-lines': 'off',
// This rule enforces a maximum number of lines per file, in order to aid in maintainability and reduce complexity.
// https://eslint.org/docs/rules/max-lines-per-function
'max-lines-per-function': [
'off',
{
max: 50,
skipBlankLines: true,
skipComments: true,
IIFEs: true,
},
],
// his rule enforces a maximum depth that callbacks can be nested to increase code clarity.
// https://eslint.org/docs/rules/max-nested-callbacks
'max-nested-callbacks': [
'error',
5,
],
// This rule enforces a maximum number of parameters allowed in function definitions
// https://eslint.org/docs/rules/max-params
'max-params': [
'error',
5,
],
// This rule enforces a maximum number of statements allowed in function blocks
// https://eslint.org/docs/rules/max-statements
'max-statements': 'off',
// This rule enforces a maximum number of statements allowed per line.
// https://eslint.org/docs/rules/max-statements-per-line
'max-statements-per-line': 'off',
// This rule aims to enforce a particular style for multiline comments.
// https://eslint.org/docs/rules/multiline-comment-style
// TODO - do we want to enable this?
'multiline-comment-style': [
'off',
'starred-block',
],
// This rule enforces or disallows newlines between operands of a ternary expression.
// Note: The location of the operators is not enforced by this rule.
// Please see the operator-linebreak rule if you are interested in enforcing the location of the operators themselves.
// https://eslint.org/docs/rules/multiline-ternary
'multiline-ternary': 'off',
// This rule requires constructor names to begin with a capital letter.
// https://eslint.org/docs/rules/new-cap
'new-cap': [
'error',
{
newIsCap: true,
newIsCapExceptions: [],
capIsNew: false,
capIsNewExceptions: ['Immutable.Map', 'Immutable.Set', 'Immutable.List'],
},
],
// disallow the omission of parentheses when invoking a constructor with no arguments
// https://eslint.org/docs/rules/new-parens
'new-parens': 'error',
// enforces new line after each method call in the chain to make it
// more readable and easy to maintain
// https://eslint.org/docs/rules/newline-per-chained-call
'newline-per-chained-call': ['error', { ignoreChainWithDepth: 4 }],
// This rule is aimed at catching debugging code that should be removed and popup UI elements that should be
// replaced with less obtrusive, custom UIs
// https://eslint.org/docs/rules/no-alert
'no-alert': 'error',
// This rule disallows Array constructors for anything other than using it to create an empty array of length N.
// https://eslint.org/docs/rules/no-array-constructor
'no-array-constructor': 'error',
// The new Promise constructor accepts an executor function as an argument, which has resolve and reject parameters that can be used to control the state of the created Promise
// https://eslint.org/docs/rules/no-async-promise-executor
'no-async-promise-executor': 'error',
// This rule disallows the use of await within loop bodies.
// https://eslint.org/docs/rules/no-await-in-loop
'no-await-in-loop': 'error',
// disallow use of bitwise operators
// https://eslint.org/docs/rules/no-bitwise
'no-bitwise': 'error',
// This rule disallows calling and constructing the Buffer() constructor.
// https://eslint.org/docs/rules/no-buffer-constructor
'no-buffer-constructor': 'error',
// This rule is aimed at discouraging the use of deprecated and sub-optimal code,
// by disallowing the use of arguments.caller and arguments.callee
// https://eslint.org/docs/rules/no-caller
'no-caller': 'error',
// This rule aims to prevent access to uninitialized lexical bindings as well as accessing hoisted functions across case clauses
// https://eslint.org/docs/rules/no-case-declarations
'no-case-declarations': 'error',
// disallow modifying variables of class declarations
// https://eslint.org/docs/rules/no-class-assign
'no-class-assign': 'error',
// The rule should warn against code that tries to compare against -0, since that will not work as intended
// https://eslint.org/docs/rules/no-compare-neg-zero
'no-compare-neg-zero': 'error',
// This rule disallows ambiguous assignment operators in test conditions of if, for, while, and do...while statements.
// https://eslint.org/docs/rules/no-cond-assign
'no-cond-assign': [
'error',
'always',
],
// Disallow arrow functions where they could be confused with comparisons
// https://eslint.org/docs/rules/no-confusing-arrow
'no-confusing-arrow': [
'error',
{
allowParens: true,
},
],
// This rule disallows calls to methods of the console object.
// https://eslint.org/docs/rules/no-console
'no-console': [
'error',
{
allow: [
'info',
'error',
'warn',
'time',
'timeEnd',
'trace',
],
},
],
// This rule is aimed to flag modifying variables that are declared using const keyword.
// https://eslint.org/docs/rules/no-const-assign
'no-const-assign': 'error',
// This rule disallows constant expressions in the test condition.
// https://eslint.org/docs/rules/no-constant-condition
'no-constant-condition': 'error',
// This rule disallows continue statements.
// https://eslint.org/docs/rules/no-continue
'no-continue': 'error',
// This rule disallows control characters in regular expressions.
// https://eslint.org/docs/rules/no-control-regex
'no-control-regex': 'error',
// This rule disallows debugger statements
// https://eslint.org/docs/rules/no-debugger
'no-debugger': 'error',
// This rule disallows the use of the delete operator on variables.
// https://eslint.org/docs/rules/no-delete-var
'no-delete-var': 'error',
// This is used to disambiguate the division operator to not confuse users.
// https://eslint.org/docs/rules/no-div-regex
'no-div-regex': 'off',
// This rule disallows duplicate parameter names in function declarations or expressions
// https://eslint.org/docs/rules/no-dupe-args
'no-dupe-args': 'error',
// This rule is aimed to flag the use of duplicate names in class members.
// https://eslint.org/docs/rules/no-dupe-class-members
'no-dupe-class-members': 'error',
// This rule disallows duplicate keys in object literals.
// https://eslint.org/docs/rules/no-dupe-keys
'no-dupe-keys': 'error',
// This rule disallows duplicate test expressions in case clauses of switch statements.
// https://eslint.org/docs/rules/no-duplicate-case
'no-duplicate-case': 'error',
// This rules requires that all imports from a single module exists in a single import statement.
// https://eslint.org/docs/rules/no-duplicate-imports
'no-duplicate-imports': 'error',
// This rule is aimed at highlighting an unnecessary block of code following an if containing a return statement.
// https://eslint.org/docs/rules/no-else-return
'no-else-return': [
'error',
{
allowElseIf: false,
},
],
// This rule disallows empty block statements
// https://eslint.org/docs/rules/no-empty
'no-empty': 'error',
// This rule disallows empty character classes in regular expressions.
// https://eslint.org/docs/rules/no-empty-character-class
'no-empty-character-class': 'error',
// This rule is aimed at eliminating empty functions.
// https://eslint.org/docs/rules/no-empty-function
'no-empty-function': [
'error',
{
allow: [
'arrowFunctions',
'functions',
'methods',
],
},
],
// This rule aims to flag any empty patterns in destructured objects and arrays, and as such,
// will report a problem whenever one is encountered.
// https://eslint.org/docs/rules/no-empty-pattern
'no-empty-pattern': 'error',
// This rule aims reduce potential bug and unwanted behavior by ensuring that comparisons to null only match null,
// and not also undefined.
// https://eslint.org/docs/rules/no-eq-null
'no-eq-null': 'off',
// This rule is aimed at preventing potentially dangerous, unnecessary, and slow code by
// disallowing the use of the eval() function.
// https://eslint.org/docs/rules/no-eval
'no-eval': 'error',
// This rule disallows reassigning exceptions in catch clauses
// https://eslint.org/docs/rules/no-ex-assign
'no-ex-assign': 'error',
// Disallows directly modifying the prototype of builtin objects.
// https://eslint.org/docs/rules/no-extend-native
'no-extend-native': 'error',
// This rule is aimed at avoiding the unnecessary use of bind() and as such will warn whenever an
// immediately-invoked function expression (IIFE) is using bind() and doesn’t have an appropriate this value.
// https://eslint.org/docs/rules/no-extra-bind
'no-extra-bind': 'error',
// This rule disallows unnecessary boolean casts
// https://eslint.org/docs/rules/no-extra-boolean-cast
'no-extra-boolean-cast': 'error',
// This rule is aimed at eliminating unnecessary labels.
// https://eslint.org/docs/rules/no-extra-label
'no-extra-label': 'error',
// disallow unnecessary parentheses
// https://eslint.org/docs/rules/no-extra-parens
'no-extra-parens': 'off',
// This rule disallows unnecessary semicolons
// https://eslint.org/docs/rules/no-extra-semi
'no-extra-semi': 'error',
// This rule is aimed at eliminating unintentional fallthrough of one case to the other.
// https://eslint.org/docs/rules/no-fallthrough
'no-fallthrough': 'error',
// This rule is aimed at eliminating floating decimal points and will warn whenever a numeric value has a
// decimal point but is missing a number either before or after it.
// https://eslint.org/docs/rules/no-floating-decimal
'no-floating-decimal': 'error',
// This rule disallows reassigning function declarations
// https://eslint.org/docs/rules/no-func-assign
'no-func-assign': 'error',
// This rule disallows modifications to read-only global variables
// https://eslint.org/docs/rules/no-global-assign
'no-global-assign': 'error',
// This rule is aimed to flag shorter notations for the type conversion, then suggest a more self-explanatory notation.
// https://eslint.org/docs/rules/no-implicit-coercion
'no-implicit-coercion': 'off',
// This rule disallows var and named function declarations at the top-level script scope.
// https://eslint.org/docs/rules/no-implicit-globals
'no-implicit-globals': 'error',
// This rule aims to eliminate implied eval() through the use of setTimeout(), setInterval() or execScript().
// https://eslint.org/docs/rules/no-implied-eval
'no-implied-eval': 'error',
// This rule disallows comments on the same line as code.
// https://eslint.org/docs/rules/no-inline-comments
'no-inline-comments': 'off',
// This rule requires that function declarations and, optionally, variable declarations be in the root of a
// program or the body of a function.
// https://eslint.org/docs/rules/no-inner-declarations
'no-inner-declarations': 'error',
// This rule disallows invalid regular expression strings in RegExp constructors.
// https://eslint.org/docs/rules/no-invalid-regexp
'no-invalid-regexp': 'error',
// This rule aims to flag usage of this keywords outside of classes or class-like objects.
// https://eslint.org/docs/rules/no-invalid-this
'no-invalid-this': 'off',
// This rule is aimed at catching invalid whitespace that is not a normal tab and space
// https://eslint.org/docs/rules/no-irregular-whitespace
'no-irregular-whitespace': 'error',
// This rule is aimed at preventing errors that may arise from using the __iterator__ property.
// https://eslint.org/docs/rules/no-iterator
'no-iterator': 'error',
// This rule aims to create clearer code by disallowing the bad practice of creating a label that shares a name
// with a variable that is in scope
// https://eslint.org/docs/rules/no-label-var
'no-label-var': 'error',
// This rule aims to eliminate the use of labeled statements in JavaScript
// Seriously. WHY WOULD YOU USE LABEL STATEMENTS IN JAVASCRIPT. WTF.
// https://eslint.org/docs/rules/no-labels
'no-labels': 'error',
// This rule aims to eliminate unnecessary and potentially confusing blocks at the top level of a script or within other blocks.
// https://eslint.org/docs/rules/no-lone-blocks
'no-lone-blocks': 'error',
// This rule disallows if statements as the only statement in else blocks
// https://eslint.org/docs/rules/no-lonely-if
'no-lonely-if': 'error',
// Disallow Functions in Loops.
// https://eslint.org/docs/rules/no-loop-func
'no-loop-func': 'error',
// This rule aims to make code more readable by ensuring that special numbers are declared as constants
// https://eslint.org/docs/rules/no-magic-numbers
'no-magic-numbers': 'off',
// Disallow characters which are made with multiple code points in character class syntax, basically disallows emojis to be used as class names
// https://eslint.org/docs/rules/no-misleading-character-class
'no-misleading-character-class': 'error',
// Disallow mixes of different operators
// https://eslint.org/docs/rules/no-mixed-operators
'no-mixed-operators': [
'error',
{
// the list of arthmetic groups disallows mixing `%` and `**` with other arithmetic operators.
groups: [
['%', '**'],
['%', '+'],
['%', '-'],
['%', '*'],
['%', '/'],
['**', '+'],
['**', '-'],
['**', '*'],
['**', '/'],
['&', '|', '^', '~', '<<', '>>', '>>>'],
['==', '!=', '===', '!==', '>', '>=', '<', '<='],
['&&', '||'],
['in', 'instanceof'],
],
allowSamePrecedence: false,
},
],
// disallow require calls to be mixed with regular variable declarations
// https://eslint.org/docs/rules/no-mixed-requires
'no-mixed-requires': 'off',
// disallow mixed spaces and tabs for indentation
// https://eslint.org/docs/rules/no-mixed-spaces-and-tabs
'no-mixed-spaces-and-tabs': 'error',
// Disallow Use of Chained Assignment Expressions
// https://eslint.org/docs/rules/no-multi-assign
'no-multi-assign': 'error',
// Disallow multiple spaces
// https://eslint.org/docs/rules/no-multi-spaces
'no-multi-spaces': [
'warn',
{
exceptions: {
VariableDeclarator: true,
},
},
],
// This rule is aimed at preventing the use of multiline strings
// https://eslint.org/docs/rules/no-multi-str
'no-multi-str': 'error',
// This rule aims to reduce the scrolling required when reading through your code
// https://eslint.org/docs/rules/no-multiple-empty-lines
'no-multiple-empty-lines': [
'error',
{
max: 2,
maxEOF: 0,
},
],
// disallow negated conditions
// https://eslint.org/docs/rules/no-negated-condition
'no-negated-condition': 'off',
// disallow nested ternary expressions
// https://eslint.org/docs/rules/no-nested-ternary
'no-nested-ternary': 'error',
// Disallow new For Side Effects
// https://eslint.org/docs/rules/no-new
'no-new': 'error',
// Disallow Function Constructor
// https://eslint.org/docs/rules/no-new-func
'no-new-func': 'error',
// disallow `Object` constructors
// https://eslint.org/docs/rules/no-new-object
'no-new-object': 'error',
// This rule aims to eliminate use of the new require expression
// https://eslint.org/docs/rules/no-new-require
'no-new-require': 'error',
// This rule is aimed at preventing the accidental calling of Symbol with the new operator
// https://eslint.org/docs/rules/no-new-symbol
'no-new-symbol': 'error',
// This rule aims to eliminate the use of String, Number, and Boolean with the new operator
// https://eslint.org/docs/rules/no-new-wrappers
'no-new-wrappers': 'error',
// This rule disallows calling the Math, JSON and Reflect objects as functions
// https://eslint.org/docs/rules/no-obj-calls
'no-obj-calls': 'error',
// The rule disallows octal literals
// https://eslint.org/docs/rules/no-octal
'no-octal': 'error',
// This rule disallows octal escape sequences in string literals
// https://eslint.org/docs/rules/no-octal-escape
'no-octal-escape': 'error',
// This rule aims to prevent unintended behavior caused by modification or reassignment of function parameters
// https://eslint.org/docs/rules/no-param-reassign
'no-param-reassign': 'off',
// Disallow string concatenation when using __dirname and __filename
// https://eslint.org/docs/rules/no-path-concat
'no-path-concat': 'error',
// disallow the unary operators ++ and --
// https://eslint.org/docs/rules/no-plusplus
'no-plusplus': [
'error',
{
allowForLoopAfterthoughts: false,
},
],
// This rule is aimed at discouraging use of process.env to avoid global dependencies
// https://eslint.org/docs/rules/no-process-env
'no-process-env': 'off',
// This rule aims to prevent the use of process.exit() in Node.js JavaScript
// https://eslint.org/docs/rules/no-process-exit
'no-process-exit': 'off',
// When an object is created __proto__ is set to the original prototype property of the object’s constructor function.
// https://eslint.org/docs/rules/no-proto
'no-proto': 'error',
// This rule disallows calling some Object.prototype methods directly on object instances
// https://eslint.org/docs/rules/no-prototype-builtins
'no-prototype-builtins': 'error',
// This rule is aimed at eliminating variables that have multiple declarations in the same scope
// https://eslint.org/docs/rules/no-redeclare
'no-redeclare': 'error',
// This rule disallows multiple spaces in regular expression literals
// https://eslint.org/docs/rules/no-regex-spaces
'no-regex-spaces': 'error',
// This rule allows you to specify global variable names that you don’t want to use in your application
// https://eslint.org/docs/rules/no-restricted-globals
'no-restricted-globals': [
'error',
'isFinite',
...restrictedGlobals,
] as Rules.RuleType,
// This rule allows you to specify imports that you don’t want to use in your application
// https://eslint.org/docs/rules/no-restricted-imports
'no-restricted-imports': 'off',
// This rule allows you to specify modules that you don’t want to use in your application
// https://eslint.org/docs/rules/no-restricted-modules
'no-restricted-modules': 'off',
// This rule looks for accessing a given property key on a given object name, either when reading the property’s
// value or invoking it as a function
// https://eslint.org/docs/rules/no-restricted-properties
'no-restricted-properties': [
'error',
{
object: 'arguments',
property: 'callee',
message: 'arguments.callee is deprecated',
},
{
object: 'global',
property: 'isFinite',
message: 'Please use Number.isFinite instead',
},
{
object: 'self',
property: 'isFinite',
message: 'Please use Number.isFinite instead',
},
{
object: 'window',
property: 'isFinite',
message: 'Please use Number.isFinite instead',
},
{
object: 'global',
property: 'isNaN',
message: 'Please use Number.isNaN instead',
},
{
object: 'self',
property: 'isNaN',
message: 'Please use Number.isNaN instead',
},
{
object: 'window',
property: 'isNaN',
message: 'Please use Number.isNaN instead',
},
{
property: '__defineGetter__',
message: 'Please use Object.defineProperty instead.',
},
{
property: '__defineSetter__',
message: 'Please use Object.defineProperty instead.',
},
{
object: 'Math',
property: 'pow',
message: 'Use the exponentiation operator (**) instead.',
},
],
// This rule disallows specified (that is, user-defined) syntax
// https://eslint.org/docs/rules/no-restricted-syntax
'no-restricted-syntax': [
'error',
/* eslint-disable max-len */
{