@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
@@ -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.
@@ -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
- When this option is `true` the rule will check operands that are typed as `any` when inspecting "loose boolean" operands.
94
+ {/* insert option description */}
93
95
 
94
- <Tabs>
96
+ Examples of code for this rule with `{ checkAny: false }`:
95
97
 
96
- <TabItem value="❌ Incorrect for `checkAny: true`">
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 for `checkAny: false`">
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
- When this option is `true` the rule will check operands that are typed as `unknown` when inspecting "loose boolean" operands.
121
+ {/* insert option description */}
119
122
 
120
- <Tabs>
123
+ Examples of code for this rule with `{ checkUnknown: false }`:
121
124
 
122
- <TabItem value="❌ Incorrect for `checkUnknown: true`">
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 for `checkUnknown: false`">
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
- When this option is `true` the rule will check operands that are typed as `string` when inspecting "loose boolean" operands.
148
+ {/* insert option description */}
145
149
 
146
- <Tabs>
150
+ Examples of code for this rule with `{ checkString: false }`:
147
151
 
148
- <TabItem value="❌ Incorrect for `checkString: true`">
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 for `checkString: false`">
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
- When this option is `true` the rule will check operands that are typed as `number` when inspecting "loose boolean" operands.
175
+ {/* insert option description */}
171
176
 
172
- <Tabs>
177
+ Examples of code for this rule with `{ checkNumber: false }`:
173
178
 
174
- <TabItem value="❌ Incorrect for `checkNumber: true`">
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 for `checkNumber: false`">
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
- When this option is `true` the rule will check operands that are typed as `boolean` when inspecting "loose boolean" operands.
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
- <Tabs>
218
+ Examples of code for this rule with `{ checkBoolean: false }`:
213
219
 
214
- <TabItem value="❌ Incorrect for `checkBoolean: true`">
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 for `checkBoolean: false`">
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
- When this option is `true` the rule will check operands that are typed as `bigint` when inspecting "loose boolean" operands.
243
+ {/* insert option description */}
237
244
 
238
- <Tabs>
245
+ Examples of code for this rule with `{ checkBigInt: false }`:
239
246
 
240
- <TabItem value="❌ Incorrect for `checkBigInt: true`">
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 for `checkBigInt: false`">
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
- When this option is `true` the rule will skip operands that are not typed with `null` and/or `undefined` when inspecting "loose boolean" operands.
270
+ {/* insert option description */}
263
271
 
264
- <Tabs>
272
+ Examples of code for this rule with `{ requireNullish: false }`:
265
273
 
266
- <TabItem value="❌ Incorrect for `requireNullish: true`">
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 for `requireNullish: true`">
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
- An array of type specifiers to ignore.
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
- Whether to check class parameter properties.
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
- Whether to ignore parameters which don't explicitly specify a type.
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
- Whether to treat all mutable methods as though they are readonly.
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}`:
@@ -70,7 +70,7 @@ class Container {
70
70
 
71
71
  ### `onlyInlineLambdas`
72
72
 
73
- You may pass `"onlyInlineLambdas": true` as a rule option within an object to restrict checking only to members immediately assigned a lambda value.
73
+ {/* insert option description */}
74
74
 
75
75
  ```jsonc
76
76
  {
@@ -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
- Whether to ignore functions that return `any` or `unknown`.
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
- Whether to check arrow functions.
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
- Whether to check standalone function declarations.
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
- Whether to check inline function expressions.
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
- Whether to check methods on classes and object literals.
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
 
@@ -57,6 +57,8 @@ userDefinedType.sort();
57
57
 
58
58
  ### `ignoreStringArrays`
59
59
 
60
+ {/* insert option description */}
61
+
60
62
  Examples of code for this rule with `{ ignoreStringArrays: true }`:
61
63
 
62
64
  <Tabs>
@@ -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>