eslint-config-isaacscript 3.7.2 → 4.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/README.md +2 -30
- package/base-eslint-comments.js +59 -0
- package/base-eslint.js +714 -277
- package/base-import.js +224 -0
- package/base-jsdoc.js +134 -135
- package/base-n.js +146 -0
- package/base-no-autofix.js +18 -0
- package/base-typescript-eslint.js +359 -223
- package/base-unicorn.js +227 -0
- package/base.js +15 -324
- package/mod.js +104 -94
- package/monorepo.js +4 -24
- package/package.json +5 -2
|
@@ -1,239 +1,375 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/** This plugin has three separate configs that are recommended to extend from. */
|
|
8
|
-
extends: [
|
|
9
|
-
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended.ts
|
|
10
|
-
"plugin:@typescript-eslint/recommended",
|
|
1
|
+
// This ESLint config only contains rules from `@typescript-eslint/eslint-plugin`:
|
|
2
|
+
// https://typescript-eslint.io/rules/
|
|
3
|
+
|
|
4
|
+
// Rules are separated into categories:
|
|
5
|
+
// 1) Supported Rules
|
|
6
|
+
// 2) Extension Rules
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
/** @type {import("eslint").Linter.RulesRecord} */
|
|
9
|
+
const SUPPORTED_RULES = {
|
|
10
|
+
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The default value is `array`. We choose `array-simple` because it makes complicated arrays
|
|
14
|
+
* easier to understand. This is worth the cost of deviating from the base rule configuration.
|
|
15
|
+
*/
|
|
16
|
+
"@typescript-eslint/array-type": [
|
|
17
|
+
"error",
|
|
18
|
+
{
|
|
19
|
+
default: "array-simple",
|
|
20
|
+
},
|
|
17
21
|
],
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
*
|
|
71
|
-
* Modify the Airbnb config to allow for a leading underscore, which signifies that it is
|
|
72
|
-
* temporarily not being used.
|
|
73
|
-
*/
|
|
74
|
-
"@typescript-eslint/naming-convention": [
|
|
75
|
-
"warn",
|
|
76
|
-
// Allow camelCase variables (23.2), PascalCase variables (23.8), and UPPER_CASE variables
|
|
77
|
-
// (23.10).
|
|
78
|
-
{
|
|
79
|
-
selector: "variable",
|
|
80
|
-
format: ["camelCase", "PascalCase", "UPPER_CASE"],
|
|
81
|
-
leadingUnderscore: "allow",
|
|
82
|
-
},
|
|
83
|
-
// Allow camelCase functions (23.2), and PascalCase functions (23.8).
|
|
84
|
-
{
|
|
85
|
-
selector: "function",
|
|
86
|
-
format: ["camelCase", "PascalCase"],
|
|
87
|
-
leadingUnderscore: "allow",
|
|
88
|
-
},
|
|
89
|
-
// Airbnb recommends PascalCase for classes (23.3), and although Airbnb does not make
|
|
90
|
-
// TypeScript recommendations, we are assuming this rule would similarly apply to anything
|
|
91
|
-
// "type like", including interfaces, type aliases, and enums.
|
|
92
|
-
{
|
|
93
|
-
selector: "typeLike",
|
|
94
|
-
format: ["PascalCase"],
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Documentation:
|
|
100
|
-
* https://typescript-eslint.io/rules/no-confusing-void-expression
|
|
101
|
-
*
|
|
102
|
-
* Not defined in the parent configs.
|
|
103
|
-
*
|
|
104
|
-
* This prevents assigning void to variables, which is almost certainly a bug.
|
|
105
|
-
*/
|
|
106
|
-
"@typescript-eslint/no-confusing-void-expression": "warn",
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Documentation:
|
|
110
|
-
* https://typescript-eslint.io/rules/no-unnecessary-boolean-literal-compare
|
|
111
|
-
*
|
|
112
|
-
* Not defined in the parent configs.
|
|
113
|
-
*
|
|
114
|
-
* This prevents useless code after refactoring variables to pure booleans.
|
|
115
|
-
*/
|
|
116
|
-
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn",
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Documentation:
|
|
120
|
-
* https://typescript-eslint.io/rules/no-unused-vars
|
|
121
|
-
*
|
|
122
|
-
* Defined at:
|
|
123
|
-
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/variables.js
|
|
124
|
-
*
|
|
125
|
-
* We want to lint unused arguments (the default is "after-used"). We also want to ignore
|
|
126
|
-
* arguments/variables that start with an underscore. This matches the behavior of the
|
|
127
|
-
* TypeScript compiler flag "--noUnusedLocals".
|
|
128
|
-
*/
|
|
129
|
-
"@typescript-eslint/no-unused-vars": [
|
|
130
|
-
"warn",
|
|
131
|
-
{
|
|
132
|
-
args: "all",
|
|
133
|
-
argsIgnorePattern: "^_",
|
|
134
|
-
varsIgnorePattern: "^_",
|
|
135
|
-
},
|
|
136
|
-
],
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Documentation:
|
|
140
|
-
* https://typescript-eslint.io/rules/no-use-before-define
|
|
141
|
-
*
|
|
142
|
-
* Defined at:
|
|
143
|
-
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/variables.js
|
|
144
|
-
*
|
|
145
|
-
* This allows code to be structured in a more logical order.
|
|
146
|
-
*/
|
|
147
|
-
"@typescript-eslint/no-use-before-define": "off",
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Documentation:
|
|
151
|
-
* https://typescript-eslint.io/rules/prefer-optional-chain
|
|
152
|
-
*
|
|
153
|
-
* Defined at:
|
|
154
|
-
* https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/strict.ts
|
|
155
|
-
*
|
|
156
|
-
* This can modify the type of boolean declarations to `boolean | undefined`, which is undesired
|
|
157
|
-
* in some circumstances:
|
|
158
|
-
* https://github.com/typescript-eslint/typescript-eslint/issues/5269
|
|
159
|
-
*/
|
|
160
|
-
"@typescript-eslint/prefer-optional-chain": "off",
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Documentation:
|
|
164
|
-
* https://typescript-eslint.io/rules/quotes
|
|
165
|
-
*
|
|
166
|
-
* Defined at:
|
|
167
|
-
* https://github.com/prettier/eslint-config-prettier/blob/main/%40typescript-eslint.js
|
|
168
|
-
*
|
|
169
|
-
* In order to forbid unnecessary backticks, we must re-enable the "@typescript-eslint/quotes"
|
|
170
|
-
* rule as specified in the eslint-config-prettier documentation:
|
|
171
|
-
* https://github.com/prettier/eslint-config-prettier#enforce-backticks
|
|
172
|
-
*/
|
|
173
|
-
"@typescript-eslint/quotes": [
|
|
174
|
-
"warn",
|
|
175
|
-
"double",
|
|
176
|
-
{
|
|
177
|
-
avoidEscape: true,
|
|
178
|
-
allowTemplateLiterals: false,
|
|
179
|
-
},
|
|
180
|
-
],
|
|
181
|
-
|
|
182
|
-
// This is part of the recommended config, but we turn it off because of this issue:
|
|
183
|
-
// https://github.com/typescript-eslint/typescript-eslint/issues/7067
|
|
184
|
-
"@typescript-eslint/no-unsafe-enum-comparison": "off",
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Documentation:
|
|
188
|
-
* https://typescript-eslint.io/rules/restrict-template-expressions
|
|
189
|
-
*
|
|
190
|
-
* Defined at:
|
|
191
|
-
* https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts
|
|
192
|
-
*
|
|
193
|
-
* This rule disallows booleans and nulls in template expressions. However, a common use-case of
|
|
194
|
-
* template strings is to coerce everything to a string.
|
|
195
|
-
*/
|
|
196
|
-
"@typescript-eslint/restrict-template-expressions": "off",
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Documentation:
|
|
200
|
-
* https://typescript-eslint.io/rules/strict-boolean-expressions
|
|
201
|
-
*
|
|
202
|
-
* Not defined in the parent configs.
|
|
203
|
-
*
|
|
204
|
-
* This rule prevents bugs when refactoring a boolean to a number.
|
|
205
|
-
*/
|
|
206
|
-
"@typescript-eslint/strict-boolean-expressions": [
|
|
207
|
-
"warn",
|
|
208
|
-
{
|
|
209
|
-
allowString: false,
|
|
210
|
-
allowNumber: false,
|
|
211
|
-
allowNullableObject: false,
|
|
212
|
-
allowNullableBoolean: false,
|
|
213
|
-
allowNullableString: false,
|
|
214
|
-
allowNullableNumber: false,
|
|
215
|
-
allowAny: false,
|
|
23
|
+
"@typescript-eslint/await-thenable": "error",
|
|
24
|
+
"@typescript-eslint/ban-ts-comment": "error",
|
|
25
|
+
"@typescript-eslint/ban-tslint-comment": "error",
|
|
26
|
+
"@typescript-eslint/ban-types": "error",
|
|
27
|
+
"@typescript-eslint/class-literal-property-style": "error",
|
|
28
|
+
"@typescript-eslint/consistent-generic-constructors": "error",
|
|
29
|
+
"@typescript-eslint/consistent-indexed-object-style": "error",
|
|
30
|
+
"@typescript-eslint/consistent-type-assertions": "error",
|
|
31
|
+
"@typescript-eslint/consistent-type-definitions": "error",
|
|
32
|
+
"@typescript-eslint/consistent-type-exports": "error",
|
|
33
|
+
"@typescript-eslint/consistent-type-imports": "error",
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Disabled since it would be to cumbersome to require return types for non-exported functions.
|
|
37
|
+
* (It is more reasonable to require it for exported functions only, since it speeds up the
|
|
38
|
+
* type-checker in large codebases.)
|
|
39
|
+
*/
|
|
40
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Disabled since many programs may have internal-only classes that would not benefit from an
|
|
44
|
+
* explicit public/private distinction.
|
|
45
|
+
*/
|
|
46
|
+
"@typescript-eslint/explicit-member-accessibility": "off",
|
|
47
|
+
|
|
48
|
+
"@typescript-eslint/explicit-module-boundary-types": "error",
|
|
49
|
+
"@typescript-eslint/member-delimiter-style": "off", // eslint-config-prettier
|
|
50
|
+
|
|
51
|
+
/** Disabled since prescribed class ordering is too project-specific. */
|
|
52
|
+
"@typescript-eslint/member-ordering": "off",
|
|
53
|
+
|
|
54
|
+
"@typescript-eslint/method-signature-style": "error",
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The options are [copied from
|
|
58
|
+
* Airbnb](https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js).
|
|
59
|
+
* We also allow a leading underscore, which signifies that it is temporarily not being used.
|
|
60
|
+
*/
|
|
61
|
+
"@typescript-eslint/naming-convention": [
|
|
62
|
+
"error",
|
|
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
|
+
// Polyfilling "__dirname" in ESM files is a common pattern.
|
|
71
|
+
filter: {
|
|
72
|
+
regex: "^__dirname$",
|
|
73
|
+
match: false,
|
|
216
74
|
},
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
75
|
+
},
|
|
76
|
+
// Allow camelCase functions (23.2), and PascalCase functions (23.8).
|
|
77
|
+
{
|
|
78
|
+
selector: "function",
|
|
79
|
+
format: ["camelCase", "PascalCase"],
|
|
80
|
+
leadingUnderscore: "allow",
|
|
81
|
+
},
|
|
82
|
+
// Airbnb recommends PascalCase for classes (23.3), and although Airbnb does not make TypeScript
|
|
83
|
+
// recommendations, we are assuming this rule would similarly apply to anything "type like",
|
|
84
|
+
// including interfaces, type aliases, and enums.
|
|
85
|
+
{
|
|
86
|
+
selector: "typeLike",
|
|
87
|
+
format: ["PascalCase"],
|
|
88
|
+
leadingUnderscore: "allow",
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
|
|
92
|
+
"@typescript-eslint/no-base-to-string": "error",
|
|
93
|
+
"@typescript-eslint/no-confusing-non-null-assertion": "error",
|
|
94
|
+
"@typescript-eslint/no-confusing-void-expression": "error",
|
|
95
|
+
"@typescript-eslint/no-duplicate-enum-values": "error",
|
|
96
|
+
"@typescript-eslint/no-duplicate-type-constituents": "error",
|
|
97
|
+
"@typescript-eslint/no-dynamic-delete": "error",
|
|
98
|
+
"@typescript-eslint/no-empty-interface": "error",
|
|
99
|
+
"@typescript-eslint/no-explicit-any": "error",
|
|
100
|
+
"@typescript-eslint/no-extra-non-null-assertion": "error",
|
|
101
|
+
"@typescript-eslint/no-extraneous-class": "error",
|
|
102
|
+
"@typescript-eslint/no-floating-promises": "error",
|
|
103
|
+
"@typescript-eslint/no-for-in-array": "error",
|
|
104
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
105
|
+
"@typescript-eslint/no-inferrable-types": "error",
|
|
106
|
+
"@typescript-eslint/no-invalid-void-type": "error",
|
|
107
|
+
"@typescript-eslint/no-meaningless-void-operator": "error",
|
|
108
|
+
"@typescript-eslint/no-misused-new": "error",
|
|
109
|
+
"@typescript-eslint/no-misused-promises": "error",
|
|
110
|
+
"@typescript-eslint/no-mixed-enums": "error",
|
|
111
|
+
"@typescript-eslint/no-namespace": "error",
|
|
112
|
+
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
|
|
113
|
+
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
|
|
114
|
+
"@typescript-eslint/no-non-null-assertion": "error",
|
|
115
|
+
"@typescript-eslint/no-redundant-type-constituents": "error",
|
|
116
|
+
"@typescript-eslint/no-require-imports": "error",
|
|
117
|
+
"@typescript-eslint/no-this-alias": "error",
|
|
118
|
+
|
|
119
|
+
/** Disabled because this rule is deprecated. */
|
|
120
|
+
"@typescript-eslint/no-type-alias": "off",
|
|
121
|
+
|
|
122
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
|
|
123
|
+
"@typescript-eslint/no-unnecessary-condition": "error",
|
|
124
|
+
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
|
125
|
+
"@typescript-eslint/no-unnecessary-type-arguments": "error",
|
|
126
|
+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
127
|
+
"@typescript-eslint/no-unnecessary-type-constraint": "error",
|
|
128
|
+
"@typescript-eslint/no-unsafe-argument": "error",
|
|
129
|
+
"@typescript-eslint/no-unsafe-assignment": "error",
|
|
130
|
+
"@typescript-eslint/no-unsafe-call": "error",
|
|
131
|
+
"@typescript-eslint/no-unsafe-declaration-merging": "error",
|
|
132
|
+
"@typescript-eslint/no-unsafe-enum-comparison": "error",
|
|
133
|
+
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
134
|
+
"@typescript-eslint/no-unsafe-return": "error",
|
|
135
|
+
"@typescript-eslint/no-useless-empty-export": "error",
|
|
136
|
+
"@typescript-eslint/no-var-requires": "error",
|
|
137
|
+
"@typescript-eslint/non-nullable-type-assertion-style": "error",
|
|
138
|
+
"@typescript-eslint/parameter-properties": "error",
|
|
139
|
+
"@typescript-eslint/prefer-as-const": "error",
|
|
140
|
+
"@typescript-eslint/prefer-enum-initializers": "error",
|
|
141
|
+
"@typescript-eslint/prefer-for-of": "error",
|
|
142
|
+
"@typescript-eslint/prefer-function-type": "error",
|
|
143
|
+
"@typescript-eslint/prefer-includes": "error",
|
|
144
|
+
"@typescript-eslint/prefer-literal-enum-member": "error",
|
|
145
|
+
"@typescript-eslint/prefer-namespace-keyword": "error",
|
|
146
|
+
"@typescript-eslint/prefer-nullish-coalescing": "error",
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Disabled because it can modify the type of `boolean` declarations, which is [undesired in some
|
|
150
|
+
* circumstances](https://github.com/typescript-eslint/typescript-eslint/issues/5269).
|
|
151
|
+
*/
|
|
152
|
+
"@typescript-eslint/prefer-optional-chain": "off",
|
|
153
|
+
|
|
154
|
+
"@typescript-eslint/prefer-readonly": "error",
|
|
155
|
+
|
|
156
|
+
/** Disabled since it can obfuscate the intended input types of a function. */
|
|
157
|
+
"@typescript-eslint/prefer-readonly-parameter-types": "off",
|
|
158
|
+
|
|
159
|
+
"@typescript-eslint/prefer-reduce-type-parameter": "error",
|
|
160
|
+
|
|
161
|
+
/** Disabled since using the `String.match` form might make code easier to read. */
|
|
162
|
+
"@typescript-eslint/prefer-regexp-exec": "off",
|
|
163
|
+
|
|
164
|
+
"@typescript-eslint/prefer-return-this-type": "error",
|
|
165
|
+
"@typescript-eslint/prefer-string-starts-ends-with": "error",
|
|
166
|
+
"@typescript-eslint/prefer-ts-expect-error": "error",
|
|
167
|
+
"@typescript-eslint/promise-function-async": "error",
|
|
168
|
+
"@typescript-eslint/require-array-sort-compare": "error",
|
|
169
|
+
"@typescript-eslint/restrict-plus-operands": "error",
|
|
170
|
+
|
|
171
|
+
/** Disabled since a common use-case of template strings is to coerce everything to a string. */
|
|
172
|
+
"@typescript-eslint/restrict-template-expressions": "off",
|
|
173
|
+
|
|
174
|
+
/** Disabled since in it does not make sense to sort a union alphabetically in many cases. */
|
|
175
|
+
"@typescript-eslint/sort-type-constituents": "off",
|
|
176
|
+
|
|
177
|
+
"@typescript-eslint/strict-boolean-expressions": "error",
|
|
178
|
+
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
|
179
|
+
"@typescript-eslint/triple-slash-reference": "error",
|
|
180
|
+
"@typescript-eslint/type-annotation-spacing": "off", // eslint-config-prettier
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Disabled since it is not recommended by the `typescript-eslint` team. (They recommend using the
|
|
184
|
+
* `noImplicitAny` and `strictPropertyInitialization` TypeScript compiler options instead.)
|
|
185
|
+
*/
|
|
186
|
+
"@typescript-eslint/typedef": "off",
|
|
187
|
+
|
|
188
|
+
"@typescript-eslint/unbound-method": "error",
|
|
189
|
+
"@typescript-eslint/unified-signatures": "error",
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
/** @type {import("eslint").Linter.RulesRecord} */
|
|
193
|
+
const EXTENSION_RULES = {
|
|
194
|
+
"@typescript-eslint/block-spacing": "off", // eslint-config-prettier
|
|
195
|
+
"@typescript-eslint/brace-style": "off", // eslint-config-prettier
|
|
196
|
+
"@typescript-eslint/class-methods-use-this": "error",
|
|
197
|
+
"@typescript-eslint/comma-dangle": "off", // eslint-config-prettier
|
|
198
|
+
"@typescript-eslint/comma-spacing": "off", // eslint-config-prettier
|
|
199
|
+
"@typescript-eslint/default-param-last": "error",
|
|
200
|
+
"@typescript-eslint/dot-notation": "error",
|
|
201
|
+
"@typescript-eslint/func-call-spacing": "off", // eslint-config-prettier
|
|
202
|
+
"@typescript-eslint/indent": "off", // eslint-config-prettier
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Disabled since it is superfluous to require an `= undefined` during variable initialization
|
|
206
|
+
* (and TypeScript will take care of the non-undefined cases).
|
|
207
|
+
*/
|
|
208
|
+
"@typescript-eslint/init-declarations": "off",
|
|
209
|
+
|
|
210
|
+
"@typescript-eslint/key-spacing": "off", // eslint-config-prettier
|
|
211
|
+
"@typescript-eslint/keyword-spacing": "off", // eslint-config-prettier
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Even though the `typescript-eslint` team does not recommend using formatting rules, this rule
|
|
215
|
+
* is not handled by Prettier, so we must use ESLint to enforce it.
|
|
216
|
+
*/
|
|
217
|
+
"@typescript-eslint/lines-around-comment": [
|
|
218
|
+
"error",
|
|
219
|
+
{
|
|
220
|
+
// All of these properties default to false.
|
|
221
|
+
allowBlockStart: true,
|
|
222
|
+
allowObjectStart: true,
|
|
223
|
+
allowArrayStart: true,
|
|
224
|
+
allowClassStart: true,
|
|
225
|
+
allowEnumStart: true,
|
|
226
|
+
allowInterfaceStart: true,
|
|
227
|
+
allowModuleStart: true,
|
|
228
|
+
allowTypeStart: true,
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Even though the `typescript-eslint` team does not recommend using formatting rules, this rule
|
|
234
|
+
* is not handled by Prettier, so we must use ESLint to enforce it.
|
|
235
|
+
*/
|
|
236
|
+
"@typescript-eslint/lines-between-class-members": [
|
|
237
|
+
"error",
|
|
238
|
+
"always",
|
|
239
|
+
{
|
|
240
|
+
exceptAfterSingleLine: true,
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
|
|
244
|
+
"@typescript-eslint/no-array-constructor": "error",
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Disabled since it is superfluous when using TypeScript according to [the ESLint
|
|
248
|
+
* documentation](https://eslint.org/docs/latest/rules/no-dupe-class-members#when-not-to-use-it).
|
|
249
|
+
*/
|
|
250
|
+
"@typescript-eslint/no-dupe-class-members": "off",
|
|
251
|
+
|
|
252
|
+
"@typescript-eslint/no-empty-function": "error",
|
|
253
|
+
"@typescript-eslint/no-extra-parens": "off", // eslint-config-prettier
|
|
254
|
+
"@typescript-eslint/no-extra-semi": "off", // eslint-config-prettier
|
|
255
|
+
"@typescript-eslint/no-implied-eval": "error",
|
|
256
|
+
|
|
257
|
+
/** The `capIsConstructor` option is disabled to make the rule stricter. */
|
|
258
|
+
"@typescript-eslint/no-invalid-this": [
|
|
259
|
+
"error",
|
|
260
|
+
{
|
|
261
|
+
capIsConstructor: false,
|
|
262
|
+
},
|
|
263
|
+
],
|
|
264
|
+
|
|
265
|
+
"@typescript-eslint/no-loop-func": "error",
|
|
266
|
+
"@typescript-eslint/no-loss-of-precision": "error",
|
|
267
|
+
|
|
268
|
+
/** Disabled since it results in too many false positives. */
|
|
269
|
+
"@typescript-eslint/no-magic-numbers": "off",
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Disabled since it is handled by the combination of the TypeScript compiler and the `no-var`
|
|
273
|
+
* ESLint rule.
|
|
274
|
+
*/
|
|
275
|
+
"@typescript-eslint/no-redeclare": "off",
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Disabled since it would only be needed in specific environments (such as forbidding Node.js
|
|
279
|
+
* imports in a browser environment).
|
|
280
|
+
*/
|
|
281
|
+
"@typescript-eslint/no-restricted-imports": "off",
|
|
282
|
+
|
|
283
|
+
"@typescript-eslint/no-shadow": "error",
|
|
284
|
+
"@typescript-eslint/no-throw-literal": "error",
|
|
285
|
+
"@typescript-eslint/no-unused-expressions": "error",
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* The `args` option is set to `all` make the rule stricter. Additionally, we ignore things that
|
|
289
|
+
* begin with an underscore, since this matches the behavior of the `--noUnusedLocals` TypeScript
|
|
290
|
+
* compiler flag.
|
|
291
|
+
*/
|
|
292
|
+
"@typescript-eslint/no-unused-vars": [
|
|
293
|
+
"error",
|
|
294
|
+
{
|
|
295
|
+
args: "all", // "after-used" is the default.
|
|
296
|
+
argsIgnorePattern: "^_",
|
|
297
|
+
varsIgnorePattern: "^_",
|
|
298
|
+
},
|
|
299
|
+
],
|
|
300
|
+
|
|
301
|
+
/** Disabled because it can prevent code from being structured sequentially. */
|
|
302
|
+
"@typescript-eslint/no-use-before-define": "off",
|
|
303
|
+
|
|
304
|
+
"@typescript-eslint/no-useless-constructor": "error",
|
|
305
|
+
"@typescript-eslint/object-curly-spacing": "off", // eslint-config-prettier
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Disabled since it is for inserting extra newlines between specific kinds of statements, which
|
|
309
|
+
* would be project-dependant. (This kind of formatting is not handled by Prettier.)
|
|
310
|
+
*/
|
|
311
|
+
"@typescript-eslint/padding-line-between-statements": "off",
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* We forbid unnecessary backticks by using the options specified in [the `eslint-config-prettier`
|
|
315
|
+
* documentation](https://github.com/prettier/eslint-config-prettier#enforce-backticks).
|
|
316
|
+
*/
|
|
317
|
+
"@typescript-eslint/quotes": [
|
|
318
|
+
"error",
|
|
319
|
+
"double",
|
|
320
|
+
{
|
|
321
|
+
avoidEscape: true,
|
|
322
|
+
allowTemplateLiterals: false,
|
|
323
|
+
},
|
|
324
|
+
],
|
|
325
|
+
|
|
326
|
+
"@typescript-eslint/require-await": "error",
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Even though the core rule was deprecated, the extended rule uses type information, so it is
|
|
330
|
+
* much better.
|
|
331
|
+
*/
|
|
332
|
+
"@typescript-eslint/return-await": "error",
|
|
333
|
+
|
|
334
|
+
"@typescript-eslint/semi": "off", // eslint-config-prettier
|
|
335
|
+
"@typescript-eslint/space-before-blocks": "off", // eslint-config-prettier
|
|
336
|
+
"@typescript-eslint/space-before-function-paren": "off", // eslint-config-prettier
|
|
337
|
+
"@typescript-eslint/space-infix-ops": "off", // eslint-config-prettier
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
/** @type {import("eslint").Linter.Config} */
|
|
341
|
+
const config = {
|
|
342
|
+
// We need to provide some special configuration to ESLint in order for it to parse TypeScript
|
|
343
|
+
// files. From:
|
|
344
|
+
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/base.ts
|
|
345
|
+
parser: "@typescript-eslint/parser",
|
|
346
|
+
parserOptions: {
|
|
347
|
+
sourceType: "module",
|
|
348
|
+
|
|
349
|
+
// Needed for `eslint-plugin-import` to work properly:
|
|
350
|
+
// https://github.com/import-js/eslint-plugin-import/blob/main/config/recommended.js
|
|
351
|
+
ecmaVersion: "latest",
|
|
352
|
+
},
|
|
353
|
+
plugins: ["@typescript-eslint"],
|
|
354
|
+
|
|
355
|
+
rules: {
|
|
356
|
+
...SUPPORTED_RULES,
|
|
357
|
+
...EXTENSION_RULES,
|
|
229
358
|
},
|
|
230
359
|
|
|
231
360
|
overrides: [
|
|
361
|
+
// We list a "blank" override for the purposes of enabling new file extensions. (ESLint adds any
|
|
362
|
+
// new extensions included in `overrides` to the list of linted extensions.)
|
|
363
|
+
{
|
|
364
|
+
files: ["*.ts", "*.tsx", "*.mts", "*.cts"],
|
|
365
|
+
},
|
|
366
|
+
|
|
232
367
|
// Disable some TypeScript-specific rules in JavaScript files.
|
|
233
368
|
{
|
|
234
369
|
files: ["*.js", "*.cjs", "*.mjs", "*.jsx"],
|
|
235
370
|
rules: {
|
|
236
371
|
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
372
|
+
"@typescript-eslint/no-require-imports": "off",
|
|
237
373
|
"@typescript-eslint/no-unsafe-argument": "off",
|
|
238
374
|
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
239
375
|
"@typescript-eslint/no-unsafe-call": "off",
|