@typescript-eslint/eslint-plugin 8.9.1-alpha.5 → 8.9.1-alpha.7
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/explicit-member-accessibility.js +5 -1
- package/dist/rules/explicit-member-accessibility.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-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
@@ -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>
|
package/docs/rules/typedef.mdx
CHANGED
@@ -62,7 +62,7 @@ For example, with the following configuration:
|
|
62
62
|
|
63
63
|
### `arrayDestructuring`
|
64
64
|
|
65
|
-
|
65
|
+
{/* insert option description */}
|
66
66
|
|
67
67
|
Examples of code with `{ "arrayDestructuring": true }`:
|
68
68
|
|
@@ -91,7 +91,7 @@ for (const [key, val] of new Map([['key', 1]])) {
|
|
91
91
|
|
92
92
|
### `arrowParameter`
|
93
93
|
|
94
|
-
|
94
|
+
{/* insert option description */}
|
95
95
|
|
96
96
|
Examples of code with `{ "arrowParameter": true }`:
|
97
97
|
|
@@ -126,7 +126,7 @@ const mapper = {
|
|
126
126
|
|
127
127
|
### `memberVariableDeclaration`
|
128
128
|
|
129
|
-
|
129
|
+
{/* insert option description */}
|
130
130
|
|
131
131
|
Examples of code with `{ "memberVariableDeclaration": true }`:
|
132
132
|
|
@@ -155,7 +155,7 @@ class ContainsText {
|
|
155
155
|
|
156
156
|
### `objectDestructuring`
|
157
157
|
|
158
|
-
|
158
|
+
{/* insert option description */}
|
159
159
|
|
160
160
|
Examples of code with `{ "objectDestructuring": true }`:
|
161
161
|
|
@@ -183,7 +183,7 @@ for (const { key, val } of [{ key: 'key', val: 1 }]) {
|
|
183
183
|
|
184
184
|
### `parameter`
|
185
185
|
|
186
|
-
|
186
|
+
{/* insert option description */}
|
187
187
|
|
188
188
|
Examples of code with `{ "parameter": true }`:
|
189
189
|
|
@@ -250,7 +250,7 @@ class Logger {
|
|
250
250
|
|
251
251
|
### `propertyDeclaration`
|
252
252
|
|
253
|
-
|
253
|
+
{/* insert option description */}
|
254
254
|
|
255
255
|
Examples of code with `{ "propertyDeclaration": true }`:
|
256
256
|
|
@@ -279,7 +279,7 @@ type Members = {
|
|
279
279
|
|
280
280
|
### `variableDeclaration`
|
281
281
|
|
282
|
-
|
282
|
+
{/* insert option description */}
|
283
283
|
|
284
284
|
Examples of code with `{ "variableDeclaration": true }`:
|
285
285
|
|
@@ -306,7 +306,7 @@ let delayedText: string;
|
|
306
306
|
|
307
307
|
### `variableDeclarationIgnoreFunction`
|
308
308
|
|
309
|
-
|
309
|
+
{/* insert option description */}
|
310
310
|
|
311
311
|
Examples of code with `{ "variableDeclaration": true, "variableDeclarationIgnoreFunction": true }`:
|
312
312
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
3
|
-
"version": "8.9.1-alpha.
|
3
|
+
"version": "8.9.1-alpha.7",
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
5
5
|
"files": [
|
6
6
|
"dist",
|
@@ -61,10 +61,10 @@
|
|
61
61
|
},
|
62
62
|
"dependencies": {
|
63
63
|
"@eslint-community/regexpp": "^4.10.0",
|
64
|
-
"@typescript-eslint/scope-manager": "8.9.1-alpha.
|
65
|
-
"@typescript-eslint/type-utils": "8.9.1-alpha.
|
66
|
-
"@typescript-eslint/utils": "8.9.1-alpha.
|
67
|
-
"@typescript-eslint/visitor-keys": "8.9.1-alpha.
|
64
|
+
"@typescript-eslint/scope-manager": "8.9.1-alpha.7",
|
65
|
+
"@typescript-eslint/type-utils": "8.9.1-alpha.7",
|
66
|
+
"@typescript-eslint/utils": "8.9.1-alpha.7",
|
67
|
+
"@typescript-eslint/visitor-keys": "8.9.1-alpha.7",
|
68
68
|
"graphemer": "^1.4.0",
|
69
69
|
"ignore": "^5.3.1",
|
70
70
|
"natural-compare": "^1.4.0",
|
@@ -75,8 +75,8 @@
|
|
75
75
|
"@types/marked": "^5.0.2",
|
76
76
|
"@types/mdast": "^4.0.3",
|
77
77
|
"@types/natural-compare": "*",
|
78
|
-
"@typescript-eslint/rule-schema-to-typescript-types": "8.9.1-alpha.
|
79
|
-
"@typescript-eslint/rule-tester": "8.9.1-alpha.
|
78
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.9.1-alpha.7",
|
79
|
+
"@typescript-eslint/rule-tester": "8.9.1-alpha.7",
|
80
80
|
"ajv": "^6.12.6",
|
81
81
|
"cross-env": "^7.0.3",
|
82
82
|
"cross-fetch": "*",
|