@typescript-eslint/eslint-plugin 8.9.1-alpha.1 → 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.
Files changed (100) 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/consistent-type-exports.js +10 -4
  12. package/dist/rules/consistent-type-exports.js.map +1 -1
  13. package/dist/rules/explicit-member-accessibility.js +5 -1
  14. package/dist/rules/explicit-member-accessibility.js.map +1 -1
  15. package/dist/rules/explicit-module-boundary-types.js.map +1 -1
  16. package/dist/rules/naming-convention.js +2 -1
  17. package/dist/rules/naming-convention.js.map +1 -1
  18. package/dist/rules/no-invalid-void-type.js +7 -3
  19. package/dist/rules/no-invalid-void-type.js.map +1 -1
  20. package/dist/rules/no-misused-promises.js +7 -1
  21. package/dist/rules/no-misused-promises.js.map +1 -1
  22. package/dist/rules/no-restricted-imports.js +1 -1
  23. package/dist/rules/no-restricted-imports.js.map +1 -1
  24. package/dist/rules/no-restricted-types.js +5 -4
  25. package/dist/rules/no-restricted-types.js.map +1 -1
  26. package/dist/rules/no-unnecessary-condition.js +0 -1
  27. package/dist/rules/no-unnecessary-condition.js.map +1 -1
  28. package/dist/rules/no-unsafe-argument.js +2 -1
  29. package/dist/rules/no-unsafe-argument.js.map +1 -1
  30. package/dist/rules/no-use-before-define.js +4 -1
  31. package/dist/rules/no-use-before-define.js.map +1 -1
  32. package/dist/rules/prefer-destructuring.js +2 -0
  33. package/dist/rules/prefer-destructuring.js.map +1 -1
  34. package/dist/rules/prefer-nullish-coalescing.js +18 -4
  35. package/dist/rules/prefer-nullish-coalescing.js.map +1 -1
  36. package/dist/rules/sort-type-constituents.js +3 -3
  37. package/dist/rules/sort-type-constituents.js.map +1 -1
  38. package/dist/rules/strict-boolean-expressions.js +5 -4
  39. package/dist/rules/strict-boolean-expressions.js.map +1 -1
  40. package/docs/rules/ban-ts-comment.mdx +4 -0
  41. package/docs/rules/class-methods-use-this.mdx +4 -1
  42. package/docs/rules/consistent-generic-constructors.mdx +6 -4
  43. package/docs/rules/consistent-indexed-object-style.mdx +6 -4
  44. package/docs/rules/consistent-type-assertions.mdx +4 -2
  45. package/docs/rules/consistent-type-definitions.mdx +8 -4
  46. package/docs/rules/consistent-type-exports.mdx +2 -1
  47. package/docs/rules/consistent-type-imports.mdx +7 -4
  48. package/docs/rules/dot-notation.mdx +5 -3
  49. package/docs/rules/explicit-function-return-type.mdx +16 -0
  50. package/docs/rules/explicit-member-accessibility.mdx +7 -2
  51. package/docs/rules/explicit-module-boundary-types.mdx +22 -12
  52. package/docs/rules/max-params.mdx +1 -1
  53. package/docs/rules/method-signature-style.mdx +4 -2
  54. package/docs/rules/no-base-to-string.mdx +5 -3
  55. package/docs/rules/no-confusing-void-expression.mdx +4 -0
  56. package/docs/rules/no-duplicate-type-constituents.mdx +4 -0
  57. package/docs/rules/no-empty-interface.mdx +3 -1
  58. package/docs/rules/no-empty-object-type.mdx +8 -3
  59. package/docs/rules/no-explicit-any.mdx +3 -1
  60. package/docs/rules/no-extraneous-class.mdx +4 -4
  61. package/docs/rules/no-floating-promises.mdx +12 -6
  62. package/docs/rules/no-inferrable-types.mdx +2 -2
  63. package/docs/rules/no-invalid-void-type.mdx +4 -3
  64. package/docs/rules/no-magic-numbers.mdx +8 -0
  65. package/docs/rules/no-meaningless-void-operator.mdx +1 -1
  66. package/docs/rules/no-misused-promises.mdx +11 -1
  67. package/docs/rules/no-namespace.mdx +4 -0
  68. package/docs/rules/no-redeclare.mdx +3 -1
  69. package/docs/rules/no-require-imports.mdx +6 -2
  70. package/docs/rules/no-restricted-imports.mdx +4 -1
  71. package/docs/rules/no-restricted-types.mdx +1 -1
  72. package/docs/rules/no-shadow.mdx +4 -2
  73. package/docs/rules/no-this-alias.mdx +4 -0
  74. package/docs/rules/no-type-alias.mdx +8 -8
  75. package/docs/rules/no-unnecessary-boolean-literal-compare.mdx +4 -0
  76. package/docs/rules/no-unnecessary-condition.mdx +6 -0
  77. package/docs/rules/no-unnecessary-type-assertion.mdx +2 -0
  78. package/docs/rules/no-use-before-define.mdx +3 -3
  79. package/docs/rules/no-var-requires.mdx +2 -0
  80. package/docs/rules/parameter-properties.mdx +6 -2
  81. package/docs/rules/prefer-destructuring.mdx +1 -1
  82. package/docs/rules/prefer-literal-enum-member.mdx +1 -1
  83. package/docs/rules/prefer-nullish-coalescing.mdx +6 -4
  84. package/docs/rules/prefer-optional-chain.mdx +37 -28
  85. package/docs/rules/prefer-readonly-parameter-types.mdx +8 -4
  86. package/docs/rules/prefer-readonly.mdx +1 -1
  87. package/docs/rules/prefer-string-starts-ends-with.mdx +2 -0
  88. package/docs/rules/promise-function-async.mdx +8 -9
  89. package/docs/rules/require-array-sort-compare.mdx +2 -0
  90. package/docs/rules/restrict-plus-operands.mdx +12 -0
  91. package/docs/rules/restrict-template-expressions.mdx +9 -7
  92. package/docs/rules/return-await.mdx +4 -0
  93. package/docs/rules/sort-type-constituents.mdx +5 -3
  94. package/docs/rules/strict-boolean-expressions.mdx +22 -12
  95. package/docs/rules/switch-exhaustiveness-check.mdx +6 -2
  96. package/docs/rules/triple-slash-reference.mdx +6 -0
  97. package/docs/rules/typedef.mdx +8 -8
  98. package/docs/rules/unbound-method.mdx +2 -0
  99. package/docs/rules/unified-signatures.mdx +2 -0
  100. package/package.json +7 -7
