@typescript-eslint/eslint-plugin 8.9.1-alpha.6 → 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.
Files changed (91) hide show
  1. package/dist/rules/class-literal-property-style.js +1 -0
  2. package/dist/rules/class-literal-property-style.js.map +1 -1
  3. package/dist/rules/class-methods-use-this.js +3 -3
  4. package/dist/rules/class-methods-use-this.js.map +1 -1
  5. package/dist/rules/consistent-generic-constructors.js +1 -0
  6. package/dist/rules/consistent-generic-constructors.js.map +1 -1
  7. package/dist/rules/consistent-indexed-object-style.js +1 -0
  8. package/dist/rules/consistent-indexed-object-style.js.map +1 -1
  9. package/dist/rules/consistent-type-definitions.js +1 -0
  10. package/dist/rules/consistent-type-definitions.js.map +1 -1
  11. package/dist/rules/explicit-member-accessibility.js +5 -1
  12. package/dist/rules/explicit-member-accessibility.js.map +1 -1
  13. package/dist/rules/no-invalid-void-type.js +7 -3
  14. package/dist/rules/no-invalid-void-type.js.map +1 -1
  15. package/dist/rules/no-misused-promises.js +7 -1
  16. package/dist/rules/no-misused-promises.js.map +1 -1
  17. package/dist/rules/no-restricted-imports.js +1 -1
  18. package/dist/rules/no-restricted-imports.js.map +1 -1
  19. package/dist/rules/no-restricted-types.js +5 -4
  20. package/dist/rules/no-restricted-types.js.map +1 -1
  21. package/dist/rules/no-use-before-define.js +4 -1
  22. package/dist/rules/no-use-before-define.js.map +1 -1
  23. package/dist/rules/prefer-destructuring.js +2 -0
  24. package/dist/rules/prefer-destructuring.js.map +1 -1
  25. package/dist/rules/prefer-nullish-coalescing.js +18 -4
  26. package/dist/rules/prefer-nullish-coalescing.js.map +1 -1
  27. package/dist/rules/sort-type-constituents.js +3 -3
  28. package/dist/rules/sort-type-constituents.js.map +1 -1
  29. package/dist/rules/strict-boolean-expressions.js +5 -4
  30. package/dist/rules/strict-boolean-expressions.js.map +1 -1
  31. package/docs/rules/ban-ts-comment.mdx +4 -0
  32. package/docs/rules/class-methods-use-this.mdx +4 -1
  33. package/docs/rules/consistent-generic-constructors.mdx +6 -4
  34. package/docs/rules/consistent-indexed-object-style.mdx +6 -4
  35. package/docs/rules/consistent-type-assertions.mdx +4 -2
  36. package/docs/rules/consistent-type-definitions.mdx +8 -4
  37. package/docs/rules/consistent-type-exports.mdx +2 -1
  38. package/docs/rules/consistent-type-imports.mdx +7 -4
  39. package/docs/rules/dot-notation.mdx +5 -3
  40. package/docs/rules/explicit-function-return-type.mdx +16 -0
  41. package/docs/rules/explicit-member-accessibility.mdx +7 -2
  42. package/docs/rules/explicit-module-boundary-types.mdx +22 -12
  43. package/docs/rules/max-params.mdx +1 -1
  44. package/docs/rules/method-signature-style.mdx +4 -2
  45. package/docs/rules/no-base-to-string.mdx +5 -3
  46. package/docs/rules/no-confusing-void-expression.mdx +4 -0
  47. package/docs/rules/no-duplicate-type-constituents.mdx +4 -0
  48. package/docs/rules/no-empty-interface.mdx +3 -1
  49. package/docs/rules/no-empty-object-type.mdx +8 -3
  50. package/docs/rules/no-explicit-any.mdx +3 -1
  51. package/docs/rules/no-extraneous-class.mdx +4 -4
  52. package/docs/rules/no-floating-promises.mdx +12 -6
  53. package/docs/rules/no-inferrable-types.mdx +2 -2
  54. package/docs/rules/no-invalid-void-type.mdx +4 -3
  55. package/docs/rules/no-magic-numbers.mdx +8 -0
  56. package/docs/rules/no-meaningless-void-operator.mdx +1 -1
  57. package/docs/rules/no-misused-promises.mdx +11 -1
  58. package/docs/rules/no-namespace.mdx +4 -0
  59. package/docs/rules/no-redeclare.mdx +3 -1
  60. package/docs/rules/no-require-imports.mdx +6 -2
  61. package/docs/rules/no-restricted-imports.mdx +4 -1
  62. package/docs/rules/no-restricted-types.mdx +1 -1
  63. package/docs/rules/no-shadow.mdx +4 -2
  64. package/docs/rules/no-this-alias.mdx +4 -0
  65. package/docs/rules/no-type-alias.mdx +8 -8
  66. package/docs/rules/no-unnecessary-boolean-literal-compare.mdx +4 -0
  67. package/docs/rules/no-unnecessary-condition.mdx +6 -0
  68. package/docs/rules/no-unnecessary-type-assertion.mdx +2 -0
  69. package/docs/rules/no-use-before-define.mdx +3 -3
  70. package/docs/rules/no-var-requires.mdx +2 -0
  71. package/docs/rules/parameter-properties.mdx +6 -2
  72. package/docs/rules/prefer-destructuring.mdx +1 -1
  73. package/docs/rules/prefer-literal-enum-member.mdx +1 -1
  74. package/docs/rules/prefer-nullish-coalescing.mdx +6 -4
  75. package/docs/rules/prefer-optional-chain.mdx +37 -28
  76. package/docs/rules/prefer-readonly-parameter-types.mdx +8 -4
  77. package/docs/rules/prefer-readonly.mdx +1 -1
  78. package/docs/rules/prefer-string-starts-ends-with.mdx +2 -0
  79. package/docs/rules/promise-function-async.mdx +8 -9
  80. package/docs/rules/require-array-sort-compare.mdx +2 -0
  81. package/docs/rules/restrict-plus-operands.mdx +12 -0
  82. package/docs/rules/restrict-template-expressions.mdx +9 -7
  83. package/docs/rules/return-await.mdx +4 -0
  84. package/docs/rules/sort-type-constituents.mdx +5 -3
  85. package/docs/rules/strict-boolean-expressions.mdx +22 -12
  86. package/docs/rules/switch-exhaustiveness-check.mdx +6 -2
  87. package/docs/rules/triple-slash-reference.mdx +6 -0
  88. package/docs/rules/typedef.mdx +8 -8
  89. package/docs/rules/unbound-method.mdx +2 -0
  90. package/docs/rules/unified-signatures.mdx +2 -0
  91. package/package.json +7 -7
