eslint-config-complete 1.2.2 → 1.2.4
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/dist/base/base-eslint.d.ts +12 -0
- package/dist/base/base-eslint.d.ts.map +1 -0
- package/dist/base/base-eslint.js +670 -0
- package/dist/base/base-import-x.d.ts +12 -0
- package/dist/base/base-import-x.d.ts.map +1 -0
- package/dist/base/base-import-x.js +262 -0
- package/dist/base/base-jsdoc.d.ts +6 -0
- package/dist/base/base-jsdoc.d.ts.map +1 -0
- package/dist/base/base-jsdoc.js +212 -0
- package/dist/base/base-n.d.ts +7 -0
- package/dist/base/base-n.d.ts.map +1 -0
- package/dist/base/base-n.js +108 -0
- package/dist/base/base-stylistic.d.ts +6 -0
- package/dist/base/base-stylistic.d.ts.map +1 -0
- package/dist/base/base-stylistic.js +35 -0
- package/dist/base/base-typescript-eslint.d.ts +6 -0
- package/dist/base/base-typescript-eslint.d.ts.map +1 -0
- package/dist/base/base-typescript-eslint.js +479 -0
- package/dist/base/base-unicorn.d.ts +10 -0
- package/dist/base/base-unicorn.d.ts.map +1 -0
- package/dist/base/base-unicorn.js +203 -0
- package/dist/base.d.ts +8 -0
- package/dist/base.d.ts.map +1 -0
- package/{src → dist}/base.js +17 -30
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/monorepo.d.ts +6 -0
- package/dist/monorepo.d.ts.map +1 -0
- package/dist/monorepo.js +16 -0
- package/package.json +5 -3
- package/src/base/base-eslint.js +0 -850
- package/src/base/base-import-x.js +0 -312
- package/src/base/base-jsdoc.js +0 -276
- package/src/base/base-n.js +0 -150
- package/src/base/base-stylistic.js +0 -38
- package/src/base/base-typescript-eslint.js +0 -554
- package/src/base/base-unicorn.js +0 -246
- package/src/monorepo.js +0 -18
- /package/{src → dist}/index.js +0 -0
|
@@ -1,554 +0,0 @@
|
|
|
1
|
-
import tseslint from "typescript-eslint";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This ESLint config only contains rules from `@typescript-eslint/eslint-plugin`:
|
|
5
|
-
* https://typescript-eslint.io/rules/
|
|
6
|
-
*/
|
|
7
|
-
export const baseTypeScriptESLint = tseslint.config(
|
|
8
|
-
{
|
|
9
|
-
plugins: {
|
|
10
|
-
"@typescript-eslint": tseslint.plugin,
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
// We need to provide some special configuration to ESLint in order for it to parse TypeScript
|
|
14
|
-
// files. From:
|
|
15
|
-
// https://typescript-eslint.io/packages/typescript-eslint/#advanced-usage
|
|
16
|
-
languageOptions: {
|
|
17
|
-
parser: tseslint.parser,
|
|
18
|
-
parserOptions: {
|
|
19
|
-
projectService: {
|
|
20
|
-
// We whitelist some specific configuration files that downstream users may have in their
|
|
21
|
-
// projects. These files should be linted but should not be included in compiled output.
|
|
22
|
-
allowDefaultProject: [
|
|
23
|
-
"babel.config.js",
|
|
24
|
-
"babel.config.cjs",
|
|
25
|
-
"babel.config.mjs",
|
|
26
|
-
"eslint.config.js",
|
|
27
|
-
"eslint.config.cjs",
|
|
28
|
-
"eslint.config.mjs",
|
|
29
|
-
"jest.config.js",
|
|
30
|
-
"jest.config.cjs",
|
|
31
|
-
"jest.config.mjs",
|
|
32
|
-
"knip.js",
|
|
33
|
-
"knip.ts",
|
|
34
|
-
"knip.config.js",
|
|
35
|
-
"knip.config.ts",
|
|
36
|
-
"prettier.config.js",
|
|
37
|
-
"prettier.config.cjs",
|
|
38
|
-
"prettier.config.mjs",
|
|
39
|
-
"typedoc.config.js",
|
|
40
|
-
"typedoc.config.cjs",
|
|
41
|
-
"typedoc.config.mjs",
|
|
42
|
-
],
|
|
43
|
-
|
|
44
|
-
// By default, the whitelisted files above will use the default TypeScript compiler
|
|
45
|
-
// options. However, certain ESLint rules such as
|
|
46
|
-
// "@typescript-eslint/no-unnecessary-condition" and
|
|
47
|
-
// "@typescript-eslint/prefer-nullish-coalescing" require "strictNullChecks", which is not
|
|
48
|
-
// a default option. Thus, we need to specify that whitelisted files should use the
|
|
49
|
-
// "tsconfig.json" file that is beside the file in the same directory.
|
|
50
|
-
defaultProject: "tsconfig.json",
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
rules: {
|
|
56
|
-
"@typescript-eslint/adjacent-overload-signatures": "warn",
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* The default value is `array`. We choose `array-simple` because it makes complicated arrays
|
|
60
|
-
* easier to understand. This is worth the cost of deviating from the base rule configuration.
|
|
61
|
-
*/
|
|
62
|
-
"@typescript-eslint/array-type": [
|
|
63
|
-
"warn",
|
|
64
|
-
{
|
|
65
|
-
default: "array-simple",
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
|
|
69
|
-
"@typescript-eslint/await-thenable": "warn",
|
|
70
|
-
"@typescript-eslint/ban-ts-comment": "warn",
|
|
71
|
-
"@typescript-eslint/ban-tslint-comment": "warn",
|
|
72
|
-
"@typescript-eslint/class-literal-property-style": "warn",
|
|
73
|
-
"@typescript-eslint/consistent-generic-constructors": "warn",
|
|
74
|
-
"@typescript-eslint/consistent-indexed-object-style": "warn",
|
|
75
|
-
"@typescript-eslint/consistent-type-assertions": "warn",
|
|
76
|
-
"@typescript-eslint/consistent-type-definitions": "warn",
|
|
77
|
-
"@typescript-eslint/consistent-type-exports": "warn",
|
|
78
|
-
"@typescript-eslint/consistent-type-imports": "warn",
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Disabled since it would be to cumbersome to require return types for non-exported
|
|
82
|
-
* functions. (It is more reasonable to require it for exported functions only, since it
|
|
83
|
-
* speeds up the type-checker in large codebases.)
|
|
84
|
-
*/
|
|
85
|
-
"@typescript-eslint/explicit-function-return-type": "off",
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Disabled since many programs may have internal-only classes that would not benefit from an
|
|
89
|
-
* explicit public/private distinction.
|
|
90
|
-
*/
|
|
91
|
-
"@typescript-eslint/explicit-member-accessibility": "off",
|
|
92
|
-
|
|
93
|
-
"@typescript-eslint/explicit-module-boundary-types": "warn",
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Disabled because enforcing an arbitrary parameter number threshold for every function in a
|
|
97
|
-
* project does not provide much value. (Additionally, using TypeScript reduces the value of
|
|
98
|
-
* such a check.)
|
|
99
|
-
*/
|
|
100
|
-
"@typescript-eslint/max-params": "off",
|
|
101
|
-
|
|
102
|
-
"@typescript-eslint/member-delimiter-style": "off", // eslint-config-prettier
|
|
103
|
-
|
|
104
|
-
/** Disabled since prescribed class ordering is too project-specific. */
|
|
105
|
-
"@typescript-eslint/member-ordering": "off",
|
|
106
|
-
|
|
107
|
-
"@typescript-eslint/method-signature-style": "warn",
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* The options are [copied from
|
|
111
|
-
* Airbnb](https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js).
|
|
112
|
-
* We also allow a leading underscore, which signifies that the element is temporarily not
|
|
113
|
-
* being used.
|
|
114
|
-
*/
|
|
115
|
-
"@typescript-eslint/naming-convention": [
|
|
116
|
-
"warn",
|
|
117
|
-
// Allow camelCase variables (23.2), PascalCase variables (23.8), and UPPER_CASE variables
|
|
118
|
-
// (23.10).
|
|
119
|
-
{
|
|
120
|
-
selector: "variable",
|
|
121
|
-
format: ["camelCase", "PascalCase", "UPPER_CASE"],
|
|
122
|
-
leadingUnderscore: "allow",
|
|
123
|
-
},
|
|
124
|
-
// Allow camelCase functions (23.2), and PascalCase functions (23.8).
|
|
125
|
-
{
|
|
126
|
-
selector: "function",
|
|
127
|
-
format: ["camelCase", "PascalCase"],
|
|
128
|
-
leadingUnderscore: "allow",
|
|
129
|
-
},
|
|
130
|
-
// Airbnb recommends PascalCase for classes (23.3), and although Airbnb does not make
|
|
131
|
-
// TypeScript recommendations, we are assuming this rule would similarly apply to anything
|
|
132
|
-
// "type like", including interfaces, type aliases, and enums.
|
|
133
|
-
{
|
|
134
|
-
selector: "typeLike",
|
|
135
|
-
format: ["PascalCase"],
|
|
136
|
-
leadingUnderscore: "allow",
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
|
|
140
|
-
"@typescript-eslint/no-base-to-string": "warn",
|
|
141
|
-
"@typescript-eslint/no-confusing-non-null-assertion": "warn",
|
|
142
|
-
"@typescript-eslint/no-confusing-void-expression": "warn",
|
|
143
|
-
"@typescript-eslint/no-deprecated": "warn",
|
|
144
|
-
"@typescript-eslint/no-duplicate-enum-values": "warn",
|
|
145
|
-
"@typescript-eslint/no-duplicate-type-constituents": "warn",
|
|
146
|
-
"@typescript-eslint/no-dynamic-delete": "warn",
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* The `allowSingleExtends` option is enabled to allow for the common pattern of using using
|
|
150
|
-
* interfaces to provide an opaque type. (This can be useful with type-builders such as Zod,
|
|
151
|
-
* since `z.infer` uses `Expand`, which is sometimes not desired since it can lead to
|
|
152
|
-
* verbose/confusing mouseover tooltips and TypeScript errors.)
|
|
153
|
-
*/
|
|
154
|
-
"@typescript-eslint/no-empty-interface": [
|
|
155
|
-
"warn",
|
|
156
|
-
{
|
|
157
|
-
allowSingleExtends: true,
|
|
158
|
-
},
|
|
159
|
-
],
|
|
160
|
-
|
|
161
|
-
"@typescript-eslint/no-empty-object-type": "warn",
|
|
162
|
-
"@typescript-eslint/no-explicit-any": "warn",
|
|
163
|
-
"@typescript-eslint/no-extra-non-null-assertion": "warn",
|
|
164
|
-
"@typescript-eslint/no-extraneous-class": "warn",
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* - The `ignoreVoid` option is disabled to make the rule stricter.
|
|
168
|
-
* - The rule is disabled in "*.test.ts" files because the built-in Node test runner returns a
|
|
169
|
-
* promise that is not meant to be awaited.
|
|
170
|
-
*/
|
|
171
|
-
"@typescript-eslint/no-floating-promises": [
|
|
172
|
-
"warn",
|
|
173
|
-
{
|
|
174
|
-
ignoreVoid: false,
|
|
175
|
-
},
|
|
176
|
-
],
|
|
177
|
-
|
|
178
|
-
"@typescript-eslint/no-for-in-array": "warn",
|
|
179
|
-
"@typescript-eslint/no-import-type-side-effects": "warn",
|
|
180
|
-
"@typescript-eslint/no-inferrable-types": "warn",
|
|
181
|
-
"@typescript-eslint/no-invalid-void-type": "warn",
|
|
182
|
-
"@typescript-eslint/no-meaningless-void-operator": "warn",
|
|
183
|
-
"@typescript-eslint/no-misused-new": "warn",
|
|
184
|
-
"@typescript-eslint/no-misused-promises": "warn",
|
|
185
|
-
"@typescript-eslint/no-mixed-enums": "warn",
|
|
186
|
-
"@typescript-eslint/no-namespace": "warn",
|
|
187
|
-
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "warn",
|
|
188
|
-
"@typescript-eslint/no-non-null-asserted-optional-chain": "warn",
|
|
189
|
-
"@typescript-eslint/no-non-null-assertion": "warn",
|
|
190
|
-
"@typescript-eslint/no-redundant-type-constituents": "warn",
|
|
191
|
-
"@typescript-eslint/no-require-imports": "warn",
|
|
192
|
-
|
|
193
|
-
/** Disabled since this rule is intended to be used for project-specific types. */
|
|
194
|
-
"@typescript-eslint/no-restricted-types": "off",
|
|
195
|
-
|
|
196
|
-
"@typescript-eslint/no-this-alias": "warn",
|
|
197
|
-
|
|
198
|
-
/** Disabled because this rule is deprecated. */
|
|
199
|
-
"@typescript-eslint/no-type-alias": "off",
|
|
200
|
-
|
|
201
|
-
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn",
|
|
202
|
-
"@typescript-eslint/no-unnecessary-condition": "warn",
|
|
203
|
-
"@typescript-eslint/no-unnecessary-parameter-property-assignment": "warn",
|
|
204
|
-
"@typescript-eslint/no-unnecessary-qualifier": "warn",
|
|
205
|
-
"@typescript-eslint/no-unnecessary-template-expression": "warn",
|
|
206
|
-
"@typescript-eslint/no-unnecessary-type-arguments": "warn",
|
|
207
|
-
"@typescript-eslint/no-unnecessary-type-assertion": "warn",
|
|
208
|
-
"@typescript-eslint/no-unnecessary-type-constraint": "warn",
|
|
209
|
-
"@typescript-eslint/no-unnecessary-type-parameters": "warn",
|
|
210
|
-
"@typescript-eslint/no-unsafe-argument": "warn",
|
|
211
|
-
"@typescript-eslint/no-unsafe-assignment": "warn",
|
|
212
|
-
"@typescript-eslint/no-unsafe-call": "warn",
|
|
213
|
-
"@typescript-eslint/no-unsafe-declaration-merging": "warn",
|
|
214
|
-
"@typescript-eslint/no-unsafe-enum-comparison": "warn",
|
|
215
|
-
"@typescript-eslint/no-unsafe-function-type": "warn",
|
|
216
|
-
"@typescript-eslint/no-unsafe-member-access": "warn",
|
|
217
|
-
"@typescript-eslint/no-unsafe-return": "warn",
|
|
218
|
-
"@typescript-eslint/no-unsafe-unary-minus": "warn",
|
|
219
|
-
"@typescript-eslint/no-useless-empty-export": "warn",
|
|
220
|
-
"@typescript-eslint/no-var-requires": "warn",
|
|
221
|
-
"@typescript-eslint/no-wrapper-object-types": "warn",
|
|
222
|
-
"@typescript-eslint/non-nullable-type-assertion-style": "warn",
|
|
223
|
-
"@typescript-eslint/only-throw-error": "warn",
|
|
224
|
-
"@typescript-eslint/parameter-properties": "warn",
|
|
225
|
-
"@typescript-eslint/prefer-as-const": "warn",
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Object destructuring is enforced but array destructuring is not. This matches usage in the
|
|
229
|
-
* general TypeScript ecosystem.
|
|
230
|
-
*/
|
|
231
|
-
"@typescript-eslint/prefer-destructuring": [
|
|
232
|
-
"warn",
|
|
233
|
-
{
|
|
234
|
-
VariableDeclarator: {
|
|
235
|
-
array: false,
|
|
236
|
-
object: true,
|
|
237
|
-
},
|
|
238
|
-
AssignmentExpression: {
|
|
239
|
-
array: false,
|
|
240
|
-
object: true,
|
|
241
|
-
},
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
// We disable this for renamed properties, since code like the following should be valid:
|
|
245
|
-
// `const someSpecificMyEnum = MyEnum.Value1;`
|
|
246
|
-
enforceForRenamedProperties: false,
|
|
247
|
-
},
|
|
248
|
-
],
|
|
249
|
-
|
|
250
|
-
"@typescript-eslint/prefer-enum-initializers": "warn",
|
|
251
|
-
"@typescript-eslint/prefer-find": "warn",
|
|
252
|
-
"@typescript-eslint/prefer-for-of": "warn",
|
|
253
|
-
"@typescript-eslint/prefer-function-type": "warn",
|
|
254
|
-
"@typescript-eslint/prefer-includes": "warn",
|
|
255
|
-
"@typescript-eslint/prefer-literal-enum-member": "warn",
|
|
256
|
-
"@typescript-eslint/prefer-namespace-keyword": "warn",
|
|
257
|
-
"@typescript-eslint/prefer-nullish-coalescing": "warn",
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Disabled because it can modify the type of `boolean` declarations, which is [undesired in
|
|
261
|
-
* some
|
|
262
|
-
* circumstances](https://github.com/typescript-eslint/typescript-eslint/issues/5269).
|
|
263
|
-
*/
|
|
264
|
-
"@typescript-eslint/prefer-optional-chain": "off",
|
|
265
|
-
|
|
266
|
-
"@typescript-eslint/prefer-readonly": "warn",
|
|
267
|
-
|
|
268
|
-
/** Superseded by the `complete/prefer-readonly-parameter-types` rule. */
|
|
269
|
-
"@typescript-eslint/prefer-readonly-parameter-types": "off",
|
|
270
|
-
|
|
271
|
-
"@typescript-eslint/prefer-reduce-type-parameter": "warn",
|
|
272
|
-
|
|
273
|
-
/** Disabled since using the `String.match` form might make code easier to read. */
|
|
274
|
-
"@typescript-eslint/prefer-regexp-exec": "off",
|
|
275
|
-
|
|
276
|
-
"@typescript-eslint/prefer-return-this-type": "warn",
|
|
277
|
-
"@typescript-eslint/prefer-string-starts-ends-with": "warn",
|
|
278
|
-
"@typescript-eslint/prefer-ts-expect-error": "warn",
|
|
279
|
-
"@typescript-eslint/promise-function-async": "warn",
|
|
280
|
-
"@typescript-eslint/require-array-sort-compare": "warn",
|
|
281
|
-
|
|
282
|
-
/** The various "allow" options are disabled to make the rule stricter. */
|
|
283
|
-
"@typescript-eslint/restrict-plus-operands": [
|
|
284
|
-
"warn",
|
|
285
|
-
{
|
|
286
|
-
allowAny: false,
|
|
287
|
-
allowBoolean: false,
|
|
288
|
-
allowNullish: false,
|
|
289
|
-
allowNumberAndString: false,
|
|
290
|
-
allowRegExp: false,
|
|
291
|
-
},
|
|
292
|
-
],
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* Disabled since a common use-case of template strings is to coerce everything to a string.
|
|
296
|
-
*/
|
|
297
|
-
"@typescript-eslint/restrict-template-expressions": "off",
|
|
298
|
-
|
|
299
|
-
/** Disabled since in it does not make sense to sort a union alphabetically in many cases. */
|
|
300
|
-
"@typescript-eslint/sort-type-constituents": "off",
|
|
301
|
-
|
|
302
|
-
/** The `allowString` and `allowNumber` options are disabled to make the rule stricter. */
|
|
303
|
-
"@typescript-eslint/strict-boolean-expressions": [
|
|
304
|
-
"warn",
|
|
305
|
-
{
|
|
306
|
-
allowString: false,
|
|
307
|
-
allowNumber: false,
|
|
308
|
-
allowNullableObject: true,
|
|
309
|
-
allowNullableBoolean: false,
|
|
310
|
-
allowNullableString: false,
|
|
311
|
-
allowNullableNumber: false,
|
|
312
|
-
allowNullableEnum: false,
|
|
313
|
-
allowAny: false,
|
|
314
|
-
allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false,
|
|
315
|
-
},
|
|
316
|
-
],
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* The `allowDefaultCaseForExhaustiveSwitch` option is disabled and the
|
|
320
|
-
* `requireDefaultForNonUnion` option is enabled to make the rule stricter.
|
|
321
|
-
*/
|
|
322
|
-
"@typescript-eslint/switch-exhaustiveness-check": [
|
|
323
|
-
"warn",
|
|
324
|
-
{
|
|
325
|
-
allowDefaultCaseForExhaustiveSwitch: false,
|
|
326
|
-
requireDefaultForNonUnion: true,
|
|
327
|
-
},
|
|
328
|
-
],
|
|
329
|
-
|
|
330
|
-
"@typescript-eslint/triple-slash-reference": "warn",
|
|
331
|
-
"@typescript-eslint/type-annotation-spacing": "off", // eslint-config-prettier
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* Disabled since it is not recommended by the `typescript-eslint` team. (They recommend using
|
|
335
|
-
* the `noImplicitAny` and `strictPropertyInitialization` TypeScript compiler options
|
|
336
|
-
* instead.)
|
|
337
|
-
*/
|
|
338
|
-
"@typescript-eslint/typedef": "off",
|
|
339
|
-
|
|
340
|
-
"@typescript-eslint/unbound-method": "warn",
|
|
341
|
-
"@typescript-eslint/unified-signatures": "warn",
|
|
342
|
-
"@typescript-eslint/use-unknown-in-catch-callback-variable": "warn",
|
|
343
|
-
|
|
344
|
-
"@typescript-eslint/block-spacing": "off", // eslint-config-prettier
|
|
345
|
-
"@typescript-eslint/brace-style": "off", // eslint-config-prettier
|
|
346
|
-
"@typescript-eslint/class-methods-use-this": "warn",
|
|
347
|
-
"@typescript-eslint/comma-dangle": "off", // eslint-config-prettier
|
|
348
|
-
"@typescript-eslint/comma-spacing": "off", // eslint-config-prettier
|
|
349
|
-
|
|
350
|
-
/** Disabled since this is handled by the `noImplicitReturns` TypeScript compiler flag. */
|
|
351
|
-
"@typescript-eslint/consistent-return": "off",
|
|
352
|
-
|
|
353
|
-
"@typescript-eslint/default-param-last": "warn",
|
|
354
|
-
"@typescript-eslint/dot-notation": "warn",
|
|
355
|
-
"@typescript-eslint/func-call-spacing": "off", // eslint-config-prettier
|
|
356
|
-
"@typescript-eslint/indent": "off", // eslint-config-prettier
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Disabled since it is superfluous to require an `= undefined` during variable initialization
|
|
360
|
-
* (and TypeScript will take care of the non-undefined cases).
|
|
361
|
-
*/
|
|
362
|
-
"@typescript-eslint/init-declarations": "off",
|
|
363
|
-
|
|
364
|
-
"@typescript-eslint/key-spacing": "off", // eslint-config-prettier
|
|
365
|
-
"@typescript-eslint/keyword-spacing": "off", // eslint-config-prettier
|
|
366
|
-
"@typescript-eslint/no-array-constructor": "warn",
|
|
367
|
-
"@typescript-eslint/no-array-delete": "warn",
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* Disabled since it is superfluous when using TypeScript according to [the ESLint
|
|
371
|
-
* documentation](https://eslint.org/docs/latest/rules/no-dupe-class-members#when-not-to-use-it).
|
|
372
|
-
*/
|
|
373
|
-
"@typescript-eslint/no-dupe-class-members": "off",
|
|
374
|
-
|
|
375
|
-
"@typescript-eslint/no-empty-function": "warn",
|
|
376
|
-
"@typescript-eslint/no-extra-parens": "off", // eslint-config-prettier
|
|
377
|
-
"@typescript-eslint/no-extra-semi": "off", // eslint-config-prettier
|
|
378
|
-
"@typescript-eslint/no-implied-eval": "warn",
|
|
379
|
-
|
|
380
|
-
/** The `capIsConstructor` option is disabled to make the rule stricter. */
|
|
381
|
-
"@typescript-eslint/no-invalid-this": [
|
|
382
|
-
"warn",
|
|
383
|
-
{
|
|
384
|
-
capIsConstructor: false,
|
|
385
|
-
},
|
|
386
|
-
],
|
|
387
|
-
|
|
388
|
-
"@typescript-eslint/no-loop-func": "warn",
|
|
389
|
-
"@typescript-eslint/no-loss-of-precision": "warn",
|
|
390
|
-
|
|
391
|
-
/** Disabled since it results in too many false positives. */
|
|
392
|
-
"@typescript-eslint/no-magic-numbers": "off",
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* Disabled since it is handled by the combination of the TypeScript compiler and the `no-var`
|
|
396
|
-
* ESLint rule.
|
|
397
|
-
*/
|
|
398
|
-
"@typescript-eslint/no-redeclare": "off",
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* Configured to prevent importing with some common patterns that are almost always a mistake:
|
|
402
|
-
*
|
|
403
|
-
* - "src" directories (but allowed in test files that are in a separate "tests" directory)
|
|
404
|
-
* - "dist" directories
|
|
405
|
-
* - "index" files (things in the same package should directly import instead of use the
|
|
406
|
-
* public API)
|
|
407
|
-
*/
|
|
408
|
-
"@typescript-eslint/no-restricted-imports": [
|
|
409
|
-
"warn",
|
|
410
|
-
{
|
|
411
|
-
patterns: [
|
|
412
|
-
// Some "src" directories have an "index.ts" file, which means that importing from the
|
|
413
|
-
// directory is valid. Thus, we check for the "src" directory with no suffix.
|
|
414
|
-
{
|
|
415
|
-
group: ["**/src"],
|
|
416
|
-
message:
|
|
417
|
-
'You cannot import from a "src" directory. If this is a monorepo, import using the package name like you would in a non-monorepo project.',
|
|
418
|
-
},
|
|
419
|
-
|
|
420
|
-
{
|
|
421
|
-
group: ["**/src/**"],
|
|
422
|
-
message:
|
|
423
|
-
'You cannot import from a "src" directory. If this is a monorepo, import using the package name like you would in a non-monorepo project.',
|
|
424
|
-
},
|
|
425
|
-
|
|
426
|
-
// Some "dist" directories have an "index.ts" file, which means that importing from the
|
|
427
|
-
// directory is valid. Thus, we check for the "dist" directory with no suffix.
|
|
428
|
-
{
|
|
429
|
-
group: ["**/dist"],
|
|
430
|
-
message:
|
|
431
|
-
'You cannot import from a "dist" directory. If this is a monorepo, import using the package name like you would in a non-monorepo project.',
|
|
432
|
-
},
|
|
433
|
-
|
|
434
|
-
{
|
|
435
|
-
group: ["**/dist/**"],
|
|
436
|
-
message:
|
|
437
|
-
'You cannot import from a "dist" directory. If this is a monorepo, import using the package name like you would in a non-monorepo project.',
|
|
438
|
-
},
|
|
439
|
-
|
|
440
|
-
{
|
|
441
|
-
group: ["**/index"],
|
|
442
|
-
message:
|
|
443
|
-
"You cannot import from a package index. Instead, import directly from the file where the code is located.",
|
|
444
|
-
},
|
|
445
|
-
|
|
446
|
-
{
|
|
447
|
-
group: ["**/index.{js,cjs,mjs,ts,cts,mts}"],
|
|
448
|
-
message:
|
|
449
|
-
"You cannot import from a package index. Instead, import directly from the file where the code is located.",
|
|
450
|
-
},
|
|
451
|
-
],
|
|
452
|
-
},
|
|
453
|
-
],
|
|
454
|
-
|
|
455
|
-
"@typescript-eslint/no-shadow": "warn",
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* The `allowTaggedTemplates` option is enabled to allow the rule to work with libraries like
|
|
459
|
-
* `execa`.
|
|
460
|
-
*/
|
|
461
|
-
"@typescript-eslint/no-unused-expressions": [
|
|
462
|
-
"warn",
|
|
463
|
-
{
|
|
464
|
-
allowTaggedTemplates: true,
|
|
465
|
-
},
|
|
466
|
-
],
|
|
467
|
-
|
|
468
|
-
/**
|
|
469
|
-
* The `args` option is set to `all` make the rule stricter. Additionally, we ignore things
|
|
470
|
-
* that begin with an underscore, since this matches the behavior of the `--noUnusedLocals`
|
|
471
|
-
* TypeScript compiler flag.
|
|
472
|
-
*/
|
|
473
|
-
"@typescript-eslint/no-unused-vars": [
|
|
474
|
-
"warn",
|
|
475
|
-
{
|
|
476
|
-
args: "all", // "after-used" is the default.
|
|
477
|
-
argsIgnorePattern: "^_",
|
|
478
|
-
varsIgnorePattern: "^_",
|
|
479
|
-
},
|
|
480
|
-
],
|
|
481
|
-
|
|
482
|
-
/** Disabled because it can prevent code from being structured sequentially. */
|
|
483
|
-
"@typescript-eslint/no-use-before-define": "off",
|
|
484
|
-
|
|
485
|
-
"@typescript-eslint/no-useless-constructor": "warn",
|
|
486
|
-
"@typescript-eslint/object-curly-spacing": "off", // eslint-config-prettier
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* Disabled since it is for inserting extra newlines between specific kinds of statements,
|
|
490
|
-
* which would be project-dependant. (This kind of formatting is not handled by Prettier.)
|
|
491
|
-
*/
|
|
492
|
-
"@typescript-eslint/padding-line-between-statements": "off",
|
|
493
|
-
|
|
494
|
-
/** The `allowEmptyReject` option is enabled since this is a common pattern. */
|
|
495
|
-
"@typescript-eslint/prefer-promise-reject-errors": [
|
|
496
|
-
"warn",
|
|
497
|
-
{
|
|
498
|
-
allowEmptyReject: true,
|
|
499
|
-
},
|
|
500
|
-
],
|
|
501
|
-
|
|
502
|
-
"@typescript-eslint/require-await": "warn",
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* Even though the core rule was deprecated, the extended rule uses type information, so it is
|
|
506
|
-
* much better.
|
|
507
|
-
*/
|
|
508
|
-
"@typescript-eslint/return-await": "warn",
|
|
509
|
-
|
|
510
|
-
"@typescript-eslint/semi": "off", // eslint-config-prettier
|
|
511
|
-
"@typescript-eslint/space-before-blocks": "off", // eslint-config-prettier
|
|
512
|
-
"@typescript-eslint/space-before-function-paren": "off", // eslint-config-prettier
|
|
513
|
-
"@typescript-eslint/space-infix-ops": "off", // eslint-config-prettier
|
|
514
|
-
},
|
|
515
|
-
},
|
|
516
|
-
|
|
517
|
-
// Enable linting on TypeScript file extensions.
|
|
518
|
-
{
|
|
519
|
-
files: ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts"],
|
|
520
|
-
},
|
|
521
|
-
|
|
522
|
-
// Disable some TypeScript-specific rules in JavaScript files.
|
|
523
|
-
{
|
|
524
|
-
files: ["**/*.js", "**/*.cjs", "**/*.mjs", "**/*.jsx"],
|
|
525
|
-
rules: {
|
|
526
|
-
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
527
|
-
"@typescript-eslint/no-require-imports": "off",
|
|
528
|
-
"@typescript-eslint/no-unsafe-argument": "off",
|
|
529
|
-
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
530
|
-
"@typescript-eslint/no-unsafe-call": "off",
|
|
531
|
-
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
532
|
-
"@typescript-eslint/no-unsafe-return": "off",
|
|
533
|
-
"@typescript-eslint/no-var-requires": "off",
|
|
534
|
-
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
535
|
-
},
|
|
536
|
-
},
|
|
537
|
-
|
|
538
|
-
// The built-in Node.js test-runner returns a promise which is not meant to be awaited.
|
|
539
|
-
{
|
|
540
|
-
files: ["**/*.test.{js,cjs,mjs,ts,cts,mts}"],
|
|
541
|
-
rules: {
|
|
542
|
-
"@typescript-eslint/no-floating-promises": "off",
|
|
543
|
-
},
|
|
544
|
-
},
|
|
545
|
-
|
|
546
|
-
// We want to be allowed to import from the "src" directory in test files that are located in a
|
|
547
|
-
// separate "tests" directory.
|
|
548
|
-
{
|
|
549
|
-
files: ["**/tests/**"],
|
|
550
|
-
rules: {
|
|
551
|
-
"@typescript-eslint/no-restricted-imports": "off",
|
|
552
|
-
},
|
|
553
|
-
},
|
|
554
|
-
);
|