-
Notifications
You must be signed in to change notification settings - Fork 26.5k
/
errors.js
189 lines (141 loc) · 6.82 KB
/
errors.js
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
module.exports = {
rules: {
// Enforce “for” loop update clause moving the counter in the right direction
// https://eslint.org/docs/rules/for-direction
'for-direction': 'error',
// Enforces that a return statement is present in property getters
// https://eslint.org/docs/rules/getter-return
'getter-return': ['error', { allowImplicit: true }],
// disallow using an async function as a Promise executor
// https://eslint.org/docs/rules/no-async-promise-executor
'no-async-promise-executor': 'error',
// Disallow await inside of loops
// https://eslint.org/docs/rules/no-await-in-loop
'no-await-in-loop': 'error',
// Disallow comparisons to negative zero
// https://eslint.org/docs/rules/no-compare-neg-zero
'no-compare-neg-zero': 'error',
// disallow assignment in conditional expressions
'no-cond-assign': ['error', 'always'],
// disallow use of console
'no-console': 'warn',
// Disallows expressions where the operation doesn't affect the value
// https://eslint.org/docs/rules/no-constant-binary-expression
// TODO: semver-major, enable
'no-constant-binary-expression': 'off',
// disallow use of constant expressions in conditions
'no-constant-condition': 'warn',
// disallow control characters in regular expressions
'no-control-regex': 'error',
// disallow use of debugger
'no-debugger': 'error',
// disallow duplicate arguments in functions
'no-dupe-args': 'error',
// Disallow duplicate conditions in if-else-if chains
// https://eslint.org/docs/rules/no-dupe-else-if
'no-dupe-else-if': 'error',
// disallow duplicate keys when creating object literals
'no-dupe-keys': 'error',
// disallow a duplicate case label.
'no-duplicate-case': 'error',
// disallow empty statements
'no-empty': 'error',
// disallow the use of empty character classes in regular expressions
'no-empty-character-class': 'error',
// disallow assigning to the exception in a catch block
'no-ex-assign': 'error',
// disallow double-negation boolean casts in a boolean context
// https://eslint.org/docs/rules/no-extra-boolean-cast
'no-extra-boolean-cast': 'error',
// disallow unnecessary parentheses
// https://eslint.org/docs/rules/no-extra-parens
'no-extra-parens': ['off', 'all', {
conditionalAssign: true,
nestedBinaryExpressions: false,
returnAssign: false,
ignoreJSX: 'all', // delegate to eslint-plugin-react
enforceForArrowConditionals: false,
}],
// disallow unnecessary semicolons
'no-extra-semi': 'error',
// disallow overwriting functions written as function declarations
'no-func-assign': 'error',
// https://eslint.org/docs/rules/no-import-assign
'no-import-assign': 'error',
// disallow function or variable declarations in nested blocks
'no-inner-declarations': 'error',
// disallow invalid regular expression strings in the RegExp constructor
'no-invalid-regexp': 'error',
// disallow irregular whitespace outside of strings and comments
'no-irregular-whitespace': 'error',
// Disallow Number Literals That Lose Precision
// https://eslint.org/docs/rules/no-loss-of-precision
'no-loss-of-precision': 'error',
// Disallow characters which are made with multiple code points in character class syntax
// https://eslint.org/docs/rules/no-misleading-character-class
'no-misleading-character-class': 'error',
// disallow the use of object properties of the global object (Math and JSON) as functions
'no-obj-calls': 'error',
// Disallow new operators with global non-constructor functions
// https://eslint.org/docs/latest/rules/no-new-native-nonconstructor
// TODO: semver-major, enable
'no-new-native-nonconstructor': 'off',
// Disallow returning values from Promise executor functions
// https://eslint.org/docs/rules/no-promise-executor-return
'no-promise-executor-return': 'error',
// disallow use of Object.prototypes builtins directly
// https://eslint.org/docs/rules/no-prototype-builtins
'no-prototype-builtins': 'error',
// disallow multiple spaces in a regular expression literal
'no-regex-spaces': 'error',
// Disallow returning values from setters
// https://eslint.org/docs/rules/no-setter-return
'no-setter-return': 'error',
// disallow sparse arrays
'no-sparse-arrays': 'error',
// Disallow template literal placeholder syntax in regular strings
// https://eslint.org/docs/rules/no-template-curly-in-string
'no-template-curly-in-string': 'error',
// Avoid code that looks like two expressions but is actually one
// https://eslint.org/docs/rules/no-unexpected-multiline
'no-unexpected-multiline': 'error',
// disallow unreachable statements after a return, throw, continue, or break statement
'no-unreachable': 'error',
// Disallow loops with a body that allows only one iteration
// https://eslint.org/docs/rules/no-unreachable-loop
'no-unreachable-loop': ['error', {
ignore: [], // WhileStatement, DoWhileStatement, ForStatement, ForInStatement, ForOfStatement
}],
// disallow return/throw/break/continue inside finally blocks
// https://eslint.org/docs/rules/no-unsafe-finally
'no-unsafe-finally': 'error',
// disallow negating the left operand of relational operators
// https://eslint.org/docs/rules/no-unsafe-negation
'no-unsafe-negation': 'error',
// disallow use of optional chaining in contexts where the undefined value is not allowed
// https://eslint.org/docs/rules/no-unsafe-optional-chaining
'no-unsafe-optional-chaining': ['error', { disallowArithmeticOperators: true }],
// Disallow Unused Private Class Members
// https://eslint.org/docs/rules/no-unused-private-class-members
// TODO: enable once eslint 7 is dropped (which is semver-major)
'no-unused-private-class-members': 'off',
// Disallow useless backreferences in regular expressions
// https://eslint.org/docs/rules/no-useless-backreference
'no-useless-backreference': 'error',
// disallow negation of the left operand of an in expression
// deprecated in favor of no-unsafe-negation
'no-negated-in-lhs': 'off',
// Disallow assignments that can lead to race conditions due to usage of await or yield
// https://eslint.org/docs/rules/require-atomic-updates
// note: not enabled because it is very buggy
'require-atomic-updates': 'off',
// disallow comparisons with the value NaN
'use-isnan': 'error',
// ensure JSDoc comments are valid
// https://eslint.org/docs/rules/valid-jsdoc
'valid-jsdoc': 'off',
// ensure that the results of typeof are compared against a valid string
// https://eslint.org/docs/rules/valid-typeof
'valid-typeof': ['error', { requireStringLiterals: true }],
}
};