@msobiecki/eslint-config 8.38.2 → 8.39.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/CHANGELOG.md +31 -56
- package/README.md +73 -58
- package/eslint.config.js +209 -0
- package/jest.config.js +7 -5
- package/package.json +32 -33
- package/rules/base.js +582 -0
- package/rules/imports.js +273 -0
- package/rules/node.js +12 -0
- package/{__tests__ → tests}/base.test.js +15 -10
- package/tests/eslint.config.js +13 -0
- package/tests/test-cases/base/array-callback-return.js +2 -0
- package/tests/test-cases/base/block-scoped-var.js +40 -0
- package/tests/test-cases/base/consistent-return.js +4 -0
- package/tests/test-cases/base/curly.js +9 -0
- package/tests/test-cases/base/default-case.js +7 -0
- package/tests/test-cases/base/guard-for-in.js +4 -0
- package/tests/test-cases/base/no-alert.js +2 -0
- package/tests/test-cases/base/no-else-return.js +38 -0
- package/tests/test-cases/base/no-empty-function.js +44 -0
- package/tests/test-cases/base/no-extend-native.js +2 -0
- package/tests/test-cases/base/no-fallthrough.js +9 -0
- package/tests/test-cases/base/no-new.js +2 -0
- package/tests/test-cases/base/no-param-reassign.js +4 -0
- package/tests/test-cases/base/no-proto.js +2 -0
- package/tests/test-cases/base/no-redeclare.js +15 -0
- package/tests/test-cases/base/no-return-assign.js +4 -0
- package/tests/test-cases/base/no-script-url.js +2 -0
- package/tests/test-cases/base/no-self-compare.js +3 -0
- package/tests/test-cases/base/no-sequences.js +2 -0
- package/tests/test-cases/base/no-useless-concat.js +8 -0
- package/{__tests__ → tests}/test-cases/base/no-var.js +1 -1
- package/tests/test-cases/base/no-void.js +4 -0
- package/tests/test-cases/base/radix.js +2 -0
- package/tests/test-cases/base/yoda.js +29 -0
- package/utils/get-ts-config.js +16 -9
- package/.eslintrc.json +0 -3
- package/__tests__/.eslintrc.json +0 -3
- package/__tests__/test-cases/base/comma-dangle.js +0 -2
- package/best-practice-next.js +0 -3
- package/best-practice-react.js +0 -3
- package/best-practice.js +0 -3
- package/index.js +0 -3
- package/jest-dom.js +0 -3
- package/jest-react.js +0 -3
- package/jest.js +0 -3
- package/next.js +0 -3
- package/node.js +0 -3
- package/presets/base/base.js +0 -26
- package/presets/best-practice/best-practice-next.js +0 -12
- package/presets/best-practice/best-practice-react.js +0 -37
- package/presets/best-practice/best-practice.js +0 -38
- package/presets/jest/jest-base.js +0 -8
- package/presets/jest/jest-dom.js +0 -9
- package/presets/jest/jest-react.js +0 -8
- package/presets/next/next.js +0 -13
- package/presets/node/node.js +0 -3
- package/presets/react/react-jsx.js +0 -3
- package/presets/react/react.js +0 -35
- package/react-jsx.js +0 -3
- package/react.js +0 -3
- /package/{__tests__ → tests}/test-cases/base/camelcase.js +0 -0
- /package/{__tests__ → tests}/test-cases/base/eqeqeq.js +0 -0
- /package/{__tests__ → tests}/test-cases/base/no-console.js +0 -0
- /package/{__tests__ → tests}/test-cases/base/no-eval.js +0 -0
- /package/{__tests__ → tests}/test-cases/base/no-undef.js +0 -0
- /package/{__tests__ → tests}/test-cases/base/no-unused-vars.js +0 -0
- /package/{__tests__ → tests}/test-cases/base/prefer-const.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@msobiecki/eslint-config",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.39.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "An ESLint shareable config for JavaScript/TypeScript ecosystem's.",
|
|
6
6
|
"keywords": [
|
|
@@ -16,52 +16,51 @@
|
|
|
16
16
|
},
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"author": "Michał Sobiecki <kontakt@codeshaker.pl>",
|
|
19
|
-
"
|
|
19
|
+
"type": "module",
|
|
20
|
+
"main": "eslint.config.js",
|
|
20
21
|
"scripts": {
|
|
22
|
+
"inspect": "npx eslint --inspect-config",
|
|
21
23
|
"prepare": "husky",
|
|
22
|
-
"test": "jest",
|
|
24
|
+
"test": "NODE_OPTIONS='--experimental-vm-modules' jest",
|
|
23
25
|
"test:watch": "jest --watch"
|
|
24
26
|
},
|
|
25
27
|
"dependencies": {
|
|
26
|
-
"eslint
|
|
27
|
-
"eslint-
|
|
28
|
-
"eslint-
|
|
29
|
-
"eslint-config-prettier": "^9.1.0",
|
|
30
|
-
"eslint-plugin-compat": "^6.0.1",
|
|
31
|
-
"eslint-plugin-deprecation": "^3.0.0",
|
|
28
|
+
"@eslint/js": "^9.37.0",
|
|
29
|
+
"@next/eslint-plugin-next": "^15.5.6",
|
|
30
|
+
"eslint-plugin-compat": "^6.0.2",
|
|
32
31
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
33
|
-
"eslint-plugin-import": "^2.
|
|
34
|
-
"eslint-plugin-jest": "^
|
|
32
|
+
"eslint-plugin-import": "^2.32.0",
|
|
33
|
+
"eslint-plugin-jest": "^29.0.1",
|
|
35
34
|
"eslint-plugin-jest-dom": "^5.5.0",
|
|
36
|
-
"eslint-plugin-jsdoc": "^
|
|
35
|
+
"eslint-plugin-jsdoc": "^61.1.4",
|
|
37
36
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
38
|
-
"eslint-plugin-n": "^17.
|
|
39
|
-
"eslint-plugin-prettier": "^5.
|
|
40
|
-
"eslint-plugin-promise": "^7.1
|
|
41
|
-
"eslint-plugin-react": "^7.37.
|
|
42
|
-
"eslint-plugin-react-hooks": "^
|
|
37
|
+
"eslint-plugin-n": "^17.23.1",
|
|
38
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
39
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
40
|
+
"eslint-plugin-react": "^7.37.5",
|
|
41
|
+
"eslint-plugin-react-hooks": "^7.0.0",
|
|
43
42
|
"eslint-plugin-security": "^3.0.1",
|
|
44
|
-
"eslint-plugin-storybook": "^
|
|
45
|
-
"eslint-plugin-testing-library": "^
|
|
46
|
-
"eslint-plugin-unicorn": "^
|
|
43
|
+
"eslint-plugin-storybook": "^9.1.12",
|
|
44
|
+
"eslint-plugin-testing-library": "^7.13.3",
|
|
45
|
+
"eslint-plugin-unicorn": "^61.0.2",
|
|
46
|
+
"typescript-eslint": "^8.46.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@commitlint/cli": "^
|
|
50
|
-
"@commitlint/config-conventional": "^
|
|
49
|
+
"@commitlint/cli": "^20.1.0",
|
|
50
|
+
"@commitlint/config-conventional": "^20.0.0",
|
|
51
51
|
"@semantic-release/changelog": "^6.0.3",
|
|
52
52
|
"@semantic-release/git": "^10.0.1",
|
|
53
|
-
"@
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"prettier": "^3.3.3",
|
|
61
|
-
"semantic-release": "^24.2.7"
|
|
53
|
+
"@types/jest": "^30.0.0",
|
|
54
|
+
"eslint": "^9.37.0",
|
|
55
|
+
"husky": "^9.1.7",
|
|
56
|
+
"jest": "^30.2.0",
|
|
57
|
+
"lint-staged": "^16.2.4",
|
|
58
|
+
"prettier": "^3.6.2",
|
|
59
|
+
"semantic-release": "^25.0.0"
|
|
62
60
|
},
|
|
63
61
|
"peerDependencies": {
|
|
64
|
-
"eslint": "^
|
|
65
|
-
"prettier": "^3.0.0"
|
|
62
|
+
"eslint": "^9.0.0",
|
|
63
|
+
"prettier": "^3.0.0",
|
|
64
|
+
"typescript": "^5.0.0"
|
|
66
65
|
}
|
|
67
66
|
}
|
package/rules/base.js
ADDED
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
const baseRules = {
|
|
2
|
+
// enforce return statements in callbacks of array's methods
|
|
3
|
+
// https://eslint.org/docs/rules/array-callback-return
|
|
4
|
+
"array-callback-return": "error",
|
|
5
|
+
|
|
6
|
+
// treat var statements as if they were block scoped
|
|
7
|
+
// https://eslint.org/docs/rules/block-scoped-var
|
|
8
|
+
"block-scoped-var": "error",
|
|
9
|
+
|
|
10
|
+
// specify the maximum cyclomatic complexity allowed in a program
|
|
11
|
+
// https://eslint.org/docs/rules/complexity
|
|
12
|
+
complexity: ["off", 20],
|
|
13
|
+
|
|
14
|
+
// enforce that class methods use "this"
|
|
15
|
+
// https://eslint.org/docs/rules/class-methods-use-this
|
|
16
|
+
"class-methods-use-this": [
|
|
17
|
+
"error",
|
|
18
|
+
{
|
|
19
|
+
exceptMethods: [],
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
|
|
23
|
+
// require return statements to either always or never specify values
|
|
24
|
+
// https://eslint.org/docs/rules/consistent-return
|
|
25
|
+
"consistent-return": "error",
|
|
26
|
+
|
|
27
|
+
// specify curly brace conventions for all control statements
|
|
28
|
+
// https://eslint.org/docs/rules/curly
|
|
29
|
+
curly: ["error", "multi-line"], // multiline
|
|
30
|
+
|
|
31
|
+
// require default case in switch statements
|
|
32
|
+
// https://eslint.org/docs/rules/default-case
|
|
33
|
+
"default-case": ["error", { commentPattern: "^no default$" }],
|
|
34
|
+
|
|
35
|
+
// Enforce default clauses in switch statements to be last
|
|
36
|
+
// https://eslint.org/docs/rules/default-case-last
|
|
37
|
+
"default-case-last": "error",
|
|
38
|
+
|
|
39
|
+
// https://eslint.org/docs/rules/default-param-last
|
|
40
|
+
"default-param-last": "error",
|
|
41
|
+
|
|
42
|
+
// encourages use of dot notation whenever possible
|
|
43
|
+
// https://eslint.org/docs/rules/dot-notation
|
|
44
|
+
"dot-notation": ["error", { allowKeywords: true }],
|
|
45
|
+
|
|
46
|
+
// require the use of === and !==
|
|
47
|
+
// https://eslint.org/docs/rules/eqeqeq
|
|
48
|
+
eqeqeq: ["error", "always", { null: "ignore" }],
|
|
49
|
+
|
|
50
|
+
// Require grouped accessor pairs in object literals and classes
|
|
51
|
+
// https://eslint.org/docs/rules/grouped-accessor-pairs
|
|
52
|
+
"grouped-accessor-pairs": "error",
|
|
53
|
+
|
|
54
|
+
// make sure for-in loops have an if statement
|
|
55
|
+
// https://eslint.org/docs/rules/guard-for-in
|
|
56
|
+
"guard-for-in": "error",
|
|
57
|
+
|
|
58
|
+
// enforce a maximum number of classes per file
|
|
59
|
+
// https://eslint.org/docs/rules/max-classes-per-file
|
|
60
|
+
"max-classes-per-file": ["error", 1],
|
|
61
|
+
|
|
62
|
+
// disallow the use of alert, confirm, and prompt
|
|
63
|
+
// https://eslint.org/docs/rules/no-alert
|
|
64
|
+
"no-alert": "warn",
|
|
65
|
+
|
|
66
|
+
// disallow use of arguments.caller or arguments.callee
|
|
67
|
+
// https://eslint.org/docs/rules/no-caller
|
|
68
|
+
"no-caller": "error",
|
|
69
|
+
|
|
70
|
+
// Disallow returning value in constructor
|
|
71
|
+
// https://eslint.org/docs/rules/no-constructor-return
|
|
72
|
+
"no-constructor-return": "error",
|
|
73
|
+
|
|
74
|
+
// disallow division operators explicitly at beginning of regular expression
|
|
75
|
+
// https://eslint.org/docs/rules/no-div-regex
|
|
76
|
+
"no-div-regex": "off",
|
|
77
|
+
|
|
78
|
+
// disallow else after a return in an if
|
|
79
|
+
// https://eslint.org/docs/rules/no-else-return
|
|
80
|
+
"no-else-return": ["error", { allowElseIf: false }],
|
|
81
|
+
|
|
82
|
+
// disallow empty functions, except for standalone funcs/arrows
|
|
83
|
+
// https://eslint.org/docs/rules/no-empty-function
|
|
84
|
+
"no-empty-function": [
|
|
85
|
+
"error",
|
|
86
|
+
{
|
|
87
|
+
allow: ["arrowFunctions", "functions", "methods"],
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
|
|
91
|
+
// disallow comparisons to null without a type-checking operator
|
|
92
|
+
// https://eslint.org/docs/rules/no-eq-null
|
|
93
|
+
"no-eq-null": "off",
|
|
94
|
+
|
|
95
|
+
// disallow use of eval()
|
|
96
|
+
// https://eslint.org/docs/rules/no-eval
|
|
97
|
+
"no-eval": "error",
|
|
98
|
+
|
|
99
|
+
// disallow adding to native types
|
|
100
|
+
// https://eslint.org/docs/rules/no-extend-native
|
|
101
|
+
"no-extend-native": "error",
|
|
102
|
+
|
|
103
|
+
// disallow unnecessary function binding
|
|
104
|
+
// https://eslint.org/docs/rules/no-extra-bind
|
|
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 implicit type conversions
|
|
112
|
+
// https://eslint.org/docs/rules/no-implicit-coercion
|
|
113
|
+
"no-implicit-coercion": [
|
|
114
|
+
"off",
|
|
115
|
+
{
|
|
116
|
+
boolean: false,
|
|
117
|
+
number: true,
|
|
118
|
+
string: true,
|
|
119
|
+
allow: [],
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
|
|
123
|
+
// disallow use of eval()-like methods
|
|
124
|
+
// https://eslint.org/docs/rules/no-implied-eval
|
|
125
|
+
"no-implied-eval": "error",
|
|
126
|
+
|
|
127
|
+
// disallow usage of __iterator__ property
|
|
128
|
+
// https://eslint.org/docs/rules/no-iterator
|
|
129
|
+
"no-iterator": "error",
|
|
130
|
+
|
|
131
|
+
// disallow use of labels for anything other than loops and switches
|
|
132
|
+
// https://eslint.org/docs/rules/no-labels
|
|
133
|
+
"no-labels": ["error", { allowLoop: false, allowSwitch: false }],
|
|
134
|
+
|
|
135
|
+
// disallow unnecessary nested blocks
|
|
136
|
+
// https://eslint.org/docs/rules/no-lone-blocks
|
|
137
|
+
"no-lone-blocks": "error",
|
|
138
|
+
|
|
139
|
+
// disallow creation of functions within loops
|
|
140
|
+
// https://eslint.org/docs/rules/no-loop-func
|
|
141
|
+
"no-loop-func": "error",
|
|
142
|
+
|
|
143
|
+
// disallow use of multiline strings
|
|
144
|
+
// https://eslint.org/docs/rules/no-multi-str
|
|
145
|
+
"no-multi-str": "error",
|
|
146
|
+
|
|
147
|
+
// disallow use of new operator when not part of the assignment or comparison
|
|
148
|
+
// https://eslint.org/docs/rules/no-new
|
|
149
|
+
"no-new": "error",
|
|
150
|
+
|
|
151
|
+
// disallow use of new operator for Function object
|
|
152
|
+
// https://eslint.org/docs/rules/no-new-func
|
|
153
|
+
"no-new-func": "error",
|
|
154
|
+
|
|
155
|
+
// disallows creating new instances of String, Number, and Boolean
|
|
156
|
+
// https://eslint.org/docs/rules/no-new-wrappers
|
|
157
|
+
"no-new-wrappers": "error",
|
|
158
|
+
|
|
159
|
+
// disallow use of octal escape sequences in string literals, such as
|
|
160
|
+
// var foo = 'Copyright \251';
|
|
161
|
+
// https://eslint.org/docs/rules/no-octal-escape
|
|
162
|
+
"no-octal-escape": "error",
|
|
163
|
+
|
|
164
|
+
// disallow reassignment of function parameters
|
|
165
|
+
// disallow parameter object manipulation except for specific exclusions
|
|
166
|
+
// rule: https://eslint.org/docs/rules/no-param-reassign.html
|
|
167
|
+
"no-param-reassign": [
|
|
168
|
+
"error",
|
|
169
|
+
{
|
|
170
|
+
props: true,
|
|
171
|
+
ignorePropertyModificationsFor: [
|
|
172
|
+
"acc", // for reduce accumulators
|
|
173
|
+
"accumulator", // for reduce accumulators
|
|
174
|
+
"e", // for e.returnvalue
|
|
175
|
+
"ctx", // for Koa routing
|
|
176
|
+
"context", // for Koa routing
|
|
177
|
+
"req", // for Express requests
|
|
178
|
+
"request", // for Express requests
|
|
179
|
+
"res", // for Express responses
|
|
180
|
+
"response", // for Express responses
|
|
181
|
+
"$scope", // for Angular 1 scopes
|
|
182
|
+
"staticContext", // for ReactRouter context
|
|
183
|
+
],
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
|
|
187
|
+
// disallow usage of __proto__ property
|
|
188
|
+
// https://eslint.org/docs/rules/no-proto
|
|
189
|
+
"no-proto": "error",
|
|
190
|
+
|
|
191
|
+
// disallow certain object properties
|
|
192
|
+
// https://eslint.org/docs/rules/no-restricted-properties
|
|
193
|
+
"no-restricted-properties": [
|
|
194
|
+
"error",
|
|
195
|
+
{
|
|
196
|
+
object: "arguments",
|
|
197
|
+
property: "callee",
|
|
198
|
+
message: "arguments.callee is deprecated",
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
object: "global",
|
|
202
|
+
property: "isFinite",
|
|
203
|
+
message: "Please use Number.isFinite instead",
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
object: "self",
|
|
207
|
+
property: "isFinite",
|
|
208
|
+
message: "Please use Number.isFinite instead",
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
object: "window",
|
|
212
|
+
property: "isFinite",
|
|
213
|
+
message: "Please use Number.isFinite instead",
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
object: "global",
|
|
217
|
+
property: "isNaN",
|
|
218
|
+
message: "Please use Number.isNaN instead",
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
object: "self",
|
|
222
|
+
property: "isNaN",
|
|
223
|
+
message: "Please use Number.isNaN instead",
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
object: "window",
|
|
227
|
+
property: "isNaN",
|
|
228
|
+
message: "Please use Number.isNaN instead",
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
property: "__defineGetter__",
|
|
232
|
+
message: "Please use Object.defineProperty instead.",
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
property: "__defineSetter__",
|
|
236
|
+
message: "Please use Object.defineProperty instead.",
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
object: "Math",
|
|
240
|
+
property: "pow",
|
|
241
|
+
message: "Use the exponentiation operator (**) instead.",
|
|
242
|
+
},
|
|
243
|
+
],
|
|
244
|
+
|
|
245
|
+
// disallow use of assignment in return statement
|
|
246
|
+
// https://eslint.org/docs/rules/no-return-assign
|
|
247
|
+
"no-return-assign": ["error", "always"],
|
|
248
|
+
|
|
249
|
+
// disallow use of `javascript:` urls.
|
|
250
|
+
// https://eslint.org/docs/rules/no-script-url
|
|
251
|
+
"no-script-url": "error",
|
|
252
|
+
|
|
253
|
+
// disallow comparisons where both sides are exactly the same
|
|
254
|
+
// https://eslint.org/docs/rules/no-self-compare
|
|
255
|
+
"no-self-compare": "error",
|
|
256
|
+
|
|
257
|
+
// disallow use of comma operator
|
|
258
|
+
// https://eslint.org/docs/rules/no-sequences
|
|
259
|
+
"no-sequences": "error",
|
|
260
|
+
|
|
261
|
+
// restrict what can be thrown as an exception
|
|
262
|
+
// https://eslint.org/docs/rules/no-throw-literal
|
|
263
|
+
"no-throw-literal": "error",
|
|
264
|
+
|
|
265
|
+
// disallow usage of expressions in statement position
|
|
266
|
+
// https://eslint.org/docs/rules/no-unused-expressions
|
|
267
|
+
"no-unused-expressions": [
|
|
268
|
+
"error",
|
|
269
|
+
{
|
|
270
|
+
allowShortCircuit: false,
|
|
271
|
+
allowTernary: false,
|
|
272
|
+
allowTaggedTemplates: false,
|
|
273
|
+
},
|
|
274
|
+
],
|
|
275
|
+
|
|
276
|
+
// disallow useless string concatenation
|
|
277
|
+
// https://eslint.org/docs/rules/no-useless-concat
|
|
278
|
+
"no-useless-concat": "error",
|
|
279
|
+
|
|
280
|
+
// disallow use of void operator
|
|
281
|
+
// https://eslint.org/docs/rules/no-void
|
|
282
|
+
"no-void": "error",
|
|
283
|
+
|
|
284
|
+
// disallow usage of configurable warning terms in comments: e.g. todo
|
|
285
|
+
// https://eslint.org/docs/rules/no-warning-comments
|
|
286
|
+
"no-warning-comments": [
|
|
287
|
+
"off",
|
|
288
|
+
{ terms: ["todo", "fixme", "xxx"], location: "start" },
|
|
289
|
+
],
|
|
290
|
+
|
|
291
|
+
// require using Error objects as Promise rejection reasons
|
|
292
|
+
// https://eslint.org/docs/rules/prefer-promise-reject-errors
|
|
293
|
+
"prefer-promise-reject-errors": ["error", { allowEmptyReject: true }],
|
|
294
|
+
|
|
295
|
+
// https://eslint.org/docs/rules/prefer-regex-literals
|
|
296
|
+
"prefer-regex-literals": [
|
|
297
|
+
"error",
|
|
298
|
+
{
|
|
299
|
+
disallowRedundantWrapping: true,
|
|
300
|
+
},
|
|
301
|
+
],
|
|
302
|
+
|
|
303
|
+
// require use of the second argument for parseInt()
|
|
304
|
+
// https://eslint.org/docs/rules/radix
|
|
305
|
+
radix: "error",
|
|
306
|
+
|
|
307
|
+
// requires to declare all vars on top of their containing scope
|
|
308
|
+
// https://eslint.org/docs/rules/vars-on-top
|
|
309
|
+
"vars-on-top": "error",
|
|
310
|
+
|
|
311
|
+
// require or disallow Yoda conditions
|
|
312
|
+
// https://eslint.org/docs/rules/yoda
|
|
313
|
+
yoda: "error",
|
|
314
|
+
|
|
315
|
+
// Disallow await inside of loops
|
|
316
|
+
// https://eslint.org/docs/rules/no-await-in-loop
|
|
317
|
+
"no-await-in-loop": "error",
|
|
318
|
+
|
|
319
|
+
// disallow use of console
|
|
320
|
+
"no-console": "warn",
|
|
321
|
+
|
|
322
|
+
// disallow function or variable declarations in nested blocks
|
|
323
|
+
"no-inner-declarations": "error",
|
|
324
|
+
|
|
325
|
+
// Disallow returning values from Promise executor functions
|
|
326
|
+
// https://eslint.org/docs/rules/no-promise-executor-return
|
|
327
|
+
"no-promise-executor-return": "error",
|
|
328
|
+
|
|
329
|
+
// Disallow template literal placeholder syntax in regular strings
|
|
330
|
+
// https://eslint.org/docs/rules/no-template-curly-in-string
|
|
331
|
+
"no-template-curly-in-string": "error",
|
|
332
|
+
|
|
333
|
+
// Disallow loops with a body that allows only one iteration
|
|
334
|
+
// https://eslint.org/docs/rules/no-unreachable-loop
|
|
335
|
+
"no-unreachable-loop": [
|
|
336
|
+
"error",
|
|
337
|
+
{
|
|
338
|
+
ignore: [], // WhileStatement, DoWhileStatement, ForStatement, ForInStatement, ForOfStatement
|
|
339
|
+
},
|
|
340
|
+
],
|
|
341
|
+
|
|
342
|
+
// ensure that the results of typeof are compared against a valid string
|
|
343
|
+
// https://eslint.org/docs/rules/valid-typeof
|
|
344
|
+
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
345
|
+
|
|
346
|
+
// enforces no braces where they can be omitted
|
|
347
|
+
// https://eslint.org/docs/rules/arrow-body-style
|
|
348
|
+
// TODO: enable requireReturnForObjectLiteral?
|
|
349
|
+
"arrow-body-style": [
|
|
350
|
+
"error",
|
|
351
|
+
"as-needed",
|
|
352
|
+
{
|
|
353
|
+
requireReturnForObjectLiteral: false,
|
|
354
|
+
},
|
|
355
|
+
],
|
|
356
|
+
|
|
357
|
+
// Disallow specified names in exports
|
|
358
|
+
// https://eslint.org/docs/rules/no-restricted-exports
|
|
359
|
+
"no-restricted-exports": [
|
|
360
|
+
"error",
|
|
361
|
+
{
|
|
362
|
+
restrictedNamedExports: [
|
|
363
|
+
"default", // use `export default` to provide a default export
|
|
364
|
+
"then", // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
|
|
365
|
+
],
|
|
366
|
+
},
|
|
367
|
+
],
|
|
368
|
+
|
|
369
|
+
// disallow useless computed property keys
|
|
370
|
+
// https://eslint.org/docs/rules/no-useless-computed-key
|
|
371
|
+
"no-useless-computed-key": "error",
|
|
372
|
+
|
|
373
|
+
// disallow unnecessary constructor
|
|
374
|
+
// https://eslint.org/docs/rules/no-useless-constructor
|
|
375
|
+
"no-useless-constructor": "error",
|
|
376
|
+
|
|
377
|
+
// disallow renaming import, export, and destructured assignments to the same name
|
|
378
|
+
// https://eslint.org/docs/rules/no-useless-rename
|
|
379
|
+
"no-useless-rename": [
|
|
380
|
+
"error",
|
|
381
|
+
{
|
|
382
|
+
ignoreDestructuring: false,
|
|
383
|
+
ignoreImport: false,
|
|
384
|
+
ignoreExport: false,
|
|
385
|
+
},
|
|
386
|
+
],
|
|
387
|
+
|
|
388
|
+
// require let or const instead of var
|
|
389
|
+
"no-var": "error",
|
|
390
|
+
|
|
391
|
+
// require method and property shorthand syntax for object literals
|
|
392
|
+
// https://eslint.org/docs/rules/object-shorthand
|
|
393
|
+
"object-shorthand": [
|
|
394
|
+
"error",
|
|
395
|
+
"always",
|
|
396
|
+
{
|
|
397
|
+
ignoreConstructors: false,
|
|
398
|
+
avoidQuotes: true,
|
|
399
|
+
},
|
|
400
|
+
],
|
|
401
|
+
|
|
402
|
+
// suggest using arrow functions as callbacks
|
|
403
|
+
"prefer-arrow-callback": [
|
|
404
|
+
"error",
|
|
405
|
+
{
|
|
406
|
+
allowNamedFunctions: false,
|
|
407
|
+
allowUnboundThis: true,
|
|
408
|
+
},
|
|
409
|
+
],
|
|
410
|
+
|
|
411
|
+
// suggest using of const declaration for variables that are never modified after declared
|
|
412
|
+
"prefer-const": [
|
|
413
|
+
"error",
|
|
414
|
+
{
|
|
415
|
+
destructuring: "any",
|
|
416
|
+
ignoreReadBeforeAssign: true,
|
|
417
|
+
},
|
|
418
|
+
],
|
|
419
|
+
|
|
420
|
+
// Prefer destructuring from arrays and objects
|
|
421
|
+
// https://eslint.org/docs/rules/prefer-destructuring
|
|
422
|
+
"prefer-destructuring": [
|
|
423
|
+
"error",
|
|
424
|
+
{
|
|
425
|
+
VariableDeclarator: {
|
|
426
|
+
array: false,
|
|
427
|
+
object: true,
|
|
428
|
+
},
|
|
429
|
+
AssignmentExpression: {
|
|
430
|
+
array: true,
|
|
431
|
+
object: false,
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
enforceForRenamedProperties: false,
|
|
436
|
+
},
|
|
437
|
+
],
|
|
438
|
+
|
|
439
|
+
// disallow parseInt() in favor of binary, octal, and hexadecimal literals
|
|
440
|
+
// https://eslint.org/docs/rules/prefer-numeric-literals
|
|
441
|
+
"prefer-numeric-literals": "error",
|
|
442
|
+
|
|
443
|
+
// use rest parameters instead of arguments
|
|
444
|
+
// https://eslint.org/docs/rules/prefer-rest-params
|
|
445
|
+
"prefer-rest-params": "error",
|
|
446
|
+
|
|
447
|
+
// suggest using the spread syntax instead of .apply()
|
|
448
|
+
// https://eslint.org/docs/rules/prefer-spread
|
|
449
|
+
"prefer-spread": "error",
|
|
450
|
+
|
|
451
|
+
// suggest using template literals instead of string concatenation
|
|
452
|
+
// https://eslint.org/docs/rules/prefer-template
|
|
453
|
+
"prefer-template": "error",
|
|
454
|
+
|
|
455
|
+
// require a Symbol description
|
|
456
|
+
// https://eslint.org/docs/rules/symbol-description
|
|
457
|
+
"symbol-description": "error",
|
|
458
|
+
|
|
459
|
+
// require camel case names
|
|
460
|
+
camelcase: ["error", { properties: "never", ignoreDestructuring: false }],
|
|
461
|
+
|
|
462
|
+
// enforce or disallow capitalization of the first letter of a comment
|
|
463
|
+
// https://eslint.org/docs/rules/capitalized-comments
|
|
464
|
+
"capitalized-comments": [
|
|
465
|
+
"off",
|
|
466
|
+
"never",
|
|
467
|
+
{
|
|
468
|
+
line: {
|
|
469
|
+
ignorePattern: ".*",
|
|
470
|
+
ignoreInlineComments: true,
|
|
471
|
+
ignoreConsecutiveComments: true,
|
|
472
|
+
},
|
|
473
|
+
block: {
|
|
474
|
+
ignorePattern: ".*",
|
|
475
|
+
ignoreInlineComments: true,
|
|
476
|
+
ignoreConsecutiveComments: true,
|
|
477
|
+
},
|
|
478
|
+
},
|
|
479
|
+
],
|
|
480
|
+
|
|
481
|
+
// require function expressions to have a name
|
|
482
|
+
// https://eslint.org/docs/rules/func-names
|
|
483
|
+
"func-names": "warn",
|
|
484
|
+
|
|
485
|
+
// require a capital letter for constructors
|
|
486
|
+
"new-cap": [
|
|
487
|
+
"error",
|
|
488
|
+
{
|
|
489
|
+
newIsCap: true,
|
|
490
|
+
newIsCapExceptions: [],
|
|
491
|
+
capIsNew: false,
|
|
492
|
+
capIsNewExceptions: ["Immutable.Map", "Immutable.Set", "Immutable.List"],
|
|
493
|
+
},
|
|
494
|
+
],
|
|
495
|
+
|
|
496
|
+
// disallow use of the Array constructor
|
|
497
|
+
"no-array-constructor": "error",
|
|
498
|
+
|
|
499
|
+
// disallow use of bitwise operators
|
|
500
|
+
// https://eslint.org/docs/rules/no-bitwise
|
|
501
|
+
"no-bitwise": "error",
|
|
502
|
+
|
|
503
|
+
// disallow use of the continue statement
|
|
504
|
+
// https://eslint.org/docs/rules/no-continue
|
|
505
|
+
"no-continue": "error",
|
|
506
|
+
|
|
507
|
+
// disallow if as the only statement in an else block
|
|
508
|
+
// https://eslint.org/docs/rules/no-lonely-if
|
|
509
|
+
"no-lonely-if": "error",
|
|
510
|
+
|
|
511
|
+
// disallow use of chained assignment expressions
|
|
512
|
+
// https://eslint.org/docs/rules/no-multi-assign
|
|
513
|
+
"no-multi-assign": ["error"],
|
|
514
|
+
|
|
515
|
+
// disallow use of unary operators, ++ and --
|
|
516
|
+
// https://eslint.org/docs/rules/no-plusplus
|
|
517
|
+
"no-plusplus": "error",
|
|
518
|
+
|
|
519
|
+
// disallow certain syntax forms
|
|
520
|
+
// https://eslint.org/docs/rules/no-restricted-syntax
|
|
521
|
+
"no-restricted-syntax": [
|
|
522
|
+
"error",
|
|
523
|
+
{
|
|
524
|
+
selector: "ForInStatement",
|
|
525
|
+
message:
|
|
526
|
+
"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.",
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
selector: "ForOfStatement",
|
|
530
|
+
message:
|
|
531
|
+
"iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.",
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
selector: "LabeledStatement",
|
|
535
|
+
message:
|
|
536
|
+
"Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.",
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
selector: "WithStatement",
|
|
540
|
+
message:
|
|
541
|
+
"`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
|
|
542
|
+
},
|
|
543
|
+
],
|
|
544
|
+
|
|
545
|
+
// disallow dangling underscores in identifiers
|
|
546
|
+
// https://eslint.org/docs/rules/no-underscore-dangle
|
|
547
|
+
"no-underscore-dangle": [
|
|
548
|
+
"error",
|
|
549
|
+
{
|
|
550
|
+
allow: [],
|
|
551
|
+
allowAfterThis: false,
|
|
552
|
+
allowAfterSuper: false,
|
|
553
|
+
enforceInMethodNames: true,
|
|
554
|
+
},
|
|
555
|
+
],
|
|
556
|
+
|
|
557
|
+
// disallow the use of Boolean literals in conditional expressions
|
|
558
|
+
// also, prefer `a || b` over `a ? a : b`
|
|
559
|
+
// https://eslint.org/docs/rules/no-unneeded-ternary
|
|
560
|
+
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
561
|
+
|
|
562
|
+
// allow just one var statement per function
|
|
563
|
+
"one-var": ["error", "never"],
|
|
564
|
+
|
|
565
|
+
// require assignment operator shorthand where possible or prohibit it entirely
|
|
566
|
+
// https://eslint.org/docs/rules/operator-assignment
|
|
567
|
+
"operator-assignment": ["error", "always"],
|
|
568
|
+
|
|
569
|
+
// Disallow the use of Math.pow in favor of the ** operator
|
|
570
|
+
// https://eslint.org/docs/rules/prefer-exponentiation-operator
|
|
571
|
+
"prefer-exponentiation-operator": "error",
|
|
572
|
+
|
|
573
|
+
// Prefer use of an object spread over Object.assign
|
|
574
|
+
// https://eslint.org/docs/rules/prefer-object-spread
|
|
575
|
+
"prefer-object-spread": "error",
|
|
576
|
+
|
|
577
|
+
// require or disallow the Unicode Byte Order Mark
|
|
578
|
+
// https://eslint.org/docs/rules/unicode-bom
|
|
579
|
+
"unicode-bom": ["error", "never"],
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
export default baseRules;
|