@innovixx/eslint-config 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +10 -0
- package/.eslintrc +6 -0
- package/LICENSE +21 -0
- package/README.md +62 -0
- package/configs/base/index.js +17 -0
- package/configs/base/rules/best-practices.js +356 -0
- package/configs/base/rules/errors.js +154 -0
- package/configs/base/rules/es6.js +176 -0
- package/configs/base/rules/imports.js +234 -0
- package/configs/base/rules/style.js +525 -0
- package/configs/base/rules/variables.js +44 -0
- package/configs/index.js +8 -0
- package/configs/jest/index.js +14 -0
- package/configs/jest/rules/jest-dom.js +9 -0
- package/configs/jest/rules/jest.js +44 -0
- package/configs/react/index.js +26 -0
- package/configs/react/rules/react-a11y.js +229 -0
- package/configs/react/rules/react-hooks.js +11 -0
- package/configs/react/rules/react.js +499 -0
- package/package.json +55 -0
package/.editorconfig
ADDED
package/.eslintrc
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Innovixx Ltd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# JavaScript Style Guide
|
|
2
|
+
|
|
3
|
+
## Highlights
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
### Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
$ npm i --save-dev @innovixx/eslint-config
|
|
11
|
+
$ npm info @innovixx/eslint-config peerDependencies
|
|
12
|
+
$ npm i --save-dev <dependency>@<version> # for each dependency in the above output
|
|
13
|
+
$ # or
|
|
14
|
+
$ yarn add --dev @innovixx/eslint-config
|
|
15
|
+
$ yarn info @innovixx/eslint-config peerDependencies
|
|
16
|
+
$ yarn add --dev <dependency>@<version> # for each dependency in the above output
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Usage
|
|
20
|
+
|
|
21
|
+
There are a number of configurations for consumption, all of which are packaged together as the default export — *or they can be selectively extended, which prevents the path names [from being written shorthand](https://eslint.org/docs/developer-guide/shareable-configs#sharing-multiple-configs).*
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
{
|
|
25
|
+
"extends": "@innovixx"
|
|
26
|
+
// or selectively extend any config(s)
|
|
27
|
+
// "extends": [
|
|
28
|
+
// "@innovixx/eslint-config/configs/base",
|
|
29
|
+
// "@innovixx/eslint-config/configs/jest",
|
|
30
|
+
// "@innovixx/eslint-config/configs/react",
|
|
31
|
+
// ]
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
If using Webpack, install and configure `eslint-loader` to have loaded files automatically linted.
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
{
|
|
39
|
+
test: /\.js$/,
|
|
40
|
+
exclude: /node_modules/,
|
|
41
|
+
loader: 'eslint-loader',
|
|
42
|
+
options: {
|
|
43
|
+
fix: true,
|
|
44
|
+
emitWarning: true,
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
For working examples, see the [demo app](./demo/App.demo.js).
|
|
50
|
+
|
|
51
|
+
## Demo
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
$ git clone git@github.com:Innovixx-Development/eslint-config.git
|
|
55
|
+
$ yarn
|
|
56
|
+
$ yarn demo
|
|
57
|
+
$ open http://localhost:3000
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
[MIT](https://github.com/Innovixx-Development/eslint-config/blob/master/LICENSE) Copyright (c) Innovixx, Ltd
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
plugins: [
|
|
3
|
+
'node',
|
|
4
|
+
],
|
|
5
|
+
env: {
|
|
6
|
+
node: true,
|
|
7
|
+
},
|
|
8
|
+
extends: [
|
|
9
|
+
'./rules/best-practices',
|
|
10
|
+
'./rules/errors',
|
|
11
|
+
'./rules/es6',
|
|
12
|
+
'./rules/imports',
|
|
13
|
+
'./rules/style',
|
|
14
|
+
'./rules/variables',
|
|
15
|
+
].map(require.resolve),
|
|
16
|
+
rules: {},
|
|
17
|
+
};
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
rules: {
|
|
3
|
+
// enforces getter/setter pairs in objects
|
|
4
|
+
'accessor-pairs': 'off',
|
|
5
|
+
|
|
6
|
+
// enforces return statements in callbacks of array's methods
|
|
7
|
+
// https://eslint.org/docs/rules/array-callback-return
|
|
8
|
+
'array-callback-return': ['error', { allowImplicit: true }],
|
|
9
|
+
|
|
10
|
+
// treat var statements as if they were block scoped
|
|
11
|
+
'block-scoped-var': 'error',
|
|
12
|
+
|
|
13
|
+
// specify the maximum cyclomatic complexity allowed in a program
|
|
14
|
+
complexity: ['off', 11],
|
|
15
|
+
|
|
16
|
+
// enforce that class methods use "this"
|
|
17
|
+
// https://eslint.org/docs/rules/class-methods-use-this
|
|
18
|
+
'class-methods-use-this': ['error', {
|
|
19
|
+
exceptMethods: [],
|
|
20
|
+
}],
|
|
21
|
+
|
|
22
|
+
// require return statements to either always or never specify values
|
|
23
|
+
'consistent-return': 'error',
|
|
24
|
+
|
|
25
|
+
// specify curly brace conventions for all control statements
|
|
26
|
+
curly: ['error', 'multi-line'], // multiline
|
|
27
|
+
|
|
28
|
+
// require default case in switch statements
|
|
29
|
+
'default-case': ['error', { commentPattern: '^no default$' }],
|
|
30
|
+
|
|
31
|
+
// https://eslint.org/docs/rules/default-param-last
|
|
32
|
+
// TODO: enable, semver-minor, when eslint v6.4 is required (which is a major)
|
|
33
|
+
'default-param-last': 'off',
|
|
34
|
+
|
|
35
|
+
// encourages use of dot notation whenever possible
|
|
36
|
+
'dot-notation': ['error', { allowKeywords: true }],
|
|
37
|
+
|
|
38
|
+
// enforces consistent newlines before or after dots
|
|
39
|
+
// https://eslint.org/docs/rules/dot-location
|
|
40
|
+
'dot-location': ['error', 'property'],
|
|
41
|
+
|
|
42
|
+
// require the use of === and !==
|
|
43
|
+
// https://eslint.org/docs/rules/eqeqeq
|
|
44
|
+
eqeqeq: ['error', 'always', { null: 'ignore' }],
|
|
45
|
+
|
|
46
|
+
// Require grouped accessor pairs in object literals and classes
|
|
47
|
+
// https://eslint.org/docs/rules/grouped-accessor-pairs
|
|
48
|
+
// TODO: enable in next major, altho the guide forbids getters/setters anyways
|
|
49
|
+
'grouped-accessor-pairs': 'off',
|
|
50
|
+
|
|
51
|
+
// make sure for-in loops have an if statement
|
|
52
|
+
'guard-for-in': 'error',
|
|
53
|
+
|
|
54
|
+
// enforce a maximum number of classes per file
|
|
55
|
+
// https://eslint.org/docs/rules/max-classes-per-file
|
|
56
|
+
'max-classes-per-file': ['error', 1],
|
|
57
|
+
|
|
58
|
+
// disallow the use of alert, confirm, and prompt
|
|
59
|
+
'no-alert': 'warn',
|
|
60
|
+
|
|
61
|
+
// disallow use of arguments.caller or arguments.callee
|
|
62
|
+
'no-caller': 'error',
|
|
63
|
+
|
|
64
|
+
// disallow lexical declarations in case/default clauses
|
|
65
|
+
// https://eslint.org/docs/rules/no-case-declarations.html
|
|
66
|
+
'no-case-declarations': 'error',
|
|
67
|
+
|
|
68
|
+
// Disallow returning value in constructor
|
|
69
|
+
// https://eslint.org/docs/rules/no-constructor-return
|
|
70
|
+
// TODO: enable, semver-major
|
|
71
|
+
'no-constructor-return': 'off',
|
|
72
|
+
|
|
73
|
+
// disallow division operators explicitly at beginning of regular expression
|
|
74
|
+
// https://eslint.org/docs/rules/no-div-regex
|
|
75
|
+
'no-div-regex': 'off',
|
|
76
|
+
|
|
77
|
+
// disallow else after a return in an if
|
|
78
|
+
// https://eslint.org/docs/rules/no-else-return
|
|
79
|
+
'no-else-return': ['error', { allowElseIf: false }],
|
|
80
|
+
|
|
81
|
+
// disallow empty functions, except for standalone funcs/arrows
|
|
82
|
+
// https://eslint.org/docs/rules/no-empty-function
|
|
83
|
+
'no-empty-function': ['error', {
|
|
84
|
+
allow: [
|
|
85
|
+
'arrowFunctions',
|
|
86
|
+
'functions',
|
|
87
|
+
'methods',
|
|
88
|
+
],
|
|
89
|
+
}],
|
|
90
|
+
|
|
91
|
+
// disallow empty destructuring patterns
|
|
92
|
+
// https://eslint.org/docs/rules/no-empty-pattern
|
|
93
|
+
'no-empty-pattern': 'error',
|
|
94
|
+
|
|
95
|
+
// disallow comparisons to null without a type-checking operator
|
|
96
|
+
'no-eq-null': 'off',
|
|
97
|
+
|
|
98
|
+
// disallow use of eval()
|
|
99
|
+
'no-eval': 'error',
|
|
100
|
+
|
|
101
|
+
// disallow adding to native types
|
|
102
|
+
'no-extend-native': 'error',
|
|
103
|
+
|
|
104
|
+
// disallow unnecessary function binding
|
|
105
|
+
'no-extra-bind': 'error',
|
|
106
|
+
|
|
107
|
+
// disallow Unnecessary Labels
|
|
108
|
+
// https://eslint.org/docs/rules/no-extra-label
|
|
109
|
+
'no-extra-label': 'error',
|
|
110
|
+
|
|
111
|
+
// disallow fallthrough of case statements
|
|
112
|
+
'no-fallthrough': 'error',
|
|
113
|
+
|
|
114
|
+
// disallow the use of leading or trailing decimal points in numeric literals
|
|
115
|
+
'no-floating-decimal': 'error',
|
|
116
|
+
|
|
117
|
+
// disallow reassignments of native objects or read-only globals
|
|
118
|
+
// https://eslint.org/docs/rules/no-global-assign
|
|
119
|
+
'no-global-assign': ['error', { exceptions: [] }],
|
|
120
|
+
// deprecated in favor of no-global-assign
|
|
121
|
+
'no-native-reassign': 'off',
|
|
122
|
+
|
|
123
|
+
// disallow implicit type conversions
|
|
124
|
+
// https://eslint.org/docs/rules/no-implicit-coercion
|
|
125
|
+
'no-implicit-coercion': ['off', {
|
|
126
|
+
boolean: false,
|
|
127
|
+
number: true,
|
|
128
|
+
string: true,
|
|
129
|
+
allow: [],
|
|
130
|
+
}],
|
|
131
|
+
|
|
132
|
+
// disallow var and named functions in global scope
|
|
133
|
+
// https://eslint.org/docs/rules/no-implicit-globals
|
|
134
|
+
'no-implicit-globals': 'off',
|
|
135
|
+
|
|
136
|
+
// disallow use of eval()-like methods
|
|
137
|
+
'no-implied-eval': 'error',
|
|
138
|
+
|
|
139
|
+
// disallow this keywords outside of classes or class-like objects
|
|
140
|
+
'no-invalid-this': 'off',
|
|
141
|
+
|
|
142
|
+
// disallow usage of __iterator__ property
|
|
143
|
+
'no-iterator': 'error',
|
|
144
|
+
|
|
145
|
+
// disallow use of labels for anything other then loops and switches
|
|
146
|
+
'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
|
|
147
|
+
|
|
148
|
+
// disallow unnecessary nested blocks
|
|
149
|
+
'no-lone-blocks': 'error',
|
|
150
|
+
|
|
151
|
+
// disallow creation of functions within loops
|
|
152
|
+
'no-loop-func': 'error',
|
|
153
|
+
|
|
154
|
+
// disallow magic numbers
|
|
155
|
+
// https://eslint.org/docs/rules/no-magic-numbers
|
|
156
|
+
'no-magic-numbers': ['off', {
|
|
157
|
+
ignore: [],
|
|
158
|
+
ignoreArrayIndexes: true,
|
|
159
|
+
enforceConst: true,
|
|
160
|
+
detectObjects: false,
|
|
161
|
+
}],
|
|
162
|
+
|
|
163
|
+
// disallow use of multiple spaces
|
|
164
|
+
'no-multi-spaces': ['error', {
|
|
165
|
+
ignoreEOLComments: false,
|
|
166
|
+
}],
|
|
167
|
+
|
|
168
|
+
// disallow use of multiline strings
|
|
169
|
+
'no-multi-str': 'error',
|
|
170
|
+
|
|
171
|
+
// disallow use of new operator when not part of the assignment or comparison
|
|
172
|
+
'no-new': 'error',
|
|
173
|
+
|
|
174
|
+
// disallow use of new operator for Function object
|
|
175
|
+
'no-new-func': 'error',
|
|
176
|
+
|
|
177
|
+
// disallows creating new instances of String, Number, and Boolean
|
|
178
|
+
'no-new-wrappers': 'error',
|
|
179
|
+
|
|
180
|
+
// disallow use of (old style) octal literals
|
|
181
|
+
'no-octal': 'error',
|
|
182
|
+
|
|
183
|
+
// disallow use of octal escape sequences in string literals, such as
|
|
184
|
+
// var foo = 'Copyright \251';
|
|
185
|
+
'no-octal-escape': 'error',
|
|
186
|
+
|
|
187
|
+
// disallow reassignment of function parameters
|
|
188
|
+
// disallow parameter object manipulation except for specific exclusions
|
|
189
|
+
// rule: https://eslint.org/docs/rules/no-param-reassign.html
|
|
190
|
+
'no-param-reassign': ['error', {
|
|
191
|
+
props: true,
|
|
192
|
+
ignorePropertyModificationsFor: [
|
|
193
|
+
'acc', // for reduce accumulators
|
|
194
|
+
'accumulator', // for reduce accumulators
|
|
195
|
+
'e', // for e.returnvalue
|
|
196
|
+
'ctx', // for Koa routing
|
|
197
|
+
'req', // for Express requests
|
|
198
|
+
'request', // for Express requests
|
|
199
|
+
'res', // for Express responses
|
|
200
|
+
'response', // for Express responses
|
|
201
|
+
'$scope', // for Angular 1 scopes
|
|
202
|
+
'staticContext', // for ReactRouter context
|
|
203
|
+
],
|
|
204
|
+
}],
|
|
205
|
+
|
|
206
|
+
// disallow usage of __proto__ property
|
|
207
|
+
'no-proto': 'error',
|
|
208
|
+
|
|
209
|
+
// disallow declaring the same variable more then once
|
|
210
|
+
'no-redeclare': 'error',
|
|
211
|
+
|
|
212
|
+
// disallow certain object properties
|
|
213
|
+
// https://eslint.org/docs/rules/no-restricted-properties
|
|
214
|
+
'no-restricted-properties': ['error',
|
|
215
|
+
{
|
|
216
|
+
object: 'arguments',
|
|
217
|
+
property: 'callee',
|
|
218
|
+
message: 'arguments.callee is deprecated',
|
|
219
|
+
}, {
|
|
220
|
+
object: 'global',
|
|
221
|
+
property: 'isFinite',
|
|
222
|
+
message: 'Please use Number.isFinite instead',
|
|
223
|
+
}, {
|
|
224
|
+
object: 'self',
|
|
225
|
+
property: 'isFinite',
|
|
226
|
+
message: 'Please use Number.isFinite instead',
|
|
227
|
+
}, {
|
|
228
|
+
object: 'window',
|
|
229
|
+
property: 'isFinite',
|
|
230
|
+
message: 'Please use Number.isFinite instead',
|
|
231
|
+
}, {
|
|
232
|
+
object: 'global',
|
|
233
|
+
property: 'isNaN',
|
|
234
|
+
message: 'Please use Number.isNaN instead',
|
|
235
|
+
}, {
|
|
236
|
+
object: 'self',
|
|
237
|
+
property: 'isNaN',
|
|
238
|
+
message: 'Please use Number.isNaN instead',
|
|
239
|
+
}, {
|
|
240
|
+
object: 'window',
|
|
241
|
+
property: 'isNaN',
|
|
242
|
+
message: 'Please use Number.isNaN instead',
|
|
243
|
+
}, {
|
|
244
|
+
property: '__defineGetter__',
|
|
245
|
+
message: 'Please use Object.defineProperty instead.',
|
|
246
|
+
}, {
|
|
247
|
+
property: '__defineSetter__',
|
|
248
|
+
message: 'Please use Object.defineProperty instead.',
|
|
249
|
+
}, {
|
|
250
|
+
object: 'Math',
|
|
251
|
+
property: 'pow',
|
|
252
|
+
message: 'Use the exponentiation operator (**) instead.',
|
|
253
|
+
}],
|
|
254
|
+
|
|
255
|
+
// disallow use of assignment in return statement
|
|
256
|
+
'no-return-assign': ['error', 'always'],
|
|
257
|
+
|
|
258
|
+
// disallow redundant `return await`
|
|
259
|
+
'no-return-await': 'error',
|
|
260
|
+
|
|
261
|
+
// disallow use of `javascript:` urls.
|
|
262
|
+
'no-script-url': 'error',
|
|
263
|
+
|
|
264
|
+
// disallow self assignment
|
|
265
|
+
// https://eslint.org/docs/rules/no-self-assign
|
|
266
|
+
'no-self-assign': ['error', {
|
|
267
|
+
props: true,
|
|
268
|
+
}],
|
|
269
|
+
|
|
270
|
+
// disallow comparisons where both sides are exactly the same
|
|
271
|
+
'no-self-compare': 'error',
|
|
272
|
+
|
|
273
|
+
// disallow use of comma operator
|
|
274
|
+
'no-sequences': 'error',
|
|
275
|
+
|
|
276
|
+
// restrict what can be thrown as an exception
|
|
277
|
+
'no-throw-literal': 'error',
|
|
278
|
+
|
|
279
|
+
// disallow unmodified conditions of loops
|
|
280
|
+
// https://eslint.org/docs/rules/no-unmodified-loop-condition
|
|
281
|
+
'no-unmodified-loop-condition': 'off',
|
|
282
|
+
|
|
283
|
+
// disallow usage of expressions in statement position
|
|
284
|
+
'no-unused-expressions': ['error', {
|
|
285
|
+
allowShortCircuit: false,
|
|
286
|
+
allowTernary: false,
|
|
287
|
+
allowTaggedTemplates: false,
|
|
288
|
+
}],
|
|
289
|
+
|
|
290
|
+
// disallow unused labels
|
|
291
|
+
// https://eslint.org/docs/rules/no-unused-labels
|
|
292
|
+
'no-unused-labels': 'error',
|
|
293
|
+
|
|
294
|
+
// disallow unnecessary .call() and .apply()
|
|
295
|
+
'no-useless-call': 'off',
|
|
296
|
+
|
|
297
|
+
// Disallow unnecessary catch clauses
|
|
298
|
+
// https://eslint.org/docs/rules/no-useless-catch
|
|
299
|
+
'no-useless-catch': 'error',
|
|
300
|
+
|
|
301
|
+
// disallow useless string concatenation
|
|
302
|
+
// https://eslint.org/docs/rules/no-useless-concat
|
|
303
|
+
'no-useless-concat': 'error',
|
|
304
|
+
|
|
305
|
+
// disallow unnecessary string escaping
|
|
306
|
+
// https://eslint.org/docs/rules/no-useless-escape
|
|
307
|
+
'no-useless-escape': 'error',
|
|
308
|
+
|
|
309
|
+
// disallow redundant return; keywords
|
|
310
|
+
// https://eslint.org/docs/rules/no-useless-return
|
|
311
|
+
'no-useless-return': 'error',
|
|
312
|
+
|
|
313
|
+
// disallow use of void operator
|
|
314
|
+
// https://eslint.org/docs/rules/no-void
|
|
315
|
+
'no-void': 'error',
|
|
316
|
+
|
|
317
|
+
// disallow usage of configurable warning terms in comments: e.g. todo
|
|
318
|
+
'no-warning-comments': ['off', { terms: ['todo', 'fixme', 'xxx'], location: 'start' }],
|
|
319
|
+
|
|
320
|
+
// disallow use of the with statement
|
|
321
|
+
'no-with': 'error',
|
|
322
|
+
|
|
323
|
+
// require using Error objects as Promise rejection reasons
|
|
324
|
+
// https://eslint.org/docs/rules/prefer-promise-reject-errors
|
|
325
|
+
'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }],
|
|
326
|
+
|
|
327
|
+
// Suggest using named capture group in regular expression
|
|
328
|
+
// https://eslint.org/docs/rules/prefer-named-capture-group
|
|
329
|
+
'prefer-named-capture-group': 'off',
|
|
330
|
+
|
|
331
|
+
// https://eslint.org/docs/rules/prefer-regex-literals
|
|
332
|
+
// TODO; enable, semver-minor, once eslint v6.4 is required (which is a major)
|
|
333
|
+
'prefer-regex-literals': 'off',
|
|
334
|
+
|
|
335
|
+
// require use of the second argument for parseInt()
|
|
336
|
+
radix: 'error',
|
|
337
|
+
|
|
338
|
+
// require `await` in `async function` (note: this is a horrible rule that should never be used)
|
|
339
|
+
// https://eslint.org/docs/rules/require-await
|
|
340
|
+
'require-await': 'off',
|
|
341
|
+
|
|
342
|
+
// Enforce the use of u flag on RegExp
|
|
343
|
+
// https://eslint.org/docs/rules/require-unicode-regexp
|
|
344
|
+
'require-unicode-regexp': 'off',
|
|
345
|
+
|
|
346
|
+
// requires to declare all vars on top of their containing scope
|
|
347
|
+
'vars-on-top': 'error',
|
|
348
|
+
|
|
349
|
+
// require immediate function invocation to be wrapped in parentheses
|
|
350
|
+
// https://eslint.org/docs/rules/wrap-iife.html
|
|
351
|
+
'wrap-iife': ['error', 'outside', { functionPrototypeMethods: false }],
|
|
352
|
+
|
|
353
|
+
// require or disallow Yoda conditions
|
|
354
|
+
yoda: 'error',
|
|
355
|
+
},
|
|
356
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
rules: {
|
|
3
|
+
// Enforce “for” loop update clause moving the counter in the right direction
|
|
4
|
+
// https://eslint.org/docs/rules/for-direction
|
|
5
|
+
'for-direction': 'error',
|
|
6
|
+
|
|
7
|
+
// Enforces that a return statement is present in property getters
|
|
8
|
+
// https://eslint.org/docs/rules/getter-return
|
|
9
|
+
'getter-return': ['error', { allowImplicit: true }],
|
|
10
|
+
|
|
11
|
+
// disallow using an async function as a Promise executor
|
|
12
|
+
// https://eslint.org/docs/rules/no-async-promise-executor
|
|
13
|
+
'no-async-promise-executor': 'error',
|
|
14
|
+
|
|
15
|
+
// Disallow await inside of loops
|
|
16
|
+
// https://eslint.org/docs/rules/no-await-in-loop
|
|
17
|
+
'no-await-in-loop': 'error',
|
|
18
|
+
|
|
19
|
+
// Disallow comparisons to negative zero
|
|
20
|
+
// https://eslint.org/docs/rules/no-compare-neg-zero
|
|
21
|
+
'no-compare-neg-zero': 'error',
|
|
22
|
+
|
|
23
|
+
// disallow assignment in conditional expressions
|
|
24
|
+
'no-cond-assign': ['error', 'always'],
|
|
25
|
+
|
|
26
|
+
// disallow use of console
|
|
27
|
+
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
|
28
|
+
|
|
29
|
+
// disallow use of constant expressions in conditions
|
|
30
|
+
'no-constant-condition': 'warn',
|
|
31
|
+
|
|
32
|
+
// disallow control characters in regular expressions
|
|
33
|
+
'no-control-regex': 'error',
|
|
34
|
+
|
|
35
|
+
// disallow use of debugger
|
|
36
|
+
'no-debugger': 'error',
|
|
37
|
+
|
|
38
|
+
// disallow duplicate arguments in functions
|
|
39
|
+
'no-dupe-args': 'error',
|
|
40
|
+
|
|
41
|
+
// Disallow duplicate conditions in if-else-if chains
|
|
42
|
+
// https://eslint.org/docs/rules/no-dupe-else-if
|
|
43
|
+
// TODO: enable, semver-major
|
|
44
|
+
'no-dupe-else-if': 'off',
|
|
45
|
+
|
|
46
|
+
// disallow duplicate keys when creating object literals
|
|
47
|
+
'no-dupe-keys': 'error',
|
|
48
|
+
|
|
49
|
+
// disallow a duplicate case label.
|
|
50
|
+
'no-duplicate-case': 'error',
|
|
51
|
+
|
|
52
|
+
// disallow empty statements
|
|
53
|
+
'no-empty': 'error',
|
|
54
|
+
|
|
55
|
+
// disallow the use of empty character classes in regular expressions
|
|
56
|
+
'no-empty-character-class': 'error',
|
|
57
|
+
|
|
58
|
+
// disallow assigning to the exception in a catch block
|
|
59
|
+
'no-ex-assign': 'error',
|
|
60
|
+
|
|
61
|
+
// disallow double-negation boolean casts in a boolean context
|
|
62
|
+
// https://eslint.org/docs/rules/no-extra-boolean-cast
|
|
63
|
+
'no-extra-boolean-cast': 'error',
|
|
64
|
+
|
|
65
|
+
// disallow unnecessary parentheses
|
|
66
|
+
// https://eslint.org/docs/rules/no-extra-parens
|
|
67
|
+
'no-extra-parens': ['off', 'all', {
|
|
68
|
+
conditionalAssign: true,
|
|
69
|
+
nestedBinaryExpressions: false,
|
|
70
|
+
returnAssign: false,
|
|
71
|
+
ignoreJSX: 'all', // delegate to eslint-plugin-react
|
|
72
|
+
enforceForArrowConditionals: false,
|
|
73
|
+
}],
|
|
74
|
+
|
|
75
|
+
// disallow unnecessary semicolons
|
|
76
|
+
'no-extra-semi': 'error',
|
|
77
|
+
|
|
78
|
+
// disallow overwriting functions written as function declarations
|
|
79
|
+
'no-func-assign': 'error',
|
|
80
|
+
|
|
81
|
+
// https://eslint.org/docs/rules/no-import-assign
|
|
82
|
+
// TODO: enable, semver-minor, once eslint v6.4 is required (which is a major)
|
|
83
|
+
'no-import-assign': 'off',
|
|
84
|
+
|
|
85
|
+
// disallow function or variable declarations in nested blocks
|
|
86
|
+
'no-inner-declarations': 'error',
|
|
87
|
+
|
|
88
|
+
// disallow invalid regular expression strings in the RegExp constructor
|
|
89
|
+
'no-invalid-regexp': 'error',
|
|
90
|
+
|
|
91
|
+
// disallow irregular whitespace outside of strings and comments
|
|
92
|
+
'no-irregular-whitespace': 'error',
|
|
93
|
+
|
|
94
|
+
// Disallow characters which are made with multiple code points in character class syntax
|
|
95
|
+
// https://eslint.org/docs/rules/no-misleading-character-class
|
|
96
|
+
'no-misleading-character-class': 'error',
|
|
97
|
+
|
|
98
|
+
// disallow the use of object properties of the global object (Math and JSON) as functions
|
|
99
|
+
'no-obj-calls': 'error',
|
|
100
|
+
|
|
101
|
+
// disallow use of Object.prototypes builtins directly
|
|
102
|
+
// https://eslint.org/docs/rules/no-prototype-builtins
|
|
103
|
+
'no-prototype-builtins': 'error',
|
|
104
|
+
|
|
105
|
+
// disallow multiple spaces in a regular expression literal
|
|
106
|
+
'no-regex-spaces': 'error',
|
|
107
|
+
|
|
108
|
+
// Disallow returning values from setters
|
|
109
|
+
// https://eslint.org/docs/rules/no-setter-return
|
|
110
|
+
// TODO: enable, semver-major (altho the guide forbids getters/setters already)
|
|
111
|
+
'no-setter-return': 'off',
|
|
112
|
+
|
|
113
|
+
// disallow sparse arrays
|
|
114
|
+
'no-sparse-arrays': 'error',
|
|
115
|
+
|
|
116
|
+
// Disallow template literal placeholder syntax in regular strings
|
|
117
|
+
// https://eslint.org/docs/rules/no-template-curly-in-string
|
|
118
|
+
'no-template-curly-in-string': 'error',
|
|
119
|
+
|
|
120
|
+
// Avoid code that looks like two expressions but is actually one
|
|
121
|
+
// https://eslint.org/docs/rules/no-unexpected-multiline
|
|
122
|
+
'no-unexpected-multiline': 'error',
|
|
123
|
+
|
|
124
|
+
// disallow unreachable statements after a return, throw, continue, or break statement
|
|
125
|
+
'no-unreachable': 'error',
|
|
126
|
+
|
|
127
|
+
// disallow return/throw/break/continue inside finally blocks
|
|
128
|
+
// https://eslint.org/docs/rules/no-unsafe-finally
|
|
129
|
+
'no-unsafe-finally': 'error',
|
|
130
|
+
|
|
131
|
+
// disallow negating the left operand of relational operators
|
|
132
|
+
// https://eslint.org/docs/rules/no-unsafe-negation
|
|
133
|
+
'no-unsafe-negation': 'error',
|
|
134
|
+
// disallow negation of the left operand of an in expression
|
|
135
|
+
// deprecated in favor of no-unsafe-negation
|
|
136
|
+
'no-negated-in-lhs': 'off',
|
|
137
|
+
|
|
138
|
+
// Disallow assignments that can lead to race conditions due to usage of await or yield
|
|
139
|
+
// https://eslint.org/docs/rules/require-atomic-updates
|
|
140
|
+
// TODO: enable, semver-major
|
|
141
|
+
'require-atomic-updates': 'off',
|
|
142
|
+
|
|
143
|
+
// disallow comparisons with the value NaN
|
|
144
|
+
'use-isnan': 'error',
|
|
145
|
+
|
|
146
|
+
// ensure JSDoc comments are valid
|
|
147
|
+
// https://eslint.org/docs/rules/valid-jsdoc
|
|
148
|
+
'valid-jsdoc': 'off',
|
|
149
|
+
|
|
150
|
+
// ensure that the results of typeof are compared against a valid string
|
|
151
|
+
// https://eslint.org/docs/rules/valid-typeof
|
|
152
|
+
'valid-typeof': ['error', { requireStringLiterals: true }],
|
|
153
|
+
},
|
|
154
|
+
};
|