@@ -55,7 +55,7 @@ const msg3 = `stringWithKindProp = ${stringWithKindProp}`;
55
55
 
56
56
  ### `allowNumber`
57
57
 
58
- Whether to allow `number` typed values in template expressions.
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
- Whether to allow Boolean typed values in template expressions.
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
- Whether to allow `any` typed values in template expressions.
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
- Whether to allow `null` or `undefined` typed values in template expressions.
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
- Whether to allow `RegExp` typed values in template expressions.
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
- Whether to allow `never` typed values in template expressions.
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
- Whether to allow `Array` typed values in template expressions.
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
- Whether to sort using case sensitive string comparisons.
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
- Whether to check intersection types (`&`).
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
- Whether to check union types (`|`).
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
- Allows `string` in a boolean context.
99
- This is safe because strings have only one falsy value (`""`).
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
- Allows `number` in a boolean context.
105
- This is safe because numbers have only two falsy values (`0` and `NaN`).
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
- Allows `object | function | symbol | null | undefined` in a boolean context.
111
- This is safe because objects, functions and symbols don't have falsy values.
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
- Allows `boolean | null | undefined` in a boolean context.
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
- Allows `string | null | undefined` in a boolean context.
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
- Allows `number | null | undefined` in a boolean context.
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
- Allows `enum | null | undefined` in a boolean context.
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
- Allows `any` in a boolean context.
142
- This is unsafe for obvious reasons.
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
- Defaults to true. 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.
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
- Defaults to false. 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.
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>
@@ -62,7 +62,7 @@ For example, with the following configuration:
62
62
 
63
63
  ### `arrayDestructuring`
64
64
 
65
- Whether to enforce type annotations on variables declared using array destructuring.
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
- Whether to enforce type annotations for parameters of arrow functions.
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
- Whether to enforce type annotations on member variables of classes.
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
- Whether to enforce type annotations on variables declared using object destructuring.
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
- Whether to enforce type annotations for parameters of functions and methods.
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
- Whether to enforce type annotations for properties of interfaces and types.
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
- Whether to enforce type annotations for variable declarations, excluding array and object destructuring.
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
- Whether to ignore variable declarations for non-arrow and arrow functions.
309
+ {/* insert option description */}
310
310
 
311
311
  Examples of code with `{ "variableDeclaration": true, "variableDeclarationIgnoreFunction": true }`:
312
312
 
@@ -87,6 +87,8 @@ const { double } = arith;
87
87
 
88
88
  ### `ignoreStatic`
89
89
 
90
+ {/* insert option description */}
91
+
90
92
  Examples of **correct** code for this rule with `{ ignoreStatic: true }`:
91
93
 
92
94
  ```ts option='{ "ignoreStatic": true }' showPlaygroundButton
@@ -55,6 +55,8 @@ function f(...a: string[]): void;
55
55
 
56
56
  ### `ignoreDifferentlyNamedParameters`
57
57
 
58
+ {/* insert option description */}
59
+
58
60
  Examples of code for this rule with `ignoreDifferentlyNamedParameters`:
59
61
 
60
62
  <Tabs>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/eslint-plugin",
3
- "version": "8.9.1-alpha.6",
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.6",
65
- "@typescript-eslint/type-utils": "8.9.1-alpha.6",
66
- "@typescript-eslint/utils": "8.9.1-alpha.6",
67
- "@typescript-eslint/visitor-keys": "8.9.1-alpha.6",
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.6",
79
- "@typescript-eslint/rule-tester": "8.9.1-alpha.6",
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": "*",