@@ -83,7 +83,9 @@ By default, this rule flags both interfaces and object types.
83
83
 
84
84
  ### `allowInterfaces`
85
85
 
86
- Whether to allow empty interfaces, as one of:
86
+ {/* insert option description */}
87
+
88
+ Allowed values are:
87
89
 
88
90
  - `'always'`: to always allow interfaces with no fields
89
91
  - `'never'` _(default)_: to never allow interfaces with no fields
@@ -101,14 +103,17 @@ interface Derived extends Base {}
101
103
 
102
104
  ### `allowObjectTypes`
103
105
 
104
- Whether to allow empty object type literals, as one of:
106
+ {/* insert option description */}
107
+
108
+ Allowed values are:
105
109
 
106
110
  - `'always'`: to always allow object type literals with no fields
107
111
  - `'never'` _(default)_: to never allow object type literals with no fields
108
112
 
109
113
  ### `allowWithName`
110
114
 
111
- A stringified regular expression to allow interfaces and object type aliases with the configured name.
115
+ {/* insert option description */}
116
+
112
117
  This can be useful if your existing code style includes a pattern of declaring empty types with `{}` instead of `object`.
113
118
 
114
119
  Examples of code for this rule with `{ allowWithName: 'Props$' }`:
@@ -107,6 +107,8 @@ function greet(param: Array<string>): Array<string> {}
107
107
 
108
108
  ### `fixToUnknown`
109
109
 
110
+ {/* insert option description */}
111
+
110
112
  By default, this rule will not provide automatic ESLint _fixes_: only opt-in _suggestions_.
111
113
  Switching types to `unknown` is safer but is likely to cause additional type errors.
112
114
 
@@ -114,7 +116,7 @@ Enabling `{ "fixToUnknown": true }` gives the rule an auto-fixer to replace `: a
114
116
 
115
117
  ### `ignoreRestArgs`
116
118
 
117
- A boolean to specify if arrays from the rest operator are considered okay. `false` by default.
119
+ {/* insert option description */}
118
120
 
119
121
  The examples below are **incorrect** when `{ignoreRestArgs: false}`, but **correct** when `{ignoreRestArgs: true}`.
120
122
 
@@ -221,7 +221,7 @@ The rule's options each add an exemption for a specific type of class.
221
221
 
222
222
  ### `allowConstructorOnly`
223
223
 
224
- `allowConstructorOnly` adds an exemption for classes that have only a constructor and no fields.
224
+ {/* insert option description */}
225
225
 
226
226
  <Tabs>
227
227
  <TabItem value="❌ Incorrect">
@@ -246,7 +246,7 @@ class NoFields {
246
246
 
247
247
  ### `allowEmpty`
248
248
 
249
- The `allowEmpty` option adds an exemption for classes that are entirely empty.
249
+ {/* insert option description */}
250
250
 
251
251
  <Tabs>
252
252
  <TabItem value="❌ Incorrect">
@@ -271,7 +271,7 @@ class NoFields {}
271
271
 
272
272
  ### `allowStaticOnly`
273
273
 
274
- The `allowStaticOnly` option adds an exemption for classes that only contain static members.
274
+ {/* insert option description */}
275
275
 
276
276
  :::caution
277
277
  We strongly recommend against the `allowStaticOnly` exemption.
@@ -299,7 +299,7 @@ class NotEmptyClass {
299
299
 
300
300
  ### `allowWithDecorator`
301
301
 
302
- The `allowWithDecorator` option adds an exemption for classes decorated with a `@` decorator.
302
+ {/* insert option description */}
303
303
 
304
304
  <Tabs>
305
305
  <TabItem value="❌ Incorrect">
@@ -87,6 +87,8 @@ await Promise.all([1, 2, 3].map(async x => x + 1));
87
87
 
88
88
  ### `checkThenables`
89
89
 
90
+ {/* insert option description */}
91
+
90
92
  A ["Thenable"](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#thenables) value is an object which has a `then` method, such as a `Promise`.
91
93
  Other Thenables include TypeScript's built-in `PromiseLike` interface and any custom object that happens to have a `.then()`.
92
94
 
@@ -132,8 +134,9 @@ await createMyThenable();
132
134
 
133
135
  ### `ignoreVoid`
134
136
 
135
- This option, which is `true` by default, allows you to stop the rule reporting promises consumed with the [`void` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void).
136
- This can be a good way to explicitly mark a promise as intentionally not awaited.
137
+ {/* insert option description */}
138
+
139
+ Placing the [`void` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void) in front of a Promise can be a convenient way to explicitly mark that Promise as intentionally not awaited.
137
140
 
138
141
  :::warning
139
142
  Voiding a Promise doesn't handle it or change the runtime behavior.
@@ -152,11 +155,11 @@ void returnsPromise();
152
155
  void Promise.reject('value');
153
156
  ```
154
157
 
155
- With this option set to `true`, and if you are using `no-void`, you should turn on the [`allowAsStatement`](https://eslint.org/docs/rules/no-void#allowasstatement) option.
158
+ When this option is set to `true`, if you are using `no-void`, you should turn on the [`allowAsStatement`](https://eslint.org/docs/rules/no-void#allowasstatement) option.
156
159
 
157
160
  ### `ignoreIIFE`
158
161
 
159
- This allows you to skip checking of async IIFEs (Immediately Invoked Function Expressions).
162
+ {/* insert option description */}
160
163
 
161
164
  Examples of **correct** code for this rule with `{ ignoreIIFE: true }`:
162
165
 
@@ -173,7 +176,9 @@ await (async function () {
173
176
 
174
177
  ### `allowForKnownSafePromises`
175
178
 
176
- Specific types to be marked as "safe" to be floating. For example, you may need to do this in the case of libraries whose APIs return Promises whose rejections are safely handled by the library.
179
+ {/* insert option description */}
180
+
181
+ For example, you may need to do this in the case of libraries whose APIs return Promises whose rejections are safely handled by the library.
177
182
 
178
183
  This option takes the shared [`TypeOrValueSpecifier` format](/packages/type-utils/type-or-value-specifier).
179
184
 
@@ -225,7 +230,8 @@ returnsSafePromise();
225
230
 
226
231
  ### `allowForKnownSafeCalls`
227
232
 
228
- Specific functions to be marked as "safe" to be called to create floating Promises.
233
+ {/* insert option description */}
234
+
229
235
  For example, you may need to do this in the case of libraries whose APIs may be called without handling the resultant Promises.
230
236
 
231
237
  This option takes the shared [`TypeOrValueSpecifier` format](/packages/type-utils/type-or-value-specifier).
@@ -80,7 +80,7 @@ function fn(a = 5, b = true) {}
80
80
 
81
81
  ### `ignoreParameters`
82
82
 
83
- Whether to ignore function parameters.
83
+ {/* insert option description */}
84
84
 
85
85
  When set to true, the following pattern is considered valid:
86
86
 
@@ -92,7 +92,7 @@ function foo(a: number = 5, b: boolean = true) {
92
92
 
93
93
  ### `ignoreProperties`
94
94
 
95
- Whether to ignore class properties.
95
+ {/* insert option description */}
96
96
 
97
97
  When set to true, the following pattern is considered valid:
98
98
 
@@ -62,9 +62,9 @@ type stillVoid = void | never;
62
62
 
63
63
  ### `allowInGenericTypeArguments`
64
64
 
65
- Whether `void` can be used as a valid value for generic type parameters.
65
+ {/* insert option description */}
66
66
 
67
- Alternatively, you can provide an array of strings which whitelist which types may accept `void` as a generic type parameter.
67
+ Alternatively, you can provide an array of strings which allowlist which types may accept `void` as a generic type parameter.
68
68
 
69
69
  Any types considered valid by this option will be considered valid as part of a union type with `void`.
70
70
 
@@ -98,7 +98,8 @@ type AllowedVoidUnion = void | Ex.Mx.Tx<void>;
98
98
 
99
99
  ### `allowAsThisParameter`
100
100
 
101
- Whether a `this` parameter of a function may be `void`.
101
+ {/* insert option description */}
102
+
102
103
  This pattern can be useful to explicitly label function types that do not use a `this` argument. [See the TypeScript docs for more information](https://www.typescriptlang.org/docs/handbook/functions.html#this-parameters-in-callbacks).
103
104
 
104
105
  This option is `false` by default.
@@ -39,6 +39,8 @@ const defaultOptions: Options = {
39
39
 
40
40
  ### `ignoreEnums`
41
41
 
42
+ {/* insert option description */}
43
+
42
44
  Whether enums used in TypeScript are considered okay. `false` by default.
43
45
 
44
46
  Examples of **incorrect** code for the `{ "ignoreEnums": false }` option:
@@ -59,6 +61,8 @@ enum foo {
59
61
 
60
62
  ### `ignoreNumericLiteralTypes`
61
63
 
64
+ {/* insert option description */}
65
+
62
66
  Whether numbers used in TypeScript numeric literal types are considered okay. `false` by default.
63
67
 
64
68
  Examples of **incorrect** code for the `{ "ignoreNumericLiteralTypes": false }` option:
@@ -75,6 +79,8 @@ type SmallPrimes = 2 | 3 | 5 | 7 | 11;
75
79
 
76
80
  ### `ignoreReadonlyClassProperties`
77
81
 
82
+ {/* insert option description */}
83
+
78
84
  Whether `readonly` class properties are considered okay.
79
85
 
80
86
  Examples of **incorrect** code for the `{ "ignoreReadonlyClassProperties": false }` option:
@@ -101,6 +107,8 @@ class Foo {
101
107
 
102
108
  ### `ignoreTypeIndexes`
103
109
 
110
+ {/* insert option description */}
111
+
104
112
  Whether numbers used to index types are okay. `false` by default.
105
113
 
106
114
  Examples of **incorrect** code for the `{ "ignoreTypeIndexes": false }` option:
@@ -54,7 +54,7 @@ void bar(1); // discarding a number
54
54
 
55
55
  ### `checkNever`
56
56
 
57
- Whether to suggest removing `void` when the argument has type `never`.
57
+ {/* insert option description */}
58
58
 
59
59
  ## When Not To Use It
60
60
 
@@ -22,6 +22,8 @@ See [`no-floating-promises`](./no-floating-promises.mdx) for detecting unhandled
22
22
 
23
23
  ### `checksConditionals`
24
24
 
25
+ {/* insert option description */}
26
+
25
27
  If you don't want to check conditionals, you can configure the rule with `"checksConditionals": false`:
26
28
 
27
29
  ```json
@@ -39,6 +41,8 @@ Doing so prevents the rule from looking at code like `if (somePromise)`.
39
41
 
40
42
  ### `checksVoidReturn`
41
43
 
44
+ {/* insert option description */}
45
+
42
46
  Likewise, if you don't want to check functions that return promises where a void return is
43
47
  expected, your configuration will look like this:
44
48
 
@@ -101,7 +105,7 @@ Disables checking an asynchronous function used as a variable whose return type
101
105
 
102
106
  ### `checksSpreads`
103
107
 
104
- Whether to warn when `...` spreading a `Promise`.
108
+ {/* insert option description */}
105
109
 
106
110
  If you don't want to check object spreads, you can add this configuration:
107
111
 
@@ -120,6 +124,8 @@ If you don't want to check object spreads, you can add this configuration:
120
124
 
121
125
  ### `checksConditionals`
122
126
 
127
+ {/* insert option description */}
128
+
123
129
  Examples of code for this rule with `checksConditionals: true`:
124
130
 
125
131
  <Tabs>
@@ -167,6 +173,8 @@ while (await promise) {
167
173
 
168
174
  ### `checksVoidReturn`
169
175
 
176
+ {/* insert option description */}
177
+
170
178
  Examples of code for this rule with `checksVoidReturn: true`:
171
179
 
172
180
  <Tabs>
@@ -254,6 +262,8 @@ class MyClass implements MyAsyncInterface {
254
262
 
255
263
  ### `checksSpreads`
256
264
 
265
+ {/* insert option description */}
266
+
257
267
  Examples of code for this rule with `checksSpreads: true`:
258
268
 
259
269
  <Tabs>
@@ -46,6 +46,8 @@ declare module 'foo' {}
46
46
 
47
47
  ### `allowDeclarations`
48
48
 
49
+ {/* insert option description */}
50
+
49
51
  Examples of code with the `{ "allowDeclarations": true }` option:
50
52
 
51
53
  <Tabs>
@@ -100,6 +102,8 @@ declare module 'foo' {}
100
102
 
101
103
  ### `allowDefinitionFiles`
102
104
 
105
+ {/* insert option description */}
106
+
103
107
  Examples of code for the `{ "allowDefinitionFiles": true }` option:
104
108
 
105
109
  <Tabs>
@@ -33,7 +33,9 @@ const defaultOptions: Options = {
33
33
 
34
34
  ### `ignoreDeclarationMerge`
35
35
 
36
- Whether to ignore declaration merges between the following sets:
36
+ {/* insert option description */}
37
+
38
+ The following sets will be ignored when this option is enabled:
37
39
 
38
40
  - interface + interface
39
41
  - namespace + namespace
@@ -38,7 +38,9 @@ import * as lib3 from 'lib3';
38
38
 
39
39
  ### `allow`
40
40
 
41
- An array of strings. These strings will be compiled into regular expressions with the `u` flag and be used to test against the imported path. A common use case is to allow importing `package.json`. This is because `package.json` commonly lives outside of the TS root directory, so statically importing it would lead to root directory conflicts, especially with `resolveJsonModule` enabled. You can also use it to allow importing any JSON if your environment doesn't support JSON modules, or use it for other cases where `import` statements cannot work.
41
+ {/* insert option description */}
42
+
43
+ These strings will be compiled into regular expressions with the `u` flag and be used to test against the imported path. A common use case is to allow importing `package.json`. This is because `package.json` commonly lives outside of the TS root directory, so statically importing it would lead to root directory conflicts, especially with `resolveJsonModule` enabled. You can also use it to allow importing any JSON if your environment doesn't support JSON modules, or use it for other cases where `import` statements cannot work.
42
44
 
43
45
  With `{allow: ['/package\\.json$']}`:
44
46
 
@@ -61,7 +63,9 @@ console.log(require('../package.json').version);
61
63
 
62
64
  ### `allowAsImport`
63
65
 
64
- When set to `true`, the `import x = require(...)` declaration won't be reported.
66
+ {/* insert option description */}
67
+
68
+ When set to `true`, `import ... = require(...)` declarations won't be reported.
65
69
  This is useful if you use certain module options that require strict CommonJS interop semantics.
66
70
 
67
71
  With `{allowAsImport: true}`:
@@ -17,7 +17,10 @@ This rule adds the following options:
17
17
 
18
18
  ### `allowTypeImports`
19
19
 
20
- (default: `false`)
20
+ {/* insert option description */}
21
+
22
+ Whether to allow type-only imports for a path.
23
+ Default: `false`.
21
24
 
22
25
  You can specify this option for a specific path or pattern as follows:
23
26
 
@@ -19,7 +19,7 @@ Note that it does not ban the corresponding runtime objects from being used.
19
19
 
20
20
  ### `types`
21
21
 
22
- An object whose keys are the types you want to ban, and the values are error messages.
22
+ {/* insert option description */}
23
23
 
24
24
  The type can either be a type name literal (`OldType`) or a a type name with generic parameter instantiation(s) (`OldType<MyArgument>`).
25
25
 
@@ -31,7 +31,9 @@ const defaultOptions: Options = {
31
31
 
32
32
  ### `ignoreTypeValueShadow`
33
33
 
34
- Whether to ignore types named the same as a variable. This is generally safe because you cannot use variables in type locations without a `typeof` operator, so there's little risk of confusion.
34
+ {/* insert option description */}
35
+
36
+ This is generally safe because you cannot use variables in type locations without a `typeof` operator, so there's little risk of confusion.
35
37
 
36
38
  Examples of **correct** code with `{ ignoreTypeValueShadow: true }`:
37
39
 
@@ -55,7 +57,7 @@ _Shadowing_ specifically refers to two identical identifiers that are in differe
55
57
 
56
58
  ### `ignoreFunctionTypeParameterNameValueShadow`
57
59
 
58
- Whether to ignore function parameters named the same as a variable.
60
+ {/* insert option description */}
59
61
 
60
62
  Each of a function type's arguments creates a value variable within the scope of the function type. This is done so that you can reference the type later using the `typeof` operator:
61
63
 
@@ -41,6 +41,8 @@ setTimeout(() => {
41
41
 
42
42
  ### `allowDestructuring`
43
43
 
44
+ {/* insert option description */}
45
+
44
46
  It can sometimes be useful to destructure properties from a class instance, such as retrieving multiple properties from the instance in one of its methods.
45
47
  `allowDestructuring` allows those destructures and is `true` by default.
46
48
  You can explicitly disallow them by setting `allowDestructuring` to `false`.
@@ -84,6 +86,8 @@ class ComponentLike {
84
86
 
85
87
  ### `allowedNames`
86
88
 
89
+ {/* insert option description */}
90
+
87
91
  `no-this-alias` can alternately be used to allow only a specific list of names as `this` aliases.
88
92
  We recommend against this except as a transitory step towards fixing all rule violations.
89
93
 
@@ -114,7 +114,7 @@ and simplified types (primitives, tuples, unions, intersections, etc).
114
114
 
115
115
  ### `allowAliases`
116
116
 
117
- This applies to primitive types and reference types.
117
+ {/* insert option description */}
118
118
 
119
119
  The setting accepts the following values:
120
120
 
@@ -268,7 +268,7 @@ type Foo = Bar & Baz;
268
268
 
269
269
  ### `allowCallbacks`
270
270
 
271
- This applies to function types.
271
+ {/* insert option description */}
272
272
 
273
273
  The setting accepts the following values:
274
274
 
@@ -290,7 +290,7 @@ type Foo = (name: string, age: number) => string & Person;
290
290
 
291
291
  ### `allowConditionalTypes`
292
292
 
293
- This applies to conditional types.
293
+ {/* insert option description */}
294
294
 
295
295
  Examples of **correct** code for the `{ "allowConditionalTypes": "always" }` option:
296
296
 
@@ -300,7 +300,7 @@ type Foo<T> = T extends number ? number : null;
300
300
 
301
301
  ### `allowConstructors`
302
302
 
303
- This applies to constructor types.
303
+ {/* insert option description */}
304
304
 
305
305
  The setting accepts the following values:
306
306
 
@@ -314,7 +314,7 @@ type Foo = new () => void;
314
314
 
315
315
  ### `allowLiterals`
316
316
 
317
- This applies to literal types (`type Foo = { ... }`).
317
+ {/* insert option description */}
318
318
 
319
319
  The setting accepts the following options:
320
320
 
@@ -421,7 +421,7 @@ type Foo = { name: string } & { age: number };
421
421
 
422
422
  ### `allowMappedTypes`
423
423
 
424
- This applies to literal types.
424
+ {/* insert option description */}
425
425
 
426
426
  The setting accepts the following values:
427
427
 
@@ -524,7 +524,7 @@ type Foo<T, U> = { [P in keyof T]?: T[P] } & { [P in keyof U]?: U[P] };
524
524
 
525
525
  ### `allowTupleTypes`
526
526
 
527
- This applies to tuple types (`type Foo = [number]`).
527
+ {/* insert option description */}
528
528
 
529
529
  The setting accepts the following options:
530
530
 
@@ -599,7 +599,7 @@ type Foo = [string] | [number];
599
599
 
600
600
  ### `allowGenerics`
601
601
 
602
- This applies to generic types, including TypeScript provided global utility types (`type Foo = Record<string, number>`).
602
+ {/* insert option description */}
603
603
 
604
604
  The setting accepts the following options:
605
605
 
@@ -61,6 +61,8 @@ are **not** checked by default.
61
61
 
62
62
  ### `allowComparingNullableBooleansToTrue`
63
63
 
64
+ {/* insert option description */}
65
+
64
66
  Examples of code for this rule with `{ allowComparingNullableBooleansToTrue: false }`:
65
67
 
66
68
  <Tabs>
@@ -94,6 +96,8 @@ if (!someNullCondition) {
94
96
 
95
97
  ### `allowComparingNullableBooleansToFalse`
96
98
 
99
+ {/* insert option description */}
100
+
97
101
  Examples of code for this rule with `{ allowComparingNullableBooleansToFalse: false }`:
98
102
 
99
103
  <Tabs>
@@ -82,6 +82,8 @@ function bar(arg?: string | null) {
82
82
 
83
83
  ### `allowConstantLoopConditions`
84
84
 
85
+ {/* insert option description */}
86
+
85
87
  Example of correct code for `{ allowConstantLoopConditions: true }`:
86
88
 
87
89
  ```ts option='{ "allowConstantLoopConditions": true }' showPlaygroundButton
@@ -92,6 +94,8 @@ do {} while (true);
92
94
 
93
95
  ### `checkTypePredicates`
94
96
 
97
+ {/* insert option description */}
98
+
95
99
  Example of additional incorrect code with `{ checkTypePredicates: true }`:
96
100
 
97
101
  ```ts option='{ "checkTypePredicates": true }' showPlaygroundButton
@@ -132,6 +136,8 @@ However, in some contexts, it may be more appropriate to keep this option disabl
132
136
 
133
137
  ### `allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing`
134
138
 
139
+ {/* insert option description */}
140
+
135
141
  :::danger Deprecated
136
142
  This option will be removed in the next major version of typescript-eslint.
137
143
  :::
@@ -75,6 +75,8 @@ function foo(x: number | undefined): number {
75
75
 
76
76
  ### `typesToIgnore`
77
77
 
78
+ {/* insert option description */}
79
+
78
80
  With `@typescript-eslint/no-unnecessary-type-assertion: ["error", { typesToIgnore: ['Foo'] }]`, the following is **correct** code:
79
81
 
80
82
  ```ts option='{ "typesToIgnore": ["Foo"] }' showPlaygroundButton
@@ -33,7 +33,7 @@ const defaultOptions: Options = {
33
33
 
34
34
  ### `enums`
35
35
 
36
- Whether to check references to enums before the enum declaration.
36
+ {/* insert option description */}
37
37
 
38
38
  If this is `true`, this rule warns every reference to a enum before the enum declaration.
39
39
  If this is `false`, this rule will ignore references to enums, when the reference is in a child scope.
@@ -69,7 +69,7 @@ enum Foo {
69
69
 
70
70
  ### `typedefs`
71
71
 
72
- Whether to check references to types before the type declaration.
72
+ {/* insert option description */}
73
73
 
74
74
  If this is `true`, this rule warns every reference to a type before the type declaration.
75
75
  If this is `false`, this rule will ignore references to types.
@@ -83,7 +83,7 @@ type StringOrNumber = string | number;
83
83
 
84
84
  ### `ignoreTypeReferences`
85
85
 
86
- Whether to ignore type references, such as in type annotations and assertions.
86
+ {/* insert option description */}
87
87
 
88
88
  If this is `true`, this rule ignores all type references.
89
89
  If this is `false`, this will check all type references.
@@ -44,6 +44,8 @@ import foo from 'foo';
44
44
 
45
45
  ### `allow`
46
46
 
47
+ {/* insert option description */}
48
+
47
49
  A array of strings. These strings will be compiled into regular expressions with the `u` flag and be used to test against the imported path. A common use case is to allow importing `package.json`. This is because `package.json` commonly lives outside of the TS root directory, so statically importing it would lead to root directory conflicts, especially with `resolveJsonModule` enabled. You can also use it to allow importing any JSON if your environment doesn't support JSON modules, or use it for other cases where `import` statements cannot work.
48
50
 
49
51
  With `{allow: ['/package\\.json$']}`:
@@ -24,6 +24,8 @@ It may take an options object containing either or both of:
24
24
 
25
25
  ### `allow`
26
26
 
27
+ {/* insert option description */}
28
+
27
29
  If you would like to ignore certain kinds of properties then you may pass an object containing `"allow"` as an array of any of the following options:
28
30
 
29
31
  - `allow`, an array containing one or more of the allowed modifiers. Valid values are:
@@ -50,8 +52,10 @@ For example, to ignore `public` properties:
50
52
 
51
53
  ### `prefer`
52
54
 
53
- By default, the rule prefers class property (`"class-property"`).
54
- You can switch it to instead preferring parameter property with (`"parameter-property"`).
55
+ {/* insert option description */}
56
+
57
+ By default, the rule prefers class properties.
58
+ You can switch it to instead preferring parameter properties with (`"parameter-property"`).
55
59
 
56
60
  In `"parameter-property"` mode, the rule will issue a report when:
57
61
 
@@ -80,7 +80,7 @@ const defaultOptions: Options = [
80
80
 
81
81
  ### `enforceForDeclarationWithTypeAnnotation`
82
82
 
83
- When set to `true`, type annotated variable declarations are enforced to use destructuring assignment.
83
+ {/* insert option description */}
84
84
 
85
85
  Examples with `{ enforceForDeclarationWithTypeAnnotation: true }`:
86
86
 
@@ -68,7 +68,7 @@ enum Valid {
68
68
 
69
69
  ### `allowBitwiseExpressions`
70
70
 
71
- Whether to allow using bitwise expressions in enum initializers (default: `false`).
71
+ {/* insert option description */}
72
72
 
73
73
  Examples of code for the `{ "allowBitwiseExpressions": true }` option:
74
74
 
@@ -25,7 +25,7 @@ This rule will not work as expected if [`strictNullChecks`](https://www.typescri
25
25
 
26
26
  ### `ignoreTernaryTests`
27
27
 
28
- Whether to ignore any ternary expressions that could be simplified by using the nullish coalescing operator. This is set to `false` by default.
28
+ {/* insert option description */}
29
29
 
30
30
  Incorrect code for `ignoreTernaryTests: false`, and correct code for `ignoreTernaryTests: true`:
31
31
 
@@ -65,7 +65,7 @@ foo ?? 'a string';
65
65
 
66
66
  ### `ignoreConditionalTests`
67
67
 
68
- Whether to ignore cases that are located within a conditional test. This is set to `true` by default.
68
+ {/* insert option description */}
69
69
 
70
70
  Generally expressions within conditional tests intentionally use the falsy fallthrough behavior of the logical or operator, meaning that fixing the operator to the nullish coalesce operator could cause bugs.
71
71
 
@@ -107,7 +107,7 @@ a ?? b ? true : false;
107
107
 
108
108
  ### `ignoreMixedLogicalExpressions`
109
109
 
110
- Whether to ignore any logical or expressions that are part of a mixed logical expression (with `&&`). This is set to `false` by default.
110
+ {/* insert option description */}
111
111
 
112
112
  Generally expressions within mixed logical expressions intentionally use the falsy fallthrough behavior of the logical or operator, meaning that fixing the operator to the nullish coalesce operator could cause bugs.
113
113
 
@@ -147,7 +147,7 @@ a ?? (b && c && d);
147
147
 
148
148
  ### `ignorePrimitives`
149
149
 
150
- Whether to ignore all (`true`) or some (an object with properties) primitive types.
150
+ {/* insert option description */}
151
151
 
152
152
  If you would like to ignore expressions containing operands of certain primitive types that can be falsy then you may pass an object containing a boolean value for each primitive:
153
153
 
@@ -174,6 +174,8 @@ Also, if you would like to ignore all primitives types, you can set `ignorePrimi
174
174
 
175
175
  ### `allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing`
176
176
 
177
+ {/* insert option description */}
178
+
177
179
  :::danger Deprecated
178
180
 
179
181
  > This option will be removed in the next major version of typescript-eslint.