@typescript-eslint/eslint-plugin 8.9.1-alpha.0 → 8.9.1-alpha.10
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/rules/class-literal-property-style.js +1 -0
- package/dist/rules/class-literal-property-style.js.map +1 -1
- package/dist/rules/class-methods-use-this.js +3 -3
- package/dist/rules/class-methods-use-this.js.map +1 -1
- package/dist/rules/consistent-generic-constructors.js +1 -0
- package/dist/rules/consistent-generic-constructors.js.map +1 -1
- package/dist/rules/consistent-indexed-object-style.js +1 -0
- package/dist/rules/consistent-indexed-object-style.js.map +1 -1
- package/dist/rules/consistent-type-definitions.js +1 -0
- package/dist/rules/consistent-type-definitions.js.map +1 -1
- package/dist/rules/consistent-type-exports.js +10 -4
- package/dist/rules/consistent-type-exports.js.map +1 -1
- package/dist/rules/explicit-member-accessibility.js +5 -1
- package/dist/rules/explicit-member-accessibility.js.map +1 -1
- package/dist/rules/explicit-module-boundary-types.js.map +1 -1
- package/dist/rules/naming-convention.js +2 -1
- package/dist/rules/naming-convention.js.map +1 -1
- package/dist/rules/no-invalid-void-type.js +7 -3
- package/dist/rules/no-invalid-void-type.js.map +1 -1
- package/dist/rules/no-misused-promises.js +7 -1
- package/dist/rules/no-misused-promises.js.map +1 -1
- package/dist/rules/no-restricted-imports.js +1 -1
- package/dist/rules/no-restricted-imports.js.map +1 -1
- package/dist/rules/no-restricted-types.js +5 -4
- package/dist/rules/no-restricted-types.js.map +1 -1
- package/dist/rules/no-unnecessary-condition.js +0 -1
- package/dist/rules/no-unnecessary-condition.js.map +1 -1
- package/dist/rules/no-unsafe-argument.js +2 -1
- package/dist/rules/no-unsafe-argument.js.map +1 -1
- package/dist/rules/no-use-before-define.js +4 -1
- package/dist/rules/no-use-before-define.js.map +1 -1
- package/dist/rules/prefer-destructuring.js +2 -0
- package/dist/rules/prefer-destructuring.js.map +1 -1
- package/dist/rules/prefer-nullish-coalescing.js +18 -4
- package/dist/rules/prefer-nullish-coalescing.js.map +1 -1
- package/dist/rules/sort-type-constituents.js +3 -3
- package/dist/rules/sort-type-constituents.js.map +1 -1
- package/dist/rules/strict-boolean-expressions.js +5 -4
- package/dist/rules/strict-boolean-expressions.js.map +1 -1
- package/docs/rules/ban-ts-comment.mdx +4 -0
- package/docs/rules/class-methods-use-this.mdx +4 -1
- package/docs/rules/consistent-generic-constructors.mdx +6 -4
- package/docs/rules/consistent-indexed-object-style.mdx +6 -4
- package/docs/rules/consistent-type-assertions.mdx +4 -2
- package/docs/rules/consistent-type-definitions.mdx +8 -4
- package/docs/rules/consistent-type-exports.mdx +2 -1
- package/docs/rules/consistent-type-imports.mdx +7 -4
- package/docs/rules/dot-notation.mdx +5 -3
- package/docs/rules/explicit-function-return-type.mdx +16 -0
- package/docs/rules/explicit-member-accessibility.mdx +7 -2
- package/docs/rules/explicit-module-boundary-types.mdx +22 -12
- package/docs/rules/max-params.mdx +1 -1
- package/docs/rules/method-signature-style.mdx +4 -2
- package/docs/rules/no-base-to-string.mdx +5 -3
- package/docs/rules/no-confusing-void-expression.mdx +4 -0
- package/docs/rules/no-duplicate-type-constituents.mdx +4 -0
- package/docs/rules/no-empty-interface.mdx +3 -1
- package/docs/rules/no-empty-object-type.mdx +8 -3
- package/docs/rules/no-explicit-any.mdx +3 -1
- package/docs/rules/no-extraneous-class.mdx +4 -4
- package/docs/rules/no-floating-promises.mdx +12 -6
- package/docs/rules/no-inferrable-types.mdx +2 -2
- package/docs/rules/no-invalid-void-type.mdx +4 -3
- package/docs/rules/no-magic-numbers.mdx +8 -0
- package/docs/rules/no-meaningless-void-operator.mdx +1 -1
- package/docs/rules/no-misused-promises.mdx +11 -1
- package/docs/rules/no-namespace.mdx +4 -0
- package/docs/rules/no-redeclare.mdx +3 -1
- package/docs/rules/no-require-imports.mdx +6 -2
- package/docs/rules/no-restricted-imports.mdx +4 -1
- package/docs/rules/no-restricted-types.mdx +1 -1
- package/docs/rules/no-shadow.mdx +4 -2
- package/docs/rules/no-this-alias.mdx +4 -0
- package/docs/rules/no-type-alias.mdx +8 -8
- package/docs/rules/no-unnecessary-boolean-literal-compare.mdx +4 -0
- package/docs/rules/no-unnecessary-condition.mdx +6 -0
- package/docs/rules/no-unnecessary-type-assertion.mdx +2 -0
- package/docs/rules/no-use-before-define.mdx +3 -3
- package/docs/rules/no-var-requires.mdx +2 -0
- package/docs/rules/parameter-properties.mdx +6 -2
- package/docs/rules/prefer-destructuring.mdx +1 -1
- package/docs/rules/prefer-literal-enum-member.mdx +1 -1
- package/docs/rules/prefer-nullish-coalescing.mdx +6 -4
- package/docs/rules/prefer-optional-chain.mdx +37 -28
- package/docs/rules/prefer-readonly-parameter-types.mdx +8 -4
- package/docs/rules/prefer-readonly.mdx +1 -1
- package/docs/rules/prefer-string-starts-ends-with.mdx +2 -0
- package/docs/rules/promise-function-async.mdx +8 -9
- package/docs/rules/require-array-sort-compare.mdx +2 -0
- package/docs/rules/restrict-plus-operands.mdx +12 -0
- package/docs/rules/restrict-template-expressions.mdx +9 -7
- package/docs/rules/return-await.mdx +4 -0
- package/docs/rules/sort-type-constituents.mdx +5 -3
- package/docs/rules/strict-boolean-expressions.mdx +22 -12
- package/docs/rules/switch-exhaustiveness-check.mdx +6 -2
- package/docs/rules/triple-slash-reference.mdx +6 -0
- package/docs/rules/typedef.mdx +8 -8
- package/docs/rules/unbound-method.mdx +2 -0
- package/docs/rules/unified-signatures.mdx +2 -0
- package/package.json +7 -7
@@ -68,6 +68,8 @@ Specifically the argument of the not operator (`!loose`) or a bare value in a lo
|
|
68
68
|
|
69
69
|
### `allowPotentiallyUnsafeFixesThatModifyTheReturnTypeIKnowWhatImDoing`
|
70
70
|
|
71
|
+
{/* insert option description */}
|
72
|
+
|
71
73
|
When this option is `true`, the rule will provide an auto-fixer for cases where the return type of the expression would change. For example for the expression `!foo || foo.bar` the return type of the expression is `true | T`, however for the equivalent optional chain `foo?.bar` the return type of the expression is `undefined | T`. Thus changing the code from a logical expression to an optional chain expression has altered the type of the expression.
|
72
74
|
|
73
75
|
In some cases this distinction _may_ matter - which is why these fixers are considered unsafe - they may break the build! For example in the following code:
|
@@ -89,11 +91,12 @@ When this option is `false` unsafe cases will have suggestion fixers provided in
|
|
89
91
|
|
90
92
|
### `checkAny`
|
91
93
|
|
92
|
-
|
94
|
+
{/* insert option description */}
|
93
95
|
|
94
|
-
|
96
|
+
Examples of code for this rule with `{ checkAny: false }`:
|
95
97
|
|
96
|
-
<
|
98
|
+
<Tabs>
|
99
|
+
<TabItem value="❌ Incorrect">
|
97
100
|
|
98
101
|
```ts option='{ "checkAny": true }'
|
99
102
|
declare const thing: any;
|
@@ -102,7 +105,7 @@ thing && thing.toString();
|
|
102
105
|
```
|
103
106
|
|
104
107
|
</TabItem>
|
105
|
-
<TabItem value="✅ Correct
|
108
|
+
<TabItem value="✅ Correct">
|
106
109
|
|
107
110
|
```ts option='{ "checkAny": false }'
|
108
111
|
declare const thing: any;
|
@@ -115,11 +118,12 @@ thing && thing.toString();
|
|
115
118
|
|
116
119
|
### `checkUnknown`
|
117
120
|
|
118
|
-
|
121
|
+
{/* insert option description */}
|
119
122
|
|
120
|
-
|
123
|
+
Examples of code for this rule with `{ checkUnknown: false }`:
|
121
124
|
|
122
|
-
<
|
125
|
+
<Tabs>
|
126
|
+
<TabItem value="❌ Incorrect">
|
123
127
|
|
124
128
|
```ts option='{ "checkUnknown": true }'
|
125
129
|
declare const thing: unknown;
|
@@ -128,7 +132,7 @@ thing && thing.toString();
|
|
128
132
|
```
|
129
133
|
|
130
134
|
</TabItem>
|
131
|
-
<TabItem value="✅ Correct
|
135
|
+
<TabItem value="✅ Correct">
|
132
136
|
|
133
137
|
```ts option='{ "checkUnknown": false }'
|
134
138
|
declare const thing: unknown;
|
@@ -141,11 +145,12 @@ thing && thing.toString();
|
|
141
145
|
|
142
146
|
### `checkString`
|
143
147
|
|
144
|
-
|
148
|
+
{/* insert option description */}
|
145
149
|
|
146
|
-
|
150
|
+
Examples of code for this rule with `{ checkString: false }`:
|
147
151
|
|
148
|
-
<
|
152
|
+
<Tabs>
|
153
|
+
<TabItem value="❌ Incorrect">
|
149
154
|
|
150
155
|
```ts option='{ "checkString": true }'
|
151
156
|
declare const thing: string;
|
@@ -154,7 +159,7 @@ thing && thing.toString();
|
|
154
159
|
```
|
155
160
|
|
156
161
|
</TabItem>
|
157
|
-
<TabItem value="✅ Correct
|
162
|
+
<TabItem value="✅ Correct">
|
158
163
|
|
159
164
|
```ts option='{ "checkString": false }'
|
160
165
|
declare const thing: string;
|
@@ -167,11 +172,12 @@ thing && thing.toString();
|
|
167
172
|
|
168
173
|
### `checkNumber`
|
169
174
|
|
170
|
-
|
175
|
+
{/* insert option description */}
|
171
176
|
|
172
|
-
|
177
|
+
Examples of code for this rule with `{ checkNumber: false }`:
|
173
178
|
|
174
|
-
<
|
179
|
+
<Tabs>
|
180
|
+
<TabItem value="❌ Incorrect">
|
175
181
|
|
176
182
|
```ts option='{ "checkNumber": true }'
|
177
183
|
declare const thing: number;
|
@@ -180,7 +186,7 @@ thing && thing.toString();
|
|
180
186
|
```
|
181
187
|
|
182
188
|
</TabItem>
|
183
|
-
<TabItem value="✅ Correct
|
189
|
+
<TabItem value="✅ Correct">
|
184
190
|
|
185
191
|
```ts option='{ "checkNumber": false }'
|
186
192
|
declare const thing: number;
|
@@ -193,7 +199,7 @@ thing && thing.toString();
|
|
193
199
|
|
194
200
|
### `checkBoolean`
|
195
201
|
|
196
|
-
|
202
|
+
{/* insert option description */}
|
197
203
|
|
198
204
|
:::note
|
199
205
|
|
@@ -209,9 +215,10 @@ The boolean expression narrows out the non-nullish falsy cases - so converting t
|
|
209
215
|
|
210
216
|
:::
|
211
217
|
|
212
|
-
|
218
|
+
Examples of code for this rule with `{ checkBoolean: false }`:
|
213
219
|
|
214
|
-
<
|
220
|
+
<Tabs>
|
221
|
+
<TabItem value="❌ Incorrect">
|
215
222
|
|
216
223
|
```ts option='{ "checkBoolean": true }'
|
217
224
|
declare const thing: true;
|
@@ -220,7 +227,7 @@ thing && thing.toString();
|
|
220
227
|
```
|
221
228
|
|
222
229
|
</TabItem>
|
223
|
-
<TabItem value="✅ Correct
|
230
|
+
<TabItem value="✅ Correct">
|
224
231
|
|
225
232
|
```ts option='{ "checkBoolean": false }'
|
226
233
|
declare const thing: true;
|
@@ -233,11 +240,12 @@ thing && thing.toString();
|
|
233
240
|
|
234
241
|
### `checkBigInt`
|
235
242
|
|
236
|
-
|
243
|
+
{/* insert option description */}
|
237
244
|
|
238
|
-
|
245
|
+
Examples of code for this rule with `{ checkBigInt: false }`:
|
239
246
|
|
240
|
-
<
|
247
|
+
<Tabs>
|
248
|
+
<TabItem value="❌ Incorrect">
|
241
249
|
|
242
250
|
```ts option='{ "checkBigInt": true }'
|
243
251
|
declare const thing: bigint;
|
@@ -246,7 +254,7 @@ thing && thing.toString();
|
|
246
254
|
```
|
247
255
|
|
248
256
|
</TabItem>
|
249
|
-
<TabItem value="✅ Correct
|
257
|
+
<TabItem value="✅ Correct">
|
250
258
|
|
251
259
|
```ts option='{ "checkBigInt": false }'
|
252
260
|
declare const thing: bigint;
|
@@ -259,11 +267,12 @@ thing && thing.toString();
|
|
259
267
|
|
260
268
|
### `requireNullish`
|
261
269
|
|
262
|
-
|
270
|
+
{/* insert option description */}
|
263
271
|
|
264
|
-
|
272
|
+
Examples of code for this rule with `{ requireNullish: false }`:
|
265
273
|
|
266
|
-
<
|
274
|
+
<Tabs>
|
275
|
+
<TabItem value="❌ Incorrect">
|
267
276
|
|
268
277
|
```ts option='{ "requireNullish": true }'
|
269
278
|
declare const thing1: string | null;
|
@@ -271,7 +280,7 @@ thing1 && thing1.toString();
|
|
271
280
|
```
|
272
281
|
|
273
282
|
</TabItem>
|
274
|
-
<TabItem value="✅ Correct
|
283
|
+
<TabItem value="✅ Correct">
|
275
284
|
|
276
285
|
```ts option='{ "requireNullish": true }'
|
277
286
|
declare const thing1: string | null;
|
@@ -140,7 +140,8 @@ interface Foo {
|
|
140
140
|
|
141
141
|
### `allow`
|
142
142
|
|
143
|
-
|
143
|
+
{/* insert option description */}
|
144
|
+
|
144
145
|
Some complex types cannot easily be made readonly, for example the `HTMLElement` type or the `JQueryStatic` type from `@types/jquery`. This option allows you to globally disable reporting of such types.
|
145
146
|
|
146
147
|
This option takes the shared [`TypeOrValueSpecifier` format](/packages/type-utils/type-or-value-specifier).
|
@@ -251,7 +252,8 @@ function fn(arg: Foo) {}
|
|
251
252
|
|
252
253
|
### `checkParameterProperties`
|
253
254
|
|
254
|
-
|
255
|
+
{/* insert option description */}
|
256
|
+
|
255
257
|
Because parameter properties create properties on the class, it may be undesirable to force them to be readonly.
|
256
258
|
|
257
259
|
Examples of code for this rule with `{checkParameterProperties: true}`:
|
@@ -290,7 +292,8 @@ class Foo {
|
|
290
292
|
|
291
293
|
### `ignoreInferredTypes`
|
292
294
|
|
293
|
-
|
295
|
+
{/* insert option description */}
|
296
|
+
|
294
297
|
This may be desirable in cases where an external dependency specifies a callback with mutable parameters, and manually annotating the callback's parameters is undesirable.
|
295
298
|
|
296
299
|
Examples of code for this rule with `{ignoreInferredTypes: true}`:
|
@@ -348,7 +351,8 @@ export const acceptsCallback: AcceptsCallback;
|
|
348
351
|
|
349
352
|
### `treatMethodsAsReadonly`
|
350
353
|
|
351
|
-
|
354
|
+
{/* insert option description */}
|
355
|
+
|
352
356
|
This may be desirable when you are never reassigning methods.
|
353
357
|
|
354
358
|
Examples of code for this rule with `{treatMethodsAsReadonly: false}`:
|
@@ -62,6 +62,8 @@ foo.endsWith('bar');
|
|
62
62
|
|
63
63
|
### `allowSingleElementEquality`
|
64
64
|
|
65
|
+
{/* insert option description */}
|
66
|
+
|
65
67
|
If switched to `'always'`, the rule will allow equality checks against the first or last character in a string.
|
66
68
|
This can be preferable in projects that don't deal with special character encodings and prefer a more succinct style.
|
67
69
|
|
@@ -68,7 +68,8 @@ async function functionReturnsUnionWithPromiseImplicitly(p: boolean) {
|
|
68
68
|
|
69
69
|
### `allowAny`
|
70
70
|
|
71
|
-
|
71
|
+
{/* insert option description */}
|
72
|
+
|
72
73
|
If you want additional safety, consider turning this option off, as it makes the rule less able to catch incorrect Promise behaviors.
|
73
74
|
|
74
75
|
Examples of code with `{ "allowAny": false }`:
|
@@ -92,6 +93,8 @@ const returnsAny = async () => ({}) as any;
|
|
92
93
|
|
93
94
|
### `allowedPromiseNames`
|
94
95
|
|
96
|
+
{/* insert option description */}
|
97
|
+
|
95
98
|
For projects that use constructs other than the global built-in `Promise` for asynchronous code.
|
96
99
|
This option allows specifying string names of classes or interfaces that cause a function to be checked as well.
|
97
100
|
|
@@ -120,23 +123,19 @@ const returnsBluebird = async () => new Bluebird(() => {});
|
|
120
123
|
|
121
124
|
### `checkArrowFunctions`
|
122
125
|
|
123
|
-
|
124
|
-
`true` by default, but can be set to `false` to ignore them.
|
126
|
+
{/* insert option description */}
|
125
127
|
|
126
128
|
### `checkFunctionDeclarations`
|
127
129
|
|
128
|
-
|
129
|
-
`true` by default, but can be set to `false` to ignore them.
|
130
|
+
{/* insert option description */}
|
130
131
|
|
131
132
|
### `checkFunctionExpressions`
|
132
133
|
|
133
|
-
|
134
|
-
`true` by default, but can be set to `false` to ignore them.
|
134
|
+
{/* insert option description */}
|
135
135
|
|
136
136
|
### `checkMethodDeclarations`
|
137
137
|
|
138
|
-
|
139
|
-
`true` by default, but can be set to `false` to ignore them.
|
138
|
+
{/* insert option description */}
|
140
139
|
|
141
140
|
## When Not To Use It
|
142
141
|
|
@@ -74,6 +74,8 @@ Safer alternatives to using the `allow*` options include:
|
|
74
74
|
|
75
75
|
### `allowAny`
|
76
76
|
|
77
|
+
{/* insert option description */}
|
78
|
+
|
77
79
|
Examples of code for this rule with `{ allowAny: true }`:
|
78
80
|
|
79
81
|
<Tabs>
|
@@ -97,6 +99,8 @@ let fn = (a: string, b: any) => a + b;
|
|
97
99
|
|
98
100
|
### `allowBoolean`
|
99
101
|
|
102
|
+
{/* insert option description */}
|
103
|
+
|
100
104
|
Examples of code for this rule with `{ allowBoolean: true }`:
|
101
105
|
|
102
106
|
<Tabs>
|
@@ -120,6 +124,8 @@ let fn = (a: string, b: boolean) => a + b;
|
|
120
124
|
|
121
125
|
### `allowNullish`
|
122
126
|
|
127
|
+
{/* insert option description */}
|
128
|
+
|
123
129
|
Examples of code for this rule with `{ allowNullish: true }`:
|
124
130
|
|
125
131
|
<Tabs>
|
@@ -147,6 +153,8 @@ let fn = (a: string, b: null) => a + b;
|
|
147
153
|
|
148
154
|
### `allowNumberAndString`
|
149
155
|
|
156
|
+
{/* insert option description */}
|
157
|
+
|
150
158
|
Examples of code for this rule with `{ allowNumberAndString: true }`:
|
151
159
|
|
152
160
|
<Tabs>
|
@@ -170,6 +178,8 @@ let fn = (a: number, b: number | string) => a + b;
|
|
170
178
|
|
171
179
|
### `allowRegExp`
|
172
180
|
|
181
|
+
{/* insert option description */}
|
182
|
+
|
173
183
|
Examples of code for this rule with `{ allowRegExp: true }`:
|
174
184
|
|
175
185
|
<Tabs>
|
@@ -191,6 +201,8 @@ let fn = (a: string, b: RegExp) => a + b;
|
|
191
201
|
|
192
202
|
### `skipCompoundAssignments`
|
193
203
|
|
204
|
+
{/* insert option description */}
|
205
|
+
|
194
206
|
Examples of code for this rule with `{ skipCompoundAssignments: false }`:
|
195
207
|
|
196
208
|
<Tabs>
|
@@ -55,7 +55,7 @@ const msg3 = `stringWithKindProp = ${stringWithKindProp}`;
|
|
55
55
|
|
56
56
|
### `allowNumber`
|
57
57
|
|
58
|
-
|
58
|
+
{/* insert option description */}
|
59
59
|
|
60
60
|
Examples of additional **correct** code for this rule with `{ allowNumber: true }`:
|
61
61
|
|
@@ -73,7 +73,7 @@ Consider using [`.toFixed()`](https://developer.mozilla.org/en-US/docs/Web/JavaS
|
|
73
73
|
|
74
74
|
### `allowBoolean`
|
75
75
|
|
76
|
-
|
76
|
+
{/* insert option description */}
|
77
77
|
|
78
78
|
Examples of additional **correct** code for this rule with `{ allowBoolean: true }`:
|
79
79
|
|
@@ -85,7 +85,7 @@ const msg2 = `arg = ${arg || 'not truthy'}`;
|
|
85
85
|
|
86
86
|
### `allowAny`
|
87
87
|
|
88
|
-
|
88
|
+
{/* insert option description */}
|
89
89
|
|
90
90
|
Examples of additional **correct** code for this rule with `{ allowAny: true }`:
|
91
91
|
|
@@ -97,7 +97,7 @@ const msg2 = `arg = ${user.name || 'the user with no name'}`;
|
|
97
97
|
|
98
98
|
### `allowNullish`
|
99
99
|
|
100
|
-
|
100
|
+
{/* insert option description */}
|
101
101
|
|
102
102
|
Examples of additional **correct** code for this rule with `{ allowNullish: true }`:
|
103
103
|
|
@@ -108,7 +108,7 @@ const msg1 = `arg = ${arg}`;
|
|
108
108
|
|
109
109
|
### `allowRegExp`
|
110
110
|
|
111
|
-
|
111
|
+
{/* insert option description */}
|
112
112
|
|
113
113
|
Examples of additional **correct** code for this rule with `{ allowRegExp: true }`:
|
114
114
|
|
@@ -124,7 +124,7 @@ const msg1 = `arg = ${arg}`;
|
|
124
124
|
|
125
125
|
### `allowNever`
|
126
126
|
|
127
|
-
|
127
|
+
{/* insert option description */}
|
128
128
|
|
129
129
|
Examples of additional **correct** code for this rule with `{ allowNever: true }`:
|
130
130
|
|
@@ -135,7 +135,7 @@ const msg1 = typeof arg === 'string' ? arg : `arg = ${arg}`;
|
|
135
135
|
|
136
136
|
### `allowArray`
|
137
137
|
|
138
|
-
|
138
|
+
{/* insert option description */}
|
139
139
|
|
140
140
|
Examples of additional **correct** code for this rule with `{ allowArray: true }`:
|
141
141
|
|
@@ -146,6 +146,8 @@ const msg1 = `arg = ${arg}`;
|
|
146
146
|
|
147
147
|
### `allow`
|
148
148
|
|
149
|
+
{/* insert option description */}
|
150
|
+
|
149
151
|
Whether to allow additional types in template expressions.
|
150
152
|
|
151
153
|
This option takes the shared [`TypeOrValueSpecifier` format](/packages/type-utils/type-or-value-specifier).
|
@@ -189,6 +189,8 @@ async function validInTryCatch7() {
|
|
189
189
|
|
190
190
|
### `always`
|
191
191
|
|
192
|
+
{/* insert option description */}
|
193
|
+
|
192
194
|
Requires that all returned promises be awaited.
|
193
195
|
|
194
196
|
This is a good option if you like the consistency of simply always awaiting promises, or prefer not having to consider the distinction between error-handling contexts and ordinary contexts.
|
@@ -268,6 +270,8 @@ async function asyncFunction(): Promise<void> {
|
|
268
270
|
|
269
271
|
### `never`
|
270
272
|
|
273
|
+
{/* insert option description */}
|
274
|
+
|
271
275
|
Disallows awaiting any returned promises.
|
272
276
|
|
273
277
|
:::warning
|
@@ -96,7 +96,7 @@ type T4 =
|
|
96
96
|
|
97
97
|
### `caseSensitive`
|
98
98
|
|
99
|
-
|
99
|
+
{/* insert option description */}
|
100
100
|
|
101
101
|
Examples of code with `{ "caseSensitive": true }`:
|
102
102
|
|
@@ -119,7 +119,7 @@ type T = 'DeleteForever' | 'DeletedAt';
|
|
119
119
|
|
120
120
|
### `checkIntersections`
|
121
121
|
|
122
|
-
|
122
|
+
{/* insert option description */}
|
123
123
|
|
124
124
|
Examples of code with `{ "checkIntersections": true }` (the default):
|
125
125
|
|
@@ -142,7 +142,7 @@ type ExampleIntersection = A & B;
|
|
142
142
|
|
143
143
|
### `checkUnions`
|
144
144
|
|
145
|
-
|
145
|
+
{/* insert option description */}
|
146
146
|
|
147
147
|
Examples of code with `{ "checkUnions": true }` (the default):
|
148
148
|
|
@@ -165,6 +165,8 @@ type ExampleUnion = A | B;
|
|
165
165
|
|
166
166
|
### `groupOrder`
|
167
167
|
|
168
|
+
{/* insert option description */}
|
169
|
+
|
168
170
|
Each constituent of the type is placed into a group, and then the rule sorts alphabetically within each group.
|
169
171
|
The ordering of groups is determined by this option.
|
170
172
|
|
@@ -95,55 +95,65 @@ const foo = (arg: any) => (Boolean(arg) ? 1 : 0);
|
|
95
95
|
|
96
96
|
### `allowString`
|
97
97
|
|
98
|
-
|
99
|
-
|
98
|
+
{/* insert option description */}
|
99
|
+
|
100
|
+
This can be safe because strings have only one falsy value (`""`).
|
100
101
|
Set this to `false` if you prefer the explicit `str != ""` or `str.length > 0` style.
|
101
102
|
|
102
103
|
### `allowNumber`
|
103
104
|
|
104
|
-
|
105
|
-
|
105
|
+
{/* insert option description */}
|
106
|
+
|
107
|
+
This can be safe because numbers have only two falsy values (`0` and `NaN`).
|
106
108
|
Set this to `false` if you prefer the explicit `num != 0` and `!Number.isNaN(num)` style.
|
107
109
|
|
108
110
|
### `allowNullableObject`
|
109
111
|
|
110
|
-
|
111
|
-
|
112
|
+
{/* insert option description */}
|
113
|
+
|
114
|
+
This can be safe because objects, functions, and symbols don't have falsy values.
|
112
115
|
Set this to `false` if you prefer the explicit `obj != null` style.
|
113
116
|
|
114
117
|
### `allowNullableBoolean`
|
115
118
|
|
116
|
-
|
119
|
+
{/* insert option description */}
|
120
|
+
|
117
121
|
This is unsafe because nullable booleans can be either `false` or nullish.
|
118
122
|
Set this to `false` if you want to enforce explicit `bool ?? false` or `bool ?? true` style.
|
119
123
|
Set this to `true` if you don't mind implicitly treating false the same as a nullish value.
|
120
124
|
|
121
125
|
### `allowNullableString`
|
122
126
|
|
123
|
-
|
127
|
+
{/* insert option description */}
|
128
|
+
|
124
129
|
This is unsafe because nullable strings can be either an empty string or nullish.
|
125
130
|
Set this to `true` if you don't mind implicitly treating an empty string the same as a nullish value.
|
126
131
|
|
127
132
|
### `allowNullableNumber`
|
128
133
|
|
129
|
-
|
134
|
+
{/* insert option description */}
|
135
|
+
|
130
136
|
This is unsafe because nullable numbers can be either a falsy number or nullish.
|
131
137
|
Set this to `true` if you don't mind implicitly treating zero or NaN the same as a nullish value.
|
132
138
|
|
133
139
|
### `allowNullableEnum`
|
134
140
|
|
135
|
-
|
141
|
+
{/* insert option description */}
|
142
|
+
|
136
143
|
This is unsafe because nullable enums can be either a falsy number or nullish.
|
137
144
|
Set this to `true` if you don't mind implicitly treating an enum whose value is zero the same as a nullish value.
|
138
145
|
|
139
146
|
### `allowAny`
|
140
147
|
|
141
|
-
|
142
|
-
|
148
|
+
{/* insert option description */}
|
149
|
+
|
150
|
+
This is unsafe for because `any` allows any values and disables many type checking checks.
|
143
151
|
Set this to `true` at your own risk.
|
144
152
|
|
145
153
|
### `allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing`
|
146
154
|
|
155
|
+
{/* insert option description */}
|
156
|
+
|
147
157
|
:::danger Deprecated
|
148
158
|
|
149
159
|
This option will be removed in the next major version of typescript-eslint.
|
@@ -18,7 +18,9 @@ This rule reports when a `switch` statement over a value typed as a union of lit
|
|
18
18
|
|
19
19
|
### `allowDefaultCaseForExhaustiveSwitch`
|
20
20
|
|
21
|
-
|
21
|
+
{/* insert option description */}
|
22
|
+
|
23
|
+
If set to false, this rule will also report when a `switch` statement has a case for everything in a union and _also_ contains a `default` case. Thus, by setting this option to false, the rule becomes stricter.
|
22
24
|
|
23
25
|
When a `switch` statement over a union type is exhaustive, a final `default` case would be a form of dead code.
|
24
26
|
Additionally, if a new value is added to the union type, a `default` would prevent the `switch-exhaustiveness-check` rule from reporting on the new case not being handled in the `switch` statement.
|
@@ -34,7 +36,9 @@ If your project has many intentionally redundant `default` cases, you may want t
|
|
34
36
|
|
35
37
|
### `requireDefaultForNonUnion`
|
36
38
|
|
37
|
-
|
39
|
+
{/* insert option description */}
|
40
|
+
|
41
|
+
If set to true, this rule will also report when a `switch` statement switches over a non-union type (like a `number` or `string`, for example) and that `switch` statement does not have a `default` case. Thus, by setting this option to true, the rule becomes stricter.
|
38
42
|
|
39
43
|
This is generally desirable so that `number` and `string` switches will be subject to the same exhaustive checks that your other switches are.
|
40
44
|
|
@@ -20,6 +20,8 @@ Specifying `'always'` disables this lint rule for that kind of reference.
|
|
20
20
|
|
21
21
|
### `lib`
|
22
22
|
|
23
|
+
{/* insert option description */}
|
24
|
+
|
23
25
|
When set to `'never'`, bans `/// <reference lib="..." />` and enforces using an `import` instead:
|
24
26
|
|
25
27
|
<Tabs>
|
@@ -43,6 +45,8 @@ import { value } from 'code';
|
|
43
45
|
|
44
46
|
### `path`
|
45
47
|
|
48
|
+
{/* insert option description */}
|
49
|
+
|
46
50
|
When set to `'never'`, bans `/// <reference path="..." />` and enforces using an `import` instead:
|
47
51
|
|
48
52
|
<Tabs>
|
@@ -66,6 +70,8 @@ import { value } from 'code';
|
|
66
70
|
|
67
71
|
### `types`
|
68
72
|
|
73
|
+
{/* insert option description */}
|
74
|
+
|
69
75
|
When set to `'never'`, bans `/// <reference types="..." />` and enforces using an `import` instead:
|
70
76
|
|
71
77
|
<Tabs>
|