eslint-config-isaacscript 3.7.1 → 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 +715 -284
- package/base-import.js +224 -0
- package/base-jsdoc.js +140 -150
- package/base-n.js +146 -0
- package/base-no-autofix.js +18 -0
- package/base-typescript-eslint.js +365 -210
- package/base-unicorn.js +227 -0
- package/base.js +23 -340
- package/mod.js +112 -98
- package/monorepo.js +12 -27
- package/package.json +5 -2
|
@@ -1,222 +1,375 @@
|
|
|
1
|
-
// This
|
|
2
|
-
// https://eslint.
|
|
3
|
-
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
//
|
|
71
|
-
{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
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-confusing-void-expression
|
|
88
|
-
*
|
|
89
|
-
* Not defined in the parent configs.
|
|
90
|
-
*
|
|
91
|
-
* This prevents assigning void to variables, which is almost certainly a bug.
|
|
92
|
-
*/
|
|
93
|
-
"@typescript-eslint/no-confusing-void-expression": "warn",
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Documentation:
|
|
97
|
-
* https://typescript-eslint.io/rules/no-unnecessary-boolean-literal-compare
|
|
98
|
-
*
|
|
99
|
-
* Not defined in the parent configs.
|
|
100
|
-
*
|
|
101
|
-
* This prevents useless code after refactoring variables to pure booleans.
|
|
102
|
-
*/
|
|
103
|
-
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn",
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Documentation:
|
|
107
|
-
* https://typescript-eslint.io/rules/no-unused-vars
|
|
108
|
-
*
|
|
109
|
-
* Defined at:
|
|
110
|
-
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/variables.js
|
|
111
|
-
*
|
|
112
|
-
* We want to lint unused arguments (the default is "after-used"). We also want to ignore
|
|
113
|
-
* arguments/variables that start with an underscore. This matches the behavior of the
|
|
114
|
-
* TypeScript compiler flag "--noUnusedLocals".
|
|
115
|
-
*/
|
|
116
|
-
"@typescript-eslint/no-unused-vars": [
|
|
117
|
-
"warn",
|
|
118
|
-
{
|
|
119
|
-
args: "all",
|
|
120
|
-
argsIgnorePattern: "^_",
|
|
121
|
-
varsIgnorePattern: "^_",
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Documentation:
|
|
127
|
-
* https://typescript-eslint.io/rules/no-use-before-define
|
|
128
|
-
*
|
|
129
|
-
* Defined at:
|
|
130
|
-
* https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/variables.js
|
|
131
|
-
*
|
|
132
|
-
* This allows code to be structured in a more logical order.
|
|
133
|
-
*/
|
|
134
|
-
"@typescript-eslint/no-use-before-define": "off",
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Documentation:
|
|
138
|
-
* https://typescript-eslint.io/rules/prefer-optional-chain
|
|
139
|
-
*
|
|
140
|
-
* Defined at:
|
|
141
|
-
* https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/strict.ts
|
|
142
|
-
*
|
|
143
|
-
* This can modify the type of boolean declarations to `boolean | undefined`, which is undesired
|
|
144
|
-
* in some circumstances:
|
|
145
|
-
* https://github.com/typescript-eslint/typescript-eslint/issues/5269
|
|
146
|
-
*/
|
|
147
|
-
"@typescript-eslint/prefer-optional-chain": "off",
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Documentation:
|
|
151
|
-
* https://typescript-eslint.io/rules/quotes
|
|
152
|
-
*
|
|
153
|
-
* Defined at:
|
|
154
|
-
* https://github.com/prettier/eslint-config-prettier/blob/main/%40typescript-eslint.js
|
|
155
|
-
*
|
|
156
|
-
* In order to forbid unnecessary backticks, we must re-enable the "@typescript-eslint/quotes"
|
|
157
|
-
* rule as specified in the eslint-config-prettier documentation:
|
|
158
|
-
* https://github.com/prettier/eslint-config-prettier#enforce-backticks
|
|
159
|
-
*/
|
|
160
|
-
"@typescript-eslint/quotes": [
|
|
161
|
-
"warn",
|
|
162
|
-
"double",
|
|
163
|
-
{
|
|
164
|
-
avoidEscape: true,
|
|
165
|
-
allowTemplateLiterals: false,
|
|
166
|
-
},
|
|
167
|
-
],
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Documentation:
|
|
171
|
-
* https://typescript-eslint.io/rules/restrict-template-expressions
|
|
172
|
-
*
|
|
173
|
-
* Defined at:
|
|
174
|
-
* https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts
|
|
175
|
-
*
|
|
176
|
-
* This rule disallows booleans and nulls in template expressions. However, a common use-case of
|
|
177
|
-
* template strings is to coerce everything to a string.
|
|
178
|
-
*/
|
|
179
|
-
"@typescript-eslint/restrict-template-expressions": "off",
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Documentation:
|
|
183
|
-
* https://typescript-eslint.io/rules/strict-boolean-expressions
|
|
184
|
-
*
|
|
185
|
-
* Not defined in the parent configs.
|
|
186
|
-
*
|
|
187
|
-
* This rule prevents bugs when refactoring a boolean to a number.
|
|
188
|
-
*/
|
|
189
|
-
"@typescript-eslint/strict-boolean-expressions": [
|
|
190
|
-
"warn",
|
|
191
|
-
{
|
|
192
|
-
allowString: false,
|
|
193
|
-
allowNumber: false,
|
|
194
|
-
allowNullableObject: false,
|
|
195
|
-
allowNullableBoolean: false,
|
|
196
|
-
allowNullableString: false,
|
|
197
|
-
allowNullableNumber: false,
|
|
198
|
-
allowAny: false,
|
|
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
|
|
7
|
+
|
|
8
|
+
/** @type {import("eslint").Linter.RulesRecord} */
|
|
9
|
+
const SUPPORTED_RULES = {
|
|
10
|
+
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
11
|
+
|
|
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
|
+
},
|
|
21
|
+
],
|
|
22
|
+
|
|
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,
|
|
199
74
|
},
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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,
|
|
212
358
|
},
|
|
213
359
|
|
|
214
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
|
+
|
|
215
367
|
// Disable some TypeScript-specific rules in JavaScript files.
|
|
216
368
|
{
|
|
217
369
|
files: ["*.js", "*.cjs", "*.mjs", "*.jsx"],
|
|
218
370
|
rules: {
|
|
219
371
|
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
372
|
+
"@typescript-eslint/no-require-imports": "off",
|
|
220
373
|
"@typescript-eslint/no-unsafe-argument": "off",
|
|
221
374
|
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
222
375
|
"@typescript-eslint/no-unsafe-call": "off",
|
|
@@ -228,3 +381,5 @@ module.exports = {
|
|
|
228
381
|
},
|
|
229
382
|
],
|
|
230
383
|
};
|
|
384
|
+
|
|
385
|
+
module.exports = config;
|