eslint-config-isaacscript 3.3.0 → 3.4.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/README.md +27 -1
- package/base-eslint.js +284 -0
- package/{jsdoc.js → base-jsdoc.js} +1 -0
- package/base-typescript-eslint.js +221 -0
- package/base.js +128 -288
- package/mod.js +1 -0
- package/monorepo.js +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,6 +4,32 @@
|
|
|
4
4
|
|
|
5
5
|
This is a sharable configuration for ESLint that is intended to be used in TypeScript and IsaacScript projects.
|
|
6
6
|
|
|
7
|
-
This package is consumed by the [`isaacscript-lint`](https://github.com/IsaacScript/isaacscript/tree/main/packages/isaacscript-lint) meta-linting package.
|
|
7
|
+
This package is consumed by the [`isaacscript-lint`](https://github.com/IsaacScript/isaacscript/tree/main/packages/isaacscript-lint) meta-linting package. It is recommended that instead of consuming this package directly, you instead list `isaacscript-lint` as a dependency, as it includes all of the corresponding plugins and so on.
|
|
8
|
+
|
|
9
|
+
For TypeScript projects, set up your `.eslintrc.cjs` file to extend from the config like this:
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
// This is the configuration file for ESLint, the TypeScript linter:
|
|
13
|
+
// https://eslint.org/docs/user-guide/configuring
|
|
14
|
+
module.exports = {
|
|
15
|
+
extends: [
|
|
16
|
+
// The linter base is the shared IsaacScript config:
|
|
17
|
+
// https://github.com/IsaacScript/isaacscript/blob/main/packages/eslint-config-isaacscript/base.js
|
|
18
|
+
"eslint-config-isaacscript/base",
|
|
19
|
+
],
|
|
20
|
+
|
|
21
|
+
// Don't bother linting the compiled output.
|
|
22
|
+
ignorePatterns: ["**/dist/**"],
|
|
23
|
+
|
|
24
|
+
parserOptions: {
|
|
25
|
+
// ESLint needs to know about the project's TypeScript settings in order for TypeScript-specific
|
|
26
|
+
// things to lint correctly. We do not point this at "./tsconfig.json" because certain files
|
|
27
|
+
// (such at this file) should be linted but not included in the actual project output.
|
|
28
|
+
project: "./tsconfig.eslint.json",
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
rules: {},
|
|
32
|
+
};
|
|
33
|
+
```
|
|
8
34
|
|
|
9
35
|
Please see the [IsaacScript webpage](https://isaacscript.github.io/) for more information.
|
package/base-eslint.js
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
// This is a shared configuration file for ESLint:
|
|
2
|
+
// https://eslint.org/docs/latest/user-guide/configuring
|
|
3
|
+
// This config only contains modifications to the built-in rules from the ESLint tool.
|
|
4
|
+
module.exports = {
|
|
5
|
+
rules: {
|
|
6
|
+
/**
|
|
7
|
+
* Documentation:
|
|
8
|
+
* https://eslint.org/docs/latest/rules/array-callback-return
|
|
9
|
+
*
|
|
10
|
+
* Defined at:
|
|
11
|
+
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/best-practices.js
|
|
12
|
+
*
|
|
13
|
+
* Airbnb changes the default options for some reason, which makes the rule less strict.
|
|
14
|
+
*/
|
|
15
|
+
"array-callback-return": ["warn", {}],
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Documentation:
|
|
19
|
+
* https://eslint.org/docs/latest/rules/consistent-return
|
|
20
|
+
*
|
|
21
|
+
* Defined at:
|
|
22
|
+
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/best-practices.js
|
|
23
|
+
*
|
|
24
|
+
* We prefer the "noImplicitReturns" compiler flag over the "consistent-return" ESLint rule,
|
|
25
|
+
* since it is type-aware:
|
|
26
|
+
* https://github.com/typescript-eslint/typescript-eslint/issues/5254
|
|
27
|
+
*/
|
|
28
|
+
"consistent-return": ["off"],
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Documentation:
|
|
32
|
+
* https://eslint.org/docs/latest/rules/curly
|
|
33
|
+
*
|
|
34
|
+
* Defined at:
|
|
35
|
+
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/best-practices.js
|
|
36
|
+
*
|
|
37
|
+
* Always requiring curly braces can partially ward against Apple-style if statement bugs:
|
|
38
|
+
* https://www.imperialviolet.org/2014/02/22/applebug.html
|
|
39
|
+
*
|
|
40
|
+
* Additionally, this rule needs to be set to "all" to work properly with
|
|
41
|
+
* `eslint-prettier-config`:
|
|
42
|
+
* https://github.com/prettier/eslint-config-prettier#curly
|
|
43
|
+
*/
|
|
44
|
+
curly: ["warn", "all"],
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Documentation:
|
|
48
|
+
* https://eslint.org/docs/latest/rules/default-case
|
|
49
|
+
*
|
|
50
|
+
* Defined at:
|
|
51
|
+
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/best-practices.js
|
|
52
|
+
*
|
|
53
|
+
* This rule is generally bad to have on in TypeScript projects:
|
|
54
|
+
* https://github.com/typescript-eslint/typescript-eslint/issues/5254
|
|
55
|
+
*/
|
|
56
|
+
"default-case": "off",
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Documentation:
|
|
60
|
+
* https://eslint.org/docs/latest/rules/no-console
|
|
61
|
+
*
|
|
62
|
+
* Defined at:
|
|
63
|
+
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/errors.js
|
|
64
|
+
*
|
|
65
|
+
* Command-line programs commonly write to standard out and standard error.
|
|
66
|
+
*/
|
|
67
|
+
"no-console": "off",
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Documentation:
|
|
71
|
+
* https://eslint.org/docs/latest/rules/no-constant-binary-expression
|
|
72
|
+
*
|
|
73
|
+
* Not defined in parent configs.
|
|
74
|
+
*
|
|
75
|
+
* This rule was released in 2022 and is known to catch many subtle bugs:
|
|
76
|
+
* https://github.com/eslint/eslint.org/pull/240/files
|
|
77
|
+
*/
|
|
78
|
+
"no-constant-binary-expression": "warn",
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Documentation:
|
|
82
|
+
* https://eslint.org/docs/latest/rules/no-continue
|
|
83
|
+
*
|
|
84
|
+
* Defined at:
|
|
85
|
+
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/style.js
|
|
86
|
+
*
|
|
87
|
+
* Proper use of continues can reduce indentation for long blocks of code.
|
|
88
|
+
*/
|
|
89
|
+
"no-continue": "off",
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Documentation:
|
|
93
|
+
* https://eslint.org/docs/latest/rules/no-plusplus
|
|
94
|
+
*
|
|
95
|
+
* Defined at:
|
|
96
|
+
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/style.js
|
|
97
|
+
*
|
|
98
|
+
* Airbnb disallows these because it can lead to errors with minified code. When using Prettier,
|
|
99
|
+
* it adds semi-colons everywhere, so we don't have to worry about this.
|
|
100
|
+
*/
|
|
101
|
+
"no-plusplus": "off",
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Documentation:
|
|
105
|
+
* https://eslint.org/docs/latest/rules/no-restricted-syntax
|
|
106
|
+
*
|
|
107
|
+
* Defined at:
|
|
108
|
+
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/style.js
|
|
109
|
+
*
|
|
110
|
+
* - We move the selector for "for..of" loops, since they are commonly used.
|
|
111
|
+
* - We add a selector for "empty" invocations of the "array.push()" method.
|
|
112
|
+
*/
|
|
113
|
+
"no-restricted-syntax": [
|
|
114
|
+
"warn",
|
|
115
|
+
{
|
|
116
|
+
selector: "ForInStatement",
|
|
117
|
+
message:
|
|
118
|
+
"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.",
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
selector: "LabeledStatement",
|
|
122
|
+
message:
|
|
123
|
+
"Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.",
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
selector: "WithStatement",
|
|
127
|
+
message:
|
|
128
|
+
"`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
selector:
|
|
132
|
+
"CallExpression[callee.property.name='push'][arguments.length=0]",
|
|
133
|
+
message: "push must always be called with at least one argument.",
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Documentation:
|
|
139
|
+
* https://eslint.org/docs/latest/rules/no-unused-expressions
|
|
140
|
+
*
|
|
141
|
+
* Not defined in parent configs.
|
|
142
|
+
*
|
|
143
|
+
* An unused expression which has no effect on the state of the program indicates a logic error.
|
|
144
|
+
*/
|
|
145
|
+
"no-unused-expressions": "warn",
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Documentation:
|
|
149
|
+
* https://eslint.org/docs/latest/rules/prefer-destructuring
|
|
150
|
+
*
|
|
151
|
+
* Defined at:
|
|
152
|
+
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/es6.js
|
|
153
|
+
*
|
|
154
|
+
* Array destructuring can result in non-intuitive code.
|
|
155
|
+
*/
|
|
156
|
+
"prefer-destructuring": [
|
|
157
|
+
"warn",
|
|
158
|
+
{
|
|
159
|
+
VariableDeclarator: {
|
|
160
|
+
array: false,
|
|
161
|
+
object: true,
|
|
162
|
+
},
|
|
163
|
+
AssignmentExpression: {
|
|
164
|
+
array: false,
|
|
165
|
+
object: false,
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
|
|
170
|
+
// "constructor-super" is disabled due to conflicting with the TypeScript compiler:
|
|
171
|
+
// https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
172
|
+
|
|
173
|
+
// "for-direction" is enabled here:
|
|
174
|
+
// https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/errors.js
|
|
175
|
+
|
|
176
|
+
// "getter-return" is disabled due to conflicting with the TypeScript compiler:
|
|
177
|
+
// https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
178
|
+
|
|
179
|
+
// "no-async-promise-executor"
|
|
180
|
+
|
|
181
|
+
// "no-await-in-loop"
|
|
182
|
+
|
|
183
|
+
// "no-class-assign"
|
|
184
|
+
|
|
185
|
+
// "no-compare-neg-zero"
|
|
186
|
+
|
|
187
|
+
// "no-cond-assign"
|
|
188
|
+
|
|
189
|
+
// "no-const-assign" is disabled due to conflicting with the TypeScript compiler:
|
|
190
|
+
// https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
191
|
+
|
|
192
|
+
// "no-constant-binary-expression"
|
|
193
|
+
|
|
194
|
+
// "no-constant-condition"
|
|
195
|
+
|
|
196
|
+
// "no-constructor-return"
|
|
197
|
+
|
|
198
|
+
// "no-control-regex"
|
|
199
|
+
|
|
200
|
+
// "no-debugger"
|
|
201
|
+
|
|
202
|
+
// "no-dupe-args" is disabled due to conflicting with the TypeScript compiler:
|
|
203
|
+
// https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
204
|
+
|
|
205
|
+
// "no-dupe-class-members" is disabled due to conflicting with the TypeScript compiler:
|
|
206
|
+
// https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
207
|
+
|
|
208
|
+
// "no-dupe-else-if"
|
|
209
|
+
|
|
210
|
+
// "no-dupe-keys" is disabled due to conflicting with the TypeScript compiler:
|
|
211
|
+
// https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
212
|
+
|
|
213
|
+
// "no-duplicate-case"
|
|
214
|
+
|
|
215
|
+
// "no-duplicate-imports"
|
|
216
|
+
|
|
217
|
+
// "no-empty-character-class"
|
|
218
|
+
|
|
219
|
+
// "no-empty-pattern"
|
|
220
|
+
|
|
221
|
+
// "no-ex-assign"
|
|
222
|
+
|
|
223
|
+
// "no-fallthrough"
|
|
224
|
+
|
|
225
|
+
// "no-func-assign" is disabled due to conflicting with the TypeScript compiler:
|
|
226
|
+
// https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
227
|
+
|
|
228
|
+
// "no-import-assign" is disabled due to conflicting with the TypeScript compiler:
|
|
229
|
+
// https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
230
|
+
|
|
231
|
+
// "no-inner-declarations"
|
|
232
|
+
|
|
233
|
+
// "no-invalid-regexp"
|
|
234
|
+
|
|
235
|
+
// "no-irregular-whitespace"
|
|
236
|
+
|
|
237
|
+
// "no-loss-of-precision"
|
|
238
|
+
|
|
239
|
+
// "no-misleading-character-class"
|
|
240
|
+
|
|
241
|
+
// "no-new-native-nonconstructor"
|
|
242
|
+
|
|
243
|
+
// "no-new-symbol" is disabled due to conflicting with the TypeScript compiler:
|
|
244
|
+
// https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
245
|
+
|
|
246
|
+
// "no-obj-calls" is disabled due to conflicting with the TypeScript compiler:
|
|
247
|
+
// https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
248
|
+
|
|
249
|
+
// "no-promise-executor-return"
|
|
250
|
+
|
|
251
|
+
// "no-prototype-builtins"
|
|
252
|
+
|
|
253
|
+
// "no-self-assign"
|
|
254
|
+
|
|
255
|
+
// "no-self-compare"
|
|
256
|
+
|
|
257
|
+
// "no-setter-return"
|
|
258
|
+
|
|
259
|
+
// "no-sparse-arrays"
|
|
260
|
+
|
|
261
|
+
// "no-template-curly-in-string"
|
|
262
|
+
|
|
263
|
+
// "no-redeclare" is disabled due to conflicting with the TypeScript compiler:
|
|
264
|
+
// https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
265
|
+
|
|
266
|
+
// "no-setter-return" is disabled due to conflicting with the TypeScript compiler:
|
|
267
|
+
// https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
268
|
+
|
|
269
|
+
// "no-this-before-super" is disabled due to conflicting with the TypeScript compiler:
|
|
270
|
+
// https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
271
|
+
|
|
272
|
+
// "no-undef" is disabled due to conflicting with the TypeScript compiler:
|
|
273
|
+
// https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
274
|
+
|
|
275
|
+
// "no-unreachable" is disabled due to conflicting with the TypeScript compiler:
|
|
276
|
+
// https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
277
|
+
|
|
278
|
+
// "no-unsafe-negation" is disabled due to conflicting with the TypeScript compiler:
|
|
279
|
+
// https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
280
|
+
|
|
281
|
+
// "valid-typeof" is disabled due to conflicting with the TypeScript compiler:
|
|
282
|
+
// https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
283
|
+
},
|
|
284
|
+
};
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// This is a shared configuration file for ESLint:
|
|
2
|
+
// https://eslint.org/docs/latest/user-guide/configuring
|
|
3
|
+
// This config only contains modifications to the built-in rules from the "@typescript-eslint"
|
|
4
|
+
// plugin.
|
|
5
|
+
module.exports = {
|
|
6
|
+
rules: {
|
|
7
|
+
/**
|
|
8
|
+
* Documentation:
|
|
9
|
+
* https://typescript-eslint.io/rules/array-type
|
|
10
|
+
*
|
|
11
|
+
* Not defined in the parent configs.
|
|
12
|
+
*
|
|
13
|
+
* Prefer the "string[]" syntax over "Array<string>".
|
|
14
|
+
*/
|
|
15
|
+
"@typescript-eslint/array-type": [
|
|
16
|
+
"warn",
|
|
17
|
+
{
|
|
18
|
+
default: "array-simple",
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Documentation:
|
|
24
|
+
* https://typescript-eslint.io/rules/explicit-module-boundary-types
|
|
25
|
+
*
|
|
26
|
+
* Not defined in the parent configs.
|
|
27
|
+
*
|
|
28
|
+
* Specifying explicit return types can help prevent bugs, but only require it on exported
|
|
29
|
+
* functions.
|
|
30
|
+
*/
|
|
31
|
+
"@typescript-eslint/explicit-module-boundary-types": "warn",
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Documentation:
|
|
35
|
+
* https://typescript-eslint.io/rules/lines-between-class-members
|
|
36
|
+
*
|
|
37
|
+
* Defined at:
|
|
38
|
+
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/style.js
|
|
39
|
+
*
|
|
40
|
+
* Airbnb has "exceptAfterSingleLine" turned off by default. A list of single-line variable
|
|
41
|
+
* declarations at the top of a class is common in TypeScript.
|
|
42
|
+
*/
|
|
43
|
+
"@typescript-eslint/lines-between-class-members": [
|
|
44
|
+
"warn",
|
|
45
|
+
"always",
|
|
46
|
+
{
|
|
47
|
+
exceptAfterSingleLine: true,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Documentation:
|
|
53
|
+
* https://typescript-eslint.io/rules/naming-convention
|
|
54
|
+
*
|
|
55
|
+
* Defined at:
|
|
56
|
+
* https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
57
|
+
*
|
|
58
|
+
* Modify the Airbnb config to allow for a leading underscore, which signifies that it is
|
|
59
|
+
* temporarily not being used.
|
|
60
|
+
*/
|
|
61
|
+
"@typescript-eslint/naming-convention": [
|
|
62
|
+
"warn",
|
|
63
|
+
// Allow camelCase variables (23.2), PascalCase variables (23.8), and UPPER_CASE variables
|
|
64
|
+
// (23.10).
|
|
65
|
+
{
|
|
66
|
+
selector: "variable",
|
|
67
|
+
format: ["camelCase", "PascalCase", "UPPER_CASE"],
|
|
68
|
+
leadingUnderscore: "allow",
|
|
69
|
+
},
|
|
70
|
+
// Allow camelCase functions (23.2), and PascalCase functions (23.8).
|
|
71
|
+
{
|
|
72
|
+
selector: "function",
|
|
73
|
+
format: ["camelCase", "PascalCase"],
|
|
74
|
+
leadingUnderscore: "allow",
|
|
75
|
+
},
|
|
76
|
+
// Airbnb recommends PascalCase for classes (23.3), and although Airbnb does not make
|
|
77
|
+
// TypeScript recommendations, we are assuming this rule would similarly apply to anything
|
|
78
|
+
// "type like", including interfaces, type aliases, and enums.
|
|
79
|
+
{
|
|
80
|
+
selector: "typeLike",
|
|
81
|
+
format: ["PascalCase"],
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Documentation:
|
|
87
|
+
* https://typescript-eslint.io/rules/no-unnecessary-boolean-literal-compare
|
|
88
|
+
*
|
|
89
|
+
* Not defined in the parent configs.
|
|
90
|
+
*
|
|
91
|
+
* This prevents useless code after refactoring variables to pure booleans.
|
|
92
|
+
*/
|
|
93
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn",
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Documentation:
|
|
97
|
+
* https://typescript-eslint.io/rules/no-unused-vars
|
|
98
|
+
*
|
|
99
|
+
* Defined at:
|
|
100
|
+
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/variables.js
|
|
101
|
+
*
|
|
102
|
+
* We want to lint unused arguments (the default is "after-used"). We also want to ignore
|
|
103
|
+
* arguments/variables that start with an underscore. This matches the behavior of the
|
|
104
|
+
* TypeScript compiler flag "--noUnusedLocals".
|
|
105
|
+
*/
|
|
106
|
+
"@typescript-eslint/no-unused-vars": [
|
|
107
|
+
"warn",
|
|
108
|
+
{
|
|
109
|
+
args: "all",
|
|
110
|
+
argsIgnorePattern: "^_",
|
|
111
|
+
varsIgnorePattern: "^_",
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Documentation:
|
|
117
|
+
* https://typescript-eslint.io/rules/no-use-before-define
|
|
118
|
+
*
|
|
119
|
+
* Defined at:
|
|
120
|
+
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/variables.js
|
|
121
|
+
*
|
|
122
|
+
* This allows code to be structured in a more logical order.
|
|
123
|
+
*/
|
|
124
|
+
"@typescript-eslint/no-use-before-define": "off",
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Documentation:
|
|
128
|
+
* https://typescript-eslint.io/rules/prefer-optional-chain
|
|
129
|
+
*
|
|
130
|
+
* Defined at:
|
|
131
|
+
* https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/strict.ts
|
|
132
|
+
*
|
|
133
|
+
* This can modify the type of boolean declarations to "boolean | undefined", which is undesired
|
|
134
|
+
* in some circumstances:
|
|
135
|
+
* https://github.com/typescript-eslint/typescript-eslint/issues/5269
|
|
136
|
+
*/
|
|
137
|
+
"@typescript-eslint/prefer-optional-chain": "off",
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Documentation:
|
|
141
|
+
* https://typescript-eslint.io/rules/quotes
|
|
142
|
+
*
|
|
143
|
+
* Defined at:
|
|
144
|
+
* https://github.com/prettier/eslint-config-prettier/blob/main/%40typescript-eslint.js
|
|
145
|
+
*
|
|
146
|
+
* In order to forbid unnecessary backticks, we must re-enable the "@typescript-eslint/quotes"
|
|
147
|
+
* rule as specified in the eslint-config-prettier documentation:
|
|
148
|
+
* https://github.com/prettier/eslint-config-prettier#enforce-backticks
|
|
149
|
+
*/
|
|
150
|
+
"@typescript-eslint/quotes": [
|
|
151
|
+
"warn",
|
|
152
|
+
"double",
|
|
153
|
+
{
|
|
154
|
+
avoidEscape: true,
|
|
155
|
+
allowTemplateLiterals: false,
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Documentation:
|
|
161
|
+
* https://typescript-eslint.io/rules/restrict-template-expressions
|
|
162
|
+
*
|
|
163
|
+
* Defined at:
|
|
164
|
+
* https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts
|
|
165
|
+
*
|
|
166
|
+
* This rule disallows booleans and nulls in template expressions. However, a common use-case of
|
|
167
|
+
* template strings is to coerce everything to a string.
|
|
168
|
+
*/
|
|
169
|
+
"@typescript-eslint/restrict-template-expressions": "off",
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Documentation:
|
|
173
|
+
* https://typescript-eslint.io/rules/strict-boolean-expressions
|
|
174
|
+
*
|
|
175
|
+
* Not defined in the parent configs.
|
|
176
|
+
*
|
|
177
|
+
* This rule prevents bugs when refactoring a boolean to a number.
|
|
178
|
+
*/
|
|
179
|
+
"@typescript-eslint/strict-boolean-expressions": [
|
|
180
|
+
"warn",
|
|
181
|
+
{
|
|
182
|
+
allowString: false,
|
|
183
|
+
allowNumber: false,
|
|
184
|
+
allowNullableObject: false,
|
|
185
|
+
allowNullableBoolean: false,
|
|
186
|
+
allowNullableString: false,
|
|
187
|
+
allowNullableNumber: false,
|
|
188
|
+
allowAny: false,
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Documentation:
|
|
194
|
+
* https://typescript-eslint.io/rules/switch-exhaustiveness-check/
|
|
195
|
+
*
|
|
196
|
+
* Not defined in the parent configs.
|
|
197
|
+
*
|
|
198
|
+
* This rule ensures type-safety with switch statements, which can be especially helpful when
|
|
199
|
+
* values are added or removed from an enum.
|
|
200
|
+
*/
|
|
201
|
+
"@typescript-eslint/switch-exhaustiveness-check": "warn",
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
overrides: [
|
|
205
|
+
// Disable some TypeScript-specific rules in JavaScript files.
|
|
206
|
+
{
|
|
207
|
+
files: ["*.js", "*.cjs", "*.mjs", "*.jsx"],
|
|
208
|
+
rules: {
|
|
209
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
210
|
+
"@typescript-eslint/no-unsafe-argument": "off",
|
|
211
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
212
|
+
"@typescript-eslint/no-unsafe-call": "off",
|
|
213
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
214
|
+
"@typescript-eslint/no-unsafe-return": "off",
|
|
215
|
+
"@typescript-eslint/no-var-requires": "off",
|
|
216
|
+
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
217
|
+
"isaacscript/no-object-any": "off",
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
};
|
package/base.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// This is a shared configuration file for ESLint:
|
|
2
2
|
// https://eslint.org/docs/latest/user-guide/configuring
|
|
3
|
+
// This config is meant to be used as a base for all TypeScript projects.
|
|
3
4
|
module.exports = {
|
|
4
5
|
extends: [
|
|
5
6
|
/**
|
|
@@ -23,7 +24,6 @@ module.exports = {
|
|
|
23
24
|
* We extend the Airbnb rules with the "recommended", "recommended-requiring-type-checking", and
|
|
24
25
|
* "strict" rules from the "typescript-eslint" plugin, which is also recommended by Matt
|
|
25
26
|
* Turnbull, the author of "airbnb-typescript/base":
|
|
26
|
-
* https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/README.md#recommended
|
|
27
27
|
* https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended.ts
|
|
28
28
|
* https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts
|
|
29
29
|
* https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/strict.ts
|
|
@@ -44,8 +44,16 @@ module.exports = {
|
|
|
44
44
|
*/
|
|
45
45
|
"plugin:eslint-comments/recommended",
|
|
46
46
|
|
|
47
|
-
/**
|
|
48
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Lint Node-specific things:
|
|
49
|
+
* https://github.com/eslint-community/eslint-plugin-n
|
|
50
|
+
*/
|
|
51
|
+
"plugin:n/recommended",
|
|
52
|
+
|
|
53
|
+
/** Rule modifications are split out into different files for better organization. */
|
|
54
|
+
"./base-eslint",
|
|
55
|
+
"./base-typescript-eslint",
|
|
56
|
+
"./base-jsdoc",
|
|
49
57
|
|
|
50
58
|
/**
|
|
51
59
|
* Disable any ESLint rules that conflict with Prettier:
|
|
@@ -57,437 +65,269 @@ module.exports = {
|
|
|
57
65
|
|
|
58
66
|
plugins: [
|
|
59
67
|
/**
|
|
60
|
-
*
|
|
61
|
-
* https://github.com/
|
|
62
|
-
*
|
|
63
|
-
* This allows the end-user to more easily distinguish between errors from the TypeScript
|
|
64
|
-
* compiler (which show up in red) and ESLint rule violations (which show up in yellow).
|
|
68
|
+
* Activate the "no-autofix" plugin, which allows the fixer for specific rules to be turned off:
|
|
69
|
+
* https://github.com/aladdin-add/eslint-plugin/tree/master/packages/no-autofix
|
|
65
70
|
*/
|
|
66
|
-
"
|
|
71
|
+
"no-autofix",
|
|
67
72
|
|
|
68
73
|
/**
|
|
69
74
|
* Activate the "no-type-assertion" plugin, which allows the "no-type-assertion" rule to be
|
|
70
|
-
* optionally enabled on a per-project basis
|
|
75
|
+
* optionally enabled on a per-project basis:
|
|
76
|
+
* https://github.com/Dremora/eslint-plugin-no-type-assertion
|
|
71
77
|
*/
|
|
72
78
|
"no-type-assertion",
|
|
73
79
|
|
|
74
80
|
/**
|
|
75
|
-
* Activate the "
|
|
76
|
-
*
|
|
81
|
+
* Activate the "eslint-plugin-only-warn" plugin to change all errors to warnings:
|
|
82
|
+
* https://github.com/bfanger/eslint-plugin-only-warn
|
|
83
|
+
*
|
|
84
|
+
* This allows the end-user to more easily distinguish between errors from the TypeScript
|
|
85
|
+
* compiler (which show up in red) and ESLint rule violations (which show up in yellow).
|
|
77
86
|
*/
|
|
78
|
-
"
|
|
79
|
-
],
|
|
87
|
+
"only-warn",
|
|
80
88
|
|
|
81
|
-
rules: {
|
|
82
89
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* Not defined in the parent configs.
|
|
87
|
-
*
|
|
88
|
-
* Prefer the "string[]" syntax over "Array<string>".
|
|
90
|
+
* Activate the "sort-exports" plugin, which allows the "sort-exports" rule to be optionally
|
|
91
|
+
* enabled on a per-project basis:
|
|
92
|
+
* https://github.com/jrdrg/eslint-plugin-sort-exports
|
|
89
93
|
*/
|
|
90
|
-
"
|
|
91
|
-
"warn",
|
|
92
|
-
{
|
|
93
|
-
default: "array-simple",
|
|
94
|
-
},
|
|
95
|
-
],
|
|
94
|
+
"sort-exports",
|
|
96
95
|
|
|
97
96
|
/**
|
|
98
|
-
*
|
|
99
|
-
* https://
|
|
100
|
-
*
|
|
101
|
-
* Not defined in the parent configs.
|
|
102
|
-
*
|
|
103
|
-
* Specifying explicit return types can help prevent bugs, but only require it on exported
|
|
104
|
-
* functions.
|
|
97
|
+
* Activate the "unicorn" plugin, which allows for various miscellaneous useful rules:
|
|
98
|
+
* https://github.com/sindresorhus/eslint-plugin-unicorn
|
|
105
99
|
*/
|
|
106
|
-
"
|
|
100
|
+
"unicorn",
|
|
101
|
+
],
|
|
107
102
|
|
|
103
|
+
rules: {
|
|
108
104
|
/**
|
|
109
105
|
* Documentation:
|
|
110
|
-
* https://
|
|
106
|
+
* https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/master/docs/rules/disable-enable-pair.md
|
|
111
107
|
*
|
|
112
108
|
* Defined at:
|
|
113
|
-
* https://github.com/
|
|
109
|
+
* https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/master/lib/configs/recommended.js
|
|
114
110
|
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
111
|
+
* By default, it does not allow "eslint-disable" comments for a whole file, which is standard
|
|
112
|
+
* practice.
|
|
117
113
|
*/
|
|
118
|
-
"
|
|
114
|
+
"eslint-comments/disable-enable-pair": [
|
|
119
115
|
"warn",
|
|
120
|
-
"always",
|
|
121
116
|
{
|
|
122
|
-
|
|
117
|
+
allowWholeFile: true,
|
|
123
118
|
},
|
|
124
119
|
],
|
|
125
120
|
|
|
126
121
|
/**
|
|
127
122
|
* Documentation:
|
|
128
|
-
* https://
|
|
123
|
+
* https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/master/docs/rules/no-unlimited-disable.md
|
|
129
124
|
*
|
|
130
125
|
* Defined at:
|
|
131
|
-
* https://github.com/
|
|
126
|
+
* https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/master/lib/configs/recommended.js
|
|
132
127
|
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
128
|
+
* If a line breaks two or more ESLint rules, then it is useful to use a single "eslint-disable"
|
|
129
|
+
* comment.
|
|
135
130
|
*/
|
|
136
|
-
"
|
|
137
|
-
"warn",
|
|
138
|
-
// Allow camelCase variables (23.2), PascalCase variables (23.8), and UPPER_CASE variables
|
|
139
|
-
// (23.10).
|
|
140
|
-
{
|
|
141
|
-
selector: "variable",
|
|
142
|
-
format: ["camelCase", "PascalCase", "UPPER_CASE"],
|
|
143
|
-
leadingUnderscore: "allow",
|
|
144
|
-
},
|
|
145
|
-
// Allow camelCase functions (23.2), and PascalCase functions (23.8).
|
|
146
|
-
{
|
|
147
|
-
selector: "function",
|
|
148
|
-
format: ["camelCase", "PascalCase"],
|
|
149
|
-
leadingUnderscore: "allow",
|
|
150
|
-
},
|
|
151
|
-
// Airbnb recommends PascalCase for classes (23.3), and although Airbnb does not make
|
|
152
|
-
// TypeScript recommendations, we are assuming this rule would similarly apply to anything
|
|
153
|
-
// "type like", including interfaces, type aliases, and enums.
|
|
154
|
-
{
|
|
155
|
-
selector: "typeLike",
|
|
156
|
-
format: ["PascalCase"],
|
|
157
|
-
},
|
|
158
|
-
],
|
|
131
|
+
"eslint-comments/no-unlimited-disable": "off",
|
|
159
132
|
|
|
160
133
|
/**
|
|
161
134
|
* Documentation:
|
|
162
|
-
* https://
|
|
135
|
+
* https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/master/docs/rules/no-unused-disable.md
|
|
163
136
|
*
|
|
164
137
|
* Not defined in the parent configs.
|
|
165
138
|
*
|
|
166
|
-
* This
|
|
139
|
+
* This can help clean up unnecessary comments.
|
|
167
140
|
*/
|
|
168
|
-
"
|
|
141
|
+
"eslint-comments/no-unused-disable": "warn",
|
|
169
142
|
|
|
170
143
|
/**
|
|
171
144
|
* Documentation:
|
|
172
|
-
* https://
|
|
145
|
+
* https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/extensions.md
|
|
173
146
|
*
|
|
174
147
|
* Defined at:
|
|
175
|
-
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/
|
|
148
|
+
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/imports.js
|
|
149
|
+
* https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
176
150
|
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* TypeScript compiler
|
|
151
|
+
* This rule is useful in commonjs codebases that want to ban file extensions on imports.
|
|
152
|
+
* However, ESM is now the standard and file extensions should be used. Furthermore, in
|
|
153
|
+
* TypeScript codebases, the compiler will alert us to any errors on a file extension in an
|
|
154
|
+
* import statement.
|
|
180
155
|
*/
|
|
181
|
-
"
|
|
182
|
-
"warn",
|
|
183
|
-
{
|
|
184
|
-
args: "all",
|
|
185
|
-
argsIgnorePattern: "^_",
|
|
186
|
-
varsIgnorePattern: "^_",
|
|
187
|
-
},
|
|
188
|
-
],
|
|
156
|
+
"import/extensions": "off",
|
|
189
157
|
|
|
190
158
|
/**
|
|
191
159
|
* Documentation:
|
|
192
|
-
* https://
|
|
160
|
+
* https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-default-export.md
|
|
193
161
|
*
|
|
194
|
-
*
|
|
195
|
-
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/variables.js
|
|
162
|
+
* Not defined in the parent configs.
|
|
196
163
|
*
|
|
197
|
-
*
|
|
164
|
+
* The case against default exports is layed out here:
|
|
165
|
+
* https://basarat.gitbook.io/typescript/main-1/defaultisbad
|
|
198
166
|
*/
|
|
199
|
-
"
|
|
167
|
+
"import/no-default-export": "warn",
|
|
200
168
|
|
|
201
169
|
/**
|
|
202
170
|
* Documentation:
|
|
203
|
-
* https://
|
|
171
|
+
* https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-deprecated.md
|
|
204
172
|
*
|
|
205
173
|
* Defined at:
|
|
206
|
-
* https://github.com/
|
|
174
|
+
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/imports.js
|
|
207
175
|
*
|
|
208
|
-
*
|
|
209
|
-
* in some circumstances:
|
|
210
|
-
* https://github.com/typescript-eslint/typescript-eslint/issues/5269
|
|
176
|
+
* It is a useful rule and it is turned off in the parent configs with no explanation.
|
|
211
177
|
*/
|
|
212
|
-
"
|
|
178
|
+
"import/no-deprecated": "off",
|
|
213
179
|
|
|
214
180
|
/**
|
|
215
181
|
* Documentation:
|
|
216
|
-
* https://
|
|
182
|
+
* https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-unresolved.md
|
|
217
183
|
*
|
|
218
184
|
* Defined at:
|
|
219
|
-
* https://github.com/
|
|
185
|
+
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/imports.js
|
|
220
186
|
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
* https://github.com/prettier/eslint-config-prettier#enforce-backticks
|
|
187
|
+
* This rule is not necessary in TypeScript codebases, since the compiler would error if you had
|
|
188
|
+
* a typo in an import statement.
|
|
224
189
|
*/
|
|
225
|
-
"
|
|
226
|
-
"warn",
|
|
227
|
-
"double",
|
|
228
|
-
{
|
|
229
|
-
avoidEscape: true,
|
|
230
|
-
allowTemplateLiterals: false,
|
|
231
|
-
},
|
|
232
|
-
],
|
|
190
|
+
"import/no-unresolved": "off",
|
|
233
191
|
|
|
234
192
|
/**
|
|
235
193
|
* Documentation:
|
|
236
|
-
* https://
|
|
194
|
+
* https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/prefer-default-export.md
|
|
237
195
|
*
|
|
238
196
|
* Defined at:
|
|
239
|
-
* https://github.com/
|
|
240
|
-
*
|
|
241
|
-
* This rule disallows booleans and nulls in template expressions. However, a common use-case of
|
|
242
|
-
* template strings is to coerce everything to a string.
|
|
243
|
-
*/
|
|
244
|
-
"@typescript-eslint/restrict-template-expressions": "off",
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Documentation:
|
|
248
|
-
* https://typescript-eslint.io/rules/strict-boolean-expressions
|
|
249
|
-
*
|
|
250
|
-
* Not defined in the parent configs.
|
|
251
|
-
*
|
|
252
|
-
* This rule prevents bugs when refactoring a boolean to a number.
|
|
253
|
-
*/
|
|
254
|
-
"@typescript-eslint/strict-boolean-expressions": [
|
|
255
|
-
"warn",
|
|
256
|
-
{
|
|
257
|
-
allowString: false,
|
|
258
|
-
allowNumber: false,
|
|
259
|
-
allowNullableObject: false,
|
|
260
|
-
allowNullableBoolean: false,
|
|
261
|
-
allowNullableString: false,
|
|
262
|
-
allowNullableNumber: false,
|
|
263
|
-
allowAny: false,
|
|
264
|
-
},
|
|
265
|
-
],
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Documentation:
|
|
269
|
-
* https://typescript-eslint.io/rules/switch-exhaustiveness-check/
|
|
270
|
-
*
|
|
271
|
-
* Not defined in the parent configs.
|
|
197
|
+
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/imports.js
|
|
272
198
|
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
199
|
+
* The case against default exports is layed out here:
|
|
200
|
+
* https://basarat.gitbook.io/typescript/main-1/defaultisbad
|
|
275
201
|
*/
|
|
276
|
-
"
|
|
202
|
+
"import/prefer-default-export": "off",
|
|
277
203
|
|
|
278
204
|
/**
|
|
279
205
|
* Documentation:
|
|
280
|
-
* https://
|
|
206
|
+
* https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-extraneous-import.md
|
|
281
207
|
*
|
|
282
208
|
* Defined at:
|
|
283
|
-
* https://github.com/
|
|
209
|
+
* https://github.com/eslint-community/eslint-plugin-n/blob/master/lib/configs/_commons.js
|
|
284
210
|
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
* https://github.com/typescript-eslint/typescript-eslint/issues/5254
|
|
211
|
+
* The TypeScript compiler will warn us if an import does not exist, so this rule is
|
|
212
|
+
* unnecessary.
|
|
288
213
|
*/
|
|
289
|
-
"
|
|
214
|
+
"n/no-extraneous-import": "off",
|
|
290
215
|
|
|
291
216
|
/**
|
|
292
217
|
* Documentation:
|
|
293
|
-
* https://
|
|
218
|
+
* https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-extraneous-require.md
|
|
294
219
|
*
|
|
295
220
|
* Defined at:
|
|
296
|
-
* https://github.com/
|
|
221
|
+
* https://github.com/eslint-community/eslint-plugin-n/blob/master/lib/configs/_commons.js
|
|
297
222
|
*
|
|
298
|
-
*
|
|
299
|
-
* https://www.imperialviolet.org/2014/02/22/applebug.html
|
|
300
|
-
*
|
|
301
|
-
* Additionally, this rule needs to be set to "all" to work properly with
|
|
302
|
-
* `eslint-prettier-config`:
|
|
303
|
-
* https://github.com/prettier/eslint-config-prettier#curly
|
|
223
|
+
* Require statements are not used in TypeScript code.
|
|
304
224
|
*/
|
|
305
|
-
|
|
225
|
+
"n/no-extraneous-require": "off",
|
|
306
226
|
|
|
307
227
|
/**
|
|
308
228
|
* Documentation:
|
|
309
|
-
* https://
|
|
229
|
+
* https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-missing-import.md
|
|
310
230
|
*
|
|
311
231
|
* Defined at:
|
|
312
|
-
* https://github.com/
|
|
232
|
+
* https://github.com/eslint-community/eslint-plugin-n/blob/master/lib/configs/_commons.js
|
|
313
233
|
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
234
|
+
* The TypeScript compiler will warn us if an import does not exist, so this rule is
|
|
235
|
+
* unnecessary.
|
|
316
236
|
*/
|
|
317
|
-
"
|
|
237
|
+
"n/no-missing-import": "off",
|
|
318
238
|
|
|
319
239
|
/**
|
|
320
240
|
* Documentation:
|
|
321
|
-
* https://github.com/
|
|
241
|
+
* https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-process-exit.md
|
|
322
242
|
*
|
|
323
243
|
* Defined at:
|
|
324
|
-
* https://github.com/
|
|
244
|
+
* https://github.com/eslint-community/eslint-plugin-n/blob/master/lib/configs/_commons.js
|
|
325
245
|
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
246
|
+
* Using "process.exit" allows the ability to exit command-line applications without verbose
|
|
247
|
+
* output.
|
|
328
248
|
*/
|
|
329
|
-
"
|
|
330
|
-
"warn",
|
|
331
|
-
{
|
|
332
|
-
allowWholeFile: true,
|
|
333
|
-
},
|
|
334
|
-
],
|
|
249
|
+
"n/no-process-exit": "off",
|
|
335
250
|
|
|
336
251
|
/**
|
|
337
252
|
* Documentation:
|
|
338
|
-
* https://github.com/
|
|
253
|
+
* https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-unsupported-features/es-syntax.md
|
|
339
254
|
*
|
|
340
255
|
* Defined at:
|
|
341
|
-
* https://github.com/
|
|
256
|
+
* https://github.com/eslint-community/eslint-plugin-n/blob/master/lib/configs/_commons.js
|
|
342
257
|
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*/
|
|
346
|
-
"eslint-comments/no-unlimited-disable": "off",
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Documentation:
|
|
350
|
-
* https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/master/docs/rules/no-unused-disable.md
|
|
351
|
-
*
|
|
352
|
-
* Not defined in the parent configs.
|
|
353
|
-
*
|
|
354
|
-
* This can help clean up unnecessary comments.
|
|
258
|
+
* This rule requires adding `parserOptions.ecmaVersion` to every ESLint configuration file. The
|
|
259
|
+
* rule does not provide enough value to make that modification worth it.
|
|
355
260
|
*/
|
|
356
|
-
"
|
|
261
|
+
"n/no-unsupported-features/es-syntax": "off",
|
|
357
262
|
|
|
358
263
|
/**
|
|
359
264
|
* Documentation:
|
|
360
|
-
* https://github.com/
|
|
361
|
-
*
|
|
362
|
-
* Not defined in the parent configs.
|
|
363
|
-
*
|
|
364
|
-
* The case against default exports is layed out here:
|
|
365
|
-
* https://basarat.gitbook.io/typescript/main-1/defaultisbad
|
|
366
|
-
*/
|
|
367
|
-
"import/no-default-export": "warn",
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* Documentation:
|
|
371
|
-
* https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/prefer-default-export.md
|
|
265
|
+
* https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-unsupported-features/es-syntax.md
|
|
372
266
|
*
|
|
373
267
|
* Defined at:
|
|
374
|
-
* https://github.com/
|
|
268
|
+
* https://github.com/eslint-community/eslint-plugin-n/blob/master/lib/configs/_commons.js
|
|
375
269
|
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
270
|
+
* This rule requires adding `parserOptions.ecmaVersion` to every ESLint configuration file. The
|
|
271
|
+
* rule does not provide enough value to make that modification worth it.
|
|
378
272
|
*/
|
|
379
|
-
"
|
|
273
|
+
"n/no-unsupported-features/es-builtins": "off",
|
|
380
274
|
|
|
381
275
|
/**
|
|
382
276
|
* Documentation:
|
|
383
|
-
* https://
|
|
277
|
+
* https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-unsupported-features/node-builtins.md
|
|
384
278
|
*
|
|
385
279
|
* Defined at:
|
|
386
|
-
* https://github.com/
|
|
387
|
-
*
|
|
388
|
-
* Command-line programs commonly write to standard out and standard error.
|
|
389
|
-
*/
|
|
390
|
-
"no-console": "off",
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* Documentation:
|
|
394
|
-
* https://eslint.org/docs/latest/rules/no-constant-binary-expression
|
|
280
|
+
* https://github.com/eslint-community/eslint-plugin-n/blob/master/lib/configs/_commons.js
|
|
395
281
|
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
* This rule was released in 2022 and is known to catch many subtle bugs:
|
|
399
|
-
* https://github.com/eslint/eslint.org/pull/240/files
|
|
282
|
+
* The TypeScript compiler will prevent us from using Node modules that are not present in the
|
|
283
|
+
* corresponding specified Node output environment, so this rule is unnecessary.
|
|
400
284
|
*/
|
|
401
|
-
"no-
|
|
285
|
+
"n/no-unsupported-features/node-builtins": "off",
|
|
402
286
|
|
|
403
287
|
/**
|
|
404
288
|
* Documentation:
|
|
405
|
-
* https://
|
|
289
|
+
* https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/shebang.md
|
|
406
290
|
*
|
|
407
291
|
* Defined at:
|
|
408
|
-
* https://github.com/
|
|
292
|
+
* https://github.com/eslint-community/eslint-plugin-n/blob/master/lib/configs/_commons.js
|
|
409
293
|
*
|
|
410
|
-
*
|
|
294
|
+
* We need to configure this rule to be Typescript-aware.
|
|
411
295
|
*/
|
|
412
|
-
"
|
|
296
|
+
"n/shebang": [
|
|
297
|
+
"error",
|
|
298
|
+
{
|
|
299
|
+
convertPath: {
|
|
300
|
+
"src/**/*.ts": ["^src/(.+?)\\.ts$", "src/$1.js"],
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
],
|
|
413
304
|
|
|
414
305
|
/**
|
|
415
306
|
* Documentation:
|
|
416
|
-
* https://
|
|
307
|
+
* https://github.com/aladdin-add/eslint-plugin/tree/master/packages/no-autofix
|
|
417
308
|
*
|
|
418
|
-
*
|
|
419
|
-
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/style.js
|
|
420
|
-
*
|
|
421
|
-
* Airbnb disallows these because it can lead to errors with minified code. When using Prettier,
|
|
422
|
-
* it adds semi-colons everywhere, so we don't have to worry about this.
|
|
309
|
+
* We want to disable the autofix for this rule, since it is almost always unwanted.
|
|
423
310
|
*/
|
|
424
|
-
"no-
|
|
311
|
+
"no-useless-return": "off",
|
|
312
|
+
"no-autofix/no-useless-return": "warn",
|
|
425
313
|
|
|
426
314
|
/**
|
|
427
315
|
* Documentation:
|
|
428
|
-
* https://
|
|
316
|
+
* https://github.com/aladdin-add/eslint-plugin/tree/master/packages/no-autofix
|
|
429
317
|
*
|
|
430
|
-
*
|
|
431
|
-
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/style.js
|
|
432
|
-
*
|
|
433
|
-
* - We move the selector for "for..of" loops, since they are commonly used.
|
|
434
|
-
* - We add a selector for "empty" invocations of the "array.push()" method.
|
|
318
|
+
* We want to disable the autofix for this rule, since it is almost always unwanted.
|
|
435
319
|
*/
|
|
436
|
-
"
|
|
437
|
-
|
|
438
|
-
{
|
|
439
|
-
selector: "ForInStatement",
|
|
440
|
-
message:
|
|
441
|
-
"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.",
|
|
442
|
-
},
|
|
443
|
-
{
|
|
444
|
-
selector: "LabeledStatement",
|
|
445
|
-
message:
|
|
446
|
-
"Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.",
|
|
447
|
-
},
|
|
448
|
-
{
|
|
449
|
-
selector: "WithStatement",
|
|
450
|
-
message:
|
|
451
|
-
"`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
|
|
452
|
-
},
|
|
453
|
-
{
|
|
454
|
-
selector:
|
|
455
|
-
"CallExpression[callee.property.name='push'][arguments.length=0]",
|
|
456
|
-
message: "push must always be called with at least one argument.",
|
|
457
|
-
},
|
|
458
|
-
],
|
|
320
|
+
"prefer-const": "off",
|
|
321
|
+
"no-autofix/prefer-const": "warn",
|
|
459
322
|
|
|
460
323
|
/**
|
|
461
324
|
* Documentation:
|
|
462
|
-
* https://
|
|
325
|
+
* https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-node-protocol.md
|
|
463
326
|
*
|
|
464
327
|
* Not defined in parent configs.
|
|
465
328
|
*
|
|
466
|
-
*
|
|
467
|
-
*/
|
|
468
|
-
"no-unused-expressions": "warn",
|
|
469
|
-
|
|
470
|
-
/**
|
|
471
|
-
* Documentation:
|
|
472
|
-
* https://eslint.org/docs/latest/rules/prefer-destructuring
|
|
473
|
-
*
|
|
474
|
-
* Defined at:
|
|
475
|
-
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/es6.js
|
|
476
|
-
*
|
|
477
|
-
* Array destructuring can result in non-intuitive code.
|
|
329
|
+
* Enforce the new "node:" prefix as an extra safety measure.
|
|
478
330
|
*/
|
|
479
|
-
"prefer-
|
|
480
|
-
"warn",
|
|
481
|
-
{
|
|
482
|
-
VariableDeclarator: {
|
|
483
|
-
array: false,
|
|
484
|
-
object: true,
|
|
485
|
-
},
|
|
486
|
-
AssignmentExpression: {
|
|
487
|
-
array: false,
|
|
488
|
-
object: false,
|
|
489
|
-
},
|
|
490
|
-
},
|
|
491
|
-
],
|
|
331
|
+
"unicorn/prefer-node-protocol": "warn",
|
|
492
332
|
},
|
|
493
333
|
};
|
package/mod.js
CHANGED
package/monorepo.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const path = require("path");
|
|
1
|
+
const path = require("node:path");
|
|
2
2
|
|
|
3
3
|
const REPO_ROOT = path.join(__dirname, "..", "..");
|
|
4
4
|
|
|
@@ -16,6 +16,9 @@ module.exports = {
|
|
|
16
16
|
tsconfigRootDir: REPO_ROOT,
|
|
17
17
|
},
|
|
18
18
|
|
|
19
|
+
// The ".prettierrc.cjs" file is ignored by default, so we have to un-ignore it.
|
|
20
|
+
ignorePatterns: ["!.prettierrc.cjs"],
|
|
21
|
+
|
|
19
22
|
rules: {
|
|
20
23
|
"@nrwl/nx/enforce-module-boundaries": [
|
|
21
24
|
"warn",
|