@typescript-eslint/eslint-plugin 7.2.1-alpha.1 → 7.2.1-alpha.3

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 (183) hide show
  1. package/dist/configs/all.js +1 -0
  2. package/dist/configs/all.js.map +1 -1
  3. package/dist/configs/disable-type-checked.js +1 -0
  4. package/dist/configs/disable-type-checked.js.map +1 -1
  5. package/dist/configs/strict-type-checked-only.js +23 -3
  6. package/dist/configs/strict-type-checked-only.js.map +1 -1
  7. package/dist/configs/strict-type-checked.js +27 -4
  8. package/dist/configs/strict-type-checked.js.map +1 -1
  9. package/dist/configs/strict.js +4 -1
  10. package/dist/configs/strict.js.map +1 -1
  11. package/dist/rules/ban-ts-comment.js +4 -1
  12. package/dist/rules/ban-ts-comment.js.map +1 -1
  13. package/dist/rules/consistent-type-imports.js +1 -0
  14. package/dist/rules/consistent-type-imports.js.map +1 -1
  15. package/dist/rules/index.js +2 -0
  16. package/dist/rules/index.js.map +1 -1
  17. package/dist/rules/no-floating-promises.js +4 -1
  18. package/dist/rules/no-floating-promises.js.map +1 -1
  19. package/dist/rules/no-misused-promises.js +1 -1
  20. package/dist/rules/no-misused-promises.js.map +1 -1
  21. package/dist/rules/no-redundant-type-constituents.js +42 -0
  22. package/dist/rules/no-redundant-type-constituents.js.map +1 -1
  23. package/dist/rules/no-unnecessary-qualifier.js +1 -1
  24. package/dist/rules/no-unnecessary-qualifier.js.map +1 -1
  25. package/dist/rules/no-unsafe-argument.js +1 -25
  26. package/dist/rules/no-unsafe-argument.js.map +1 -1
  27. package/dist/rules/no-unused-expressions.js +6 -2
  28. package/dist/rules/no-unused-expressions.js.map +1 -1
  29. package/dist/rules/restrict-plus-operands.js +12 -1
  30. package/dist/rules/restrict-plus-operands.js.map +1 -1
  31. package/dist/rules/restrict-template-expressions.js +52 -87
  32. package/dist/rules/restrict-template-expressions.js.map +1 -1
  33. package/dist/rules/use-unknown-in-catch-callback-variable.js +283 -0
  34. package/dist/rules/use-unknown-in-catch-callback-variable.js.map +1 -0
  35. package/dist/util/misc.js +10 -1
  36. package/dist/util/misc.js.map +1 -1
  37. package/docs/rules/TEMPLATE.md +10 -4
  38. package/docs/rules/{adjacent-overload-signatures.md → adjacent-overload-signatures.mdx} +11 -5
  39. package/docs/rules/{array-type.md → array-type.mdx} +24 -12
  40. package/docs/rules/{await-thenable.md → await-thenable.mdx} +10 -4
  41. package/docs/rules/{ban-ts-comment.md → ban-ts-comment.mdx} +32 -18
  42. package/docs/rules/{ban-tslint-comment.md → ban-tslint-comment.mdx} +10 -4
  43. package/docs/rules/{ban-types.md → ban-types.mdx} +11 -5
  44. package/docs/rules/{block-spacing.md → block-spacing.mdx} +3 -0
  45. package/docs/rules/{brace-style.md → brace-style.mdx} +3 -0
  46. package/docs/rules/camelcase.md +3 -5
  47. package/docs/rules/{class-literal-property-style.md → class-literal-property-style.mdx} +18 -11
  48. package/docs/rules/{class-methods-use-this.md → class-methods-use-this.mdx} +12 -6
  49. package/docs/rules/{comma-dangle.md → comma-dangle.mdx} +3 -0
  50. package/docs/rules/{comma-spacing.md → comma-spacing.mdx} +3 -0
  51. package/docs/rules/{consistent-generic-constructors.md → consistent-generic-constructors.mdx} +17 -8
  52. package/docs/rules/{consistent-indexed-object-style.md → consistent-indexed-object-style.mdx} +17 -8
  53. package/docs/rules/{consistent-return.md → consistent-return.mdx} +10 -4
  54. package/docs/rules/{consistent-type-assertions.md → consistent-type-assertions.mdx} +15 -10
  55. package/docs/rules/{consistent-type-definitions.md → consistent-type-definitions.mdx} +17 -8
  56. package/docs/rules/{consistent-type-exports.md → consistent-type-exports.mdx} +17 -8
  57. package/docs/rules/{consistent-type-imports.md → consistent-type-imports.mdx} +13 -8
  58. package/docs/rules/{default-param-last.md → default-param-last.mdx} +10 -4
  59. package/docs/rules/{dot-notation.md → dot-notation.mdx} +3 -0
  60. package/docs/rules/{explicit-function-return-type.md → explicit-function-return-type.mdx} +59 -32
  61. package/docs/rules/{explicit-member-accessibility.md → explicit-member-accessibility.mdx} +3 -0
  62. package/docs/rules/{explicit-module-boundary-types.md → explicit-module-boundary-types.mdx} +39 -21
  63. package/docs/rules/{func-call-spacing.md → func-call-spacing.mdx} +3 -0
  64. package/docs/rules/{indent.md → indent.mdx} +3 -0
  65. package/docs/rules/{init-declarations.md → init-declarations.mdx} +3 -0
  66. package/docs/rules/{key-spacing.md → key-spacing.mdx} +3 -0
  67. package/docs/rules/{keyword-spacing.md → keyword-spacing.mdx} +3 -0
  68. package/docs/rules/{lines-around-comment.md → lines-around-comment.mdx} +3 -0
  69. package/docs/rules/{lines-between-class-members.md → lines-between-class-members.mdx} +3 -0
  70. package/docs/rules/{max-params.md → max-params.mdx} +3 -0
  71. package/docs/rules/{member-delimiter-style.md → member-delimiter-style.mdx} +13 -7
  72. package/docs/rules/{member-ordering.md → member-ordering.mdx} +92 -56
  73. package/docs/rules/{method-signature-style.md → method-signature-style.mdx} +17 -8
  74. package/docs/rules/{naming-convention.md → naming-convention.mdx} +3 -0
  75. package/docs/rules/{no-array-constructor.md → no-array-constructor.mdx} +10 -4
  76. package/docs/rules/{no-array-delete.md → no-array-delete.mdx} +9 -5
  77. package/docs/rules/{no-base-to-string.md → no-base-to-string.mdx} +12 -6
  78. package/docs/rules/{no-confusing-non-null-assertion.md → no-confusing-non-null-assertion.mdx} +11 -5
  79. package/docs/rules/{no-confusing-void-expression.md → no-confusing-void-expression.mdx} +10 -4
  80. package/docs/rules/{no-dupe-class-members.md → no-dupe-class-members.mdx} +4 -1
  81. package/docs/rules/{no-duplicate-enum-values.md → no-duplicate-enum-values.mdx} +10 -4
  82. package/docs/rules/{no-duplicate-imports.md → no-duplicate-imports.mdx} +1 -1
  83. package/docs/rules/{no-duplicate-type-constituents.md → no-duplicate-type-constituents.mdx} +10 -4
  84. package/docs/rules/{no-dynamic-delete.md → no-dynamic-delete.mdx} +10 -4
  85. package/docs/rules/{no-empty-function.md → no-empty-function.mdx} +3 -0
  86. package/docs/rules/{no-empty-interface.md → no-empty-interface.mdx} +9 -5
  87. package/docs/rules/{no-explicit-any.md → no-explicit-any.mdx} +15 -9
  88. package/docs/rules/{no-extra-non-null-assertion.md → no-extra-non-null-assertion.mdx} +11 -5
  89. package/docs/rules/{no-extra-parens.md → no-extra-parens.mdx} +3 -0
  90. package/docs/rules/{no-extra-semi.md → no-extra-semi.mdx} +3 -0
  91. package/docs/rules/{no-extraneous-class.md → no-extraneous-class.mdx} +61 -33
  92. package/docs/rules/{no-floating-promises.md → no-floating-promises.mdx} +12 -6
  93. package/docs/rules/{no-for-in-array.md → no-for-in-array.mdx} +10 -4
  94. package/docs/rules/{no-implied-eval.md → no-implied-eval.mdx} +10 -4
  95. package/docs/rules/{no-import-type-side-effects.md → no-import-type-side-effects.mdx} +12 -6
  96. package/docs/rules/{no-inferrable-types.md → no-inferrable-types.mdx} +9 -5
  97. package/docs/rules/{no-invalid-this.md → no-invalid-this.mdx} +4 -1
  98. package/docs/rules/{no-invalid-void-type.md → no-invalid-void-type.mdx} +10 -4
  99. package/docs/rules/{no-loop-func.md → no-loop-func.mdx} +3 -0
  100. package/docs/rules/{no-loss-of-precision.md → no-loss-of-precision.mdx} +3 -0
  101. package/docs/rules/{no-magic-numbers.md → no-magic-numbers.mdx} +3 -0
  102. package/docs/rules/{no-meaningless-void-operator.md → no-meaningless-void-operator.mdx} +12 -4
  103. package/docs/rules/{no-misused-new.md → no-misused-new.mdx} +10 -4
  104. package/docs/rules/{no-misused-promises.md → no-misused-promises.mdx} +24 -16
  105. package/docs/rules/{no-mixed-enums.md → no-mixed-enums.mdx} +14 -6
  106. package/docs/rules/{no-namespace.md → no-namespace.mdx} +29 -18
  107. package/docs/rules/{no-non-null-asserted-nullish-coalescing.md → no-non-null-asserted-nullish-coalescing.mdx} +10 -4
  108. package/docs/rules/{no-non-null-asserted-optional-chain.md → no-non-null-asserted-optional-chain.mdx} +10 -4
  109. package/docs/rules/{no-non-null-assertion.md → no-non-null-assertion.mdx} +10 -4
  110. package/docs/rules/{no-redeclare.md → no-redeclare.mdx} +4 -1
  111. package/docs/rules/{no-redundant-type-constituents.md → no-redundant-type-constituents.mdx} +10 -4
  112. package/docs/rules/{no-require-imports.md → no-require-imports.mdx} +18 -9
  113. package/docs/rules/{no-restricted-imports.md → no-restricted-imports.mdx} +10 -4
  114. package/docs/rules/{no-shadow.md → no-shadow.mdx} +4 -1
  115. package/docs/rules/{no-this-alias.md → no-this-alias.mdx} +24 -12
  116. package/docs/rules/{no-throw-literal.md → no-throw-literal.mdx} +11 -5
  117. package/docs/rules/{no-type-alias.md → no-type-alias.mdx} +5 -2
  118. package/docs/rules/{no-unnecessary-boolean-literal-compare.md → no-unnecessary-boolean-literal-compare.mdx} +24 -12
  119. package/docs/rules/{no-unnecessary-condition.md → no-unnecessary-condition.mdx} +11 -5
  120. package/docs/rules/{no-unnecessary-qualifier.md → no-unnecessary-qualifier.mdx} +10 -4
  121. package/docs/rules/{no-unnecessary-type-arguments.md → no-unnecessary-type-arguments.mdx} +10 -4
  122. package/docs/rules/{no-unnecessary-type-assertion.md → no-unnecessary-type-assertion.mdx} +10 -4
  123. package/docs/rules/{no-unnecessary-type-constraint.md → no-unnecessary-type-constraint.mdx} +10 -4
  124. package/docs/rules/{no-unsafe-argument.md → no-unsafe-argument.mdx} +14 -10
  125. package/docs/rules/{no-unsafe-assignment.md → no-unsafe-assignment.mdx} +14 -10
  126. package/docs/rules/{no-unsafe-call.md → no-unsafe-call.mdx} +15 -9
  127. package/docs/rules/{no-unsafe-declaration-merging.md → no-unsafe-declaration-merging.mdx} +10 -4
  128. package/docs/rules/{no-unsafe-enum-comparison.md → no-unsafe-enum-comparison.mdx} +9 -5
  129. package/docs/rules/{no-unsafe-member-access.md → no-unsafe-member-access.mdx} +15 -9
  130. package/docs/rules/{no-unsafe-return.md → no-unsafe-return.mdx} +14 -10
  131. package/docs/rules/{no-unsafe-unary-minus.md → no-unsafe-unary-minus.mdx} +11 -5
  132. package/docs/rules/{no-unused-expressions.md → no-unused-expressions.mdx} +3 -0
  133. package/docs/rules/{no-unused-vars.md → no-unused-vars.mdx} +3 -0
  134. package/docs/rules/{no-use-before-define.md → no-use-before-define.mdx} +10 -4
  135. package/docs/rules/{no-useless-constructor.md → no-useless-constructor.mdx} +3 -0
  136. package/docs/rules/{no-useless-empty-export.md → no-useless-empty-export.mdx} +10 -4
  137. package/docs/rules/{no-useless-template-literals.md → no-useless-template-literals.mdx} +10 -6
  138. package/docs/rules/{no-var-requires.md → no-var-requires.mdx} +18 -9
  139. package/docs/rules/{non-nullable-type-assertion-style.md → non-nullable-type-assertion-style.mdx} +10 -4
  140. package/docs/rules/{object-curly-spacing.md → object-curly-spacing.mdx} +3 -0
  141. package/docs/rules/{padding-line-between-statements.md → padding-line-between-statements.mdx} +3 -0
  142. package/docs/rules/{parameter-properties.md → parameter-properties.mdx} +66 -36
  143. package/docs/rules/{prefer-as-const.md → prefer-as-const.mdx} +9 -5
  144. package/docs/rules/{prefer-destructuring.md → prefer-destructuring.mdx} +23 -12
  145. package/docs/rules/{prefer-enum-initializers.md → prefer-enum-initializers.mdx} +10 -4
  146. package/docs/rules/{prefer-find.md → prefer-find.mdx} +10 -4
  147. package/docs/rules/{prefer-for-of.md → prefer-for-of.mdx} +11 -5
  148. package/docs/rules/{prefer-function-type.md → prefer-function-type.mdx} +10 -4
  149. package/docs/rules/{prefer-includes.md → prefer-includes.mdx} +11 -5
  150. package/docs/rules/{prefer-literal-enum-member.md → prefer-literal-enum-member.mdx} +16 -9
  151. package/docs/rules/{prefer-namespace-keyword.md → prefer-namespace-keyword.mdx} +9 -5
  152. package/docs/rules/{prefer-nullish-coalescing.md → prefer-nullish-coalescing.mdx} +3 -0
  153. package/docs/rules/{prefer-optional-chain.md → prefer-optional-chain.mdx} +58 -33
  154. package/docs/rules/{prefer-promise-reject-errors.md → prefer-promise-reject-errors.mdx} +10 -4
  155. package/docs/rules/{prefer-readonly-parameter-types.md → prefer-readonly-parameter-types.mdx} +36 -22
  156. package/docs/rules/{prefer-readonly.md → prefer-readonly.mdx} +17 -8
  157. package/docs/rules/{prefer-reduce-type-parameter.md → prefer-reduce-type-parameter.mdx} +10 -4
  158. package/docs/rules/{prefer-regexp-exec.md → prefer-regexp-exec.mdx} +10 -4
  159. package/docs/rules/{prefer-return-this-type.md → prefer-return-this-type.mdx} +10 -4
  160. package/docs/rules/{prefer-string-starts-ends-with.md → prefer-string-starts-ends-with.mdx} +9 -5
  161. package/docs/rules/{prefer-ts-expect-error.md → prefer-ts-expect-error.mdx} +10 -4
  162. package/docs/rules/{promise-function-async.md → promise-function-async.mdx} +24 -12
  163. package/docs/rules/{quotes.md → quotes.mdx} +3 -0
  164. package/docs/rules/{require-array-sort-compare.md → require-array-sort-compare.mdx} +17 -8
  165. package/docs/rules/{require-await.md → require-await.mdx} +3 -0
  166. package/docs/rules/{restrict-plus-operands.md → restrict-plus-operands.mdx} +54 -30
  167. package/docs/rules/{restrict-template-expressions.md → restrict-template-expressions.mdx} +24 -9
  168. package/docs/rules/{return-await.md → return-await.mdx} +24 -12
  169. package/docs/rules/{semi.md → semi.mdx} +4 -1
  170. package/docs/rules/{sort-type-constituents.md → sort-type-constituents.mdx} +31 -16
  171. package/docs/rules/{space-before-blocks.md → space-before-blocks.mdx} +10 -4
  172. package/docs/rules/{space-before-function-paren.md → space-before-function-paren.mdx} +3 -0
  173. package/docs/rules/{space-infix-ops.md → space-infix-ops.mdx} +3 -0
  174. package/docs/rules/{strict-boolean-expressions.md → strict-boolean-expressions.mdx} +11 -5
  175. package/docs/rules/{switch-exhaustiveness-check.md → switch-exhaustiveness-check.mdx} +19 -14
  176. package/docs/rules/{triple-slash-reference.md → triple-slash-reference.mdx} +30 -17
  177. package/docs/rules/{type-annotation-spacing.md → type-annotation-spacing.mdx} +49 -31
  178. package/docs/rules/{typedef.md → typedef.mdx} +60 -33
  179. package/docs/rules/{unbound-method.md → unbound-method.mdx} +12 -6
  180. package/docs/rules/{unified-signatures.md → unified-signatures.mdx} +18 -9
  181. package/docs/rules/use-unknown-in-catch-callback-variable.mdx +84 -0
  182. package/package.json +8 -8
  183. /package/docs/rules/{no-parameter-properties.md → no-parameter-properties.mdx} +0 -0
@@ -2,6 +2,9 @@
2
2
  description: 'Disallow classes used as namespaces.'
3
3
  ---
4
4
 
5
+ import Tabs from '@theme/Tabs';
6
+ import TabItem from '@theme/TabItem';
7
+
5
8
  > 🛑 This file is source code, not the primary documentation location! 🛑
6
9
  >
7
10
  > See **https://typescript-eslint.io/rules/no-extraneous-class** for documentation.
@@ -22,9 +25,8 @@ Those classes can generally be replaced with a standalone function.
22
25
 
23
26
  ## Examples
24
27
 
25
- <!--tabs-->
26
-
27
- ### ❌ Incorrect
28
+ <Tabs>
29
+ <TabItem value="❌ Incorrect">
28
30
 
29
31
  ```ts
30
32
  class StaticConstants {
@@ -42,7 +44,8 @@ class HelloWorldLogger {
42
44
  }
43
45
  ```
44
46
 
45
- ### ✅ Correct
47
+ </TabItem>
48
+ <TabItem value="✅ Correct">
46
49
 
47
50
  ```ts
48
51
  export const version = 42;
@@ -56,15 +59,17 @@ function logHelloWorld() {
56
59
  }
57
60
  ```
58
61
 
62
+ </TabItem>
63
+ </Tabs>
64
+
59
65
  ## Alternatives
60
66
 
61
67
  ### Individual Exports (Recommended)
62
68
 
63
69
  Instead of using a static utility class we recommend you individually export the utilities from your module.
64
70
 
65
- <!--tabs-->
66
-
67
- #### ❌ Incorrect
71
+ <Tabs>
72
+ <TabItem value="❌ Incorrect">
68
73
 
69
74
  ```ts
70
75
  export class Utilities {
@@ -82,7 +87,8 @@ export class Utilities {
82
87
  }
83
88
  ```
84
89
 
85
- #### ✅ Correct
90
+ </TabItem>
91
+ <TabItem value="✅ Correct">
86
92
 
87
93
  ```ts
88
94
  export function util1() {
@@ -98,6 +104,9 @@ export function util3() {
98
104
  }
99
105
  ```
100
106
 
107
+ </TabItem>
108
+ </Tabs>
109
+
101
110
  ### Namespace Imports (Not Recommended)
102
111
 
103
112
  If you strongly prefer to have all constructs from a module available as properties of a single object, you can `import * as` the module.
@@ -109,9 +118,8 @@ However, namespace imports are impacted by these downsides:
109
118
  - They also don't play as well with tree shaking in modern bundlers
110
119
  - They require a name prefix before each property's usage
111
120
 
112
- <!--tabs-->
113
-
114
- #### ❌ Incorrect
121
+ <Tabs>
122
+ <TabItem value="❌ Incorrect">
115
123
 
116
124
  ```ts
117
125
  // utilities.ts
@@ -127,7 +135,8 @@ import { Utilities } from './utilities';
127
135
  Utilities.sayHello();
128
136
  ```
129
137
 
130
- #### ⚠️ Namespace Imports
138
+ </TabItem>
139
+ <TabItem value="⚠️ Namespace Imports">
131
140
 
132
141
  ```ts
133
142
  // utilities.ts
@@ -141,7 +150,8 @@ import * as utilities from './utilities';
141
150
  utilities.sayHello();
142
151
  ```
143
152
 
144
- #### ✅ Standalone Imports
153
+ </TabItem>
154
+ <TabItem value="✅ Standalone Imports">
145
155
 
146
156
  ```ts
147
157
  // utilities.ts
@@ -155,6 +165,9 @@ import { sayHello } from './utilities';
155
165
  sayHello();
156
166
  ```
157
167
 
168
+ </TabItem>
169
+ </Tabs>
170
+
158
171
  ### Notes on Mutating Variables
159
172
 
160
173
  One case you need to be careful of is exporting mutable variables.
@@ -164,9 +177,8 @@ This means that importers can only ever read the first value they are assigned a
164
177
  Needing to write to an exported variable is very rare and is generally considered a code smell.
165
178
  If you do need it you can accomplish it using getter and setter functions:
166
179
 
167
- <!--tabs-->
168
-
169
- #### ❌ Incorrect
180
+ <Tabs>
181
+ <TabItem value="❌ Incorrect">
170
182
 
171
183
  ```ts
172
184
  export class Utilities {
@@ -178,7 +190,8 @@ export class Utilities {
178
190
  }
179
191
  ```
180
192
 
181
- #### ✅ Correct
193
+ </TabItem>
194
+ <TabItem value="✅ Correct">
182
195
 
183
196
  ```ts
184
197
  let mutableCount = 1;
@@ -192,6 +205,9 @@ export function incrementCount() {
192
205
  }
193
206
  ```
194
207
 
208
+ </TabItem>
209
+ </Tabs>
210
+
195
211
  ## Options
196
212
 
197
213
  This rule normally bans classes that are empty (have no constructor or fields).
@@ -201,15 +217,15 @@ The rule's options each add an exemption for a specific type of class.
201
217
 
202
218
  `allowConstructorOnly` adds an exemption for classes that have only a constructor and no fields.
203
219
 
204
- <!--tabs-->
205
-
206
- #### ❌ Incorrect
220
+ <Tabs>
221
+ <TabItem value="❌ Incorrect">
207
222
 
208
223
  ```ts option='{ "allowConstructorOnly": true }'
209
224
  class NoFields {}
210
225
  ```
211
226
 
212
- #### ✅ Correct
227
+ </TabItem>
228
+ <TabItem value="✅ Correct">
213
229
 
214
230
  ```ts option='{ "allowConstructorOnly": true }'
215
231
  class NoFields {
@@ -219,13 +235,15 @@ class NoFields {
219
235
  }
220
236
  ```
221
237
 
238
+ </TabItem>
239
+ </Tabs>
240
+
222
241
  ### `allowEmpty`
223
242
 
224
243
  The `allowEmpty` option adds an exemption for classes that are entirely empty.
225
244
 
226
- <!--tabs-->
227
-
228
- #### ❌ Incorrect
245
+ <Tabs>
246
+ <TabItem value="❌ Incorrect">
229
247
 
230
248
  ```ts option='{ "allowEmpty": true }'
231
249
  class NoFields {
@@ -235,12 +253,16 @@ class NoFields {
235
253
  }
236
254
  ```
237
255
 
238
- #### ✅ Correct
256
+ </TabItem>
257
+ <TabItem value="✅ Correct">
239
258
 
240
259
  ```ts option='{ "allowEmpty": true }'
241
260
  class NoFields {}
242
261
  ```
243
262
 
263
+ </TabItem>
264
+ </Tabs>
265
+
244
266
  ### `allowStaticOnly`
245
267
 
246
268
  The `allowStaticOnly` option adds an exemption for classes that only contain static members.
@@ -250,15 +272,15 @@ We strongly recommend against the `allowStaticOnly` exemption.
250
272
  It works against this rule's primary purpose of discouraging classes used only for static members.
251
273
  :::
252
274
 
253
- <!--tabs-->
254
-
255
- #### ❌ Incorrect
275
+ <Tabs>
276
+ <TabItem value="❌ Incorrect">
256
277
 
257
278
  ```ts option='{ "allowStaticOnly": true }'
258
279
  class EmptyClass {}
259
280
  ```
260
281
 
261
- #### ✅ Correct
282
+ </TabItem>
283
+ <TabItem value="✅ Correct">
262
284
 
263
285
  ```ts option='{ "allowStaticOnly": true }'
264
286
  class NotEmptyClass {
@@ -266,13 +288,15 @@ class NotEmptyClass {
266
288
  }
267
289
  ```
268
290
 
291
+ </TabItem>
292
+ </Tabs>
293
+
269
294
  ### `allowWithDecorator`
270
295
 
271
296
  The `allowWithDecorator` option adds an exemption for classes that contain a member decorated with a `@` decorator.
272
297
 
273
- <!--tabs-->
274
-
275
- #### ❌ Incorrect
298
+ <Tabs>
299
+ <TabItem value="❌ Incorrect">
276
300
 
277
301
  ```ts option='{ "allowWithDecorator": true }'
278
302
  class Constants {
@@ -280,7 +304,8 @@ class Constants {
280
304
  }
281
305
  ```
282
306
 
283
- #### ✅ Correct
307
+ </TabItem>
308
+ <TabItem value="✅ Correct">
284
309
 
285
310
  ```ts option='{ "allowWithDecorator": true }'
286
311
  class Constants {
@@ -289,6 +314,9 @@ class Constants {
289
314
  }
290
315
  ```
291
316
 
317
+ </TabItem>
318
+ </Tabs>
319
+
292
320
  ## When Not To Use It
293
321
 
294
322
  If your project was set up before modern class and namespace practices, and you don't have the time to switch over, you might not be practically able to use this rule.
@@ -2,6 +2,9 @@
2
2
  description: 'Require Promise-like statements to be handled appropriately.'
3
3
  ---
4
4
 
5
+ import Tabs from '@theme/Tabs';
6
+ import TabItem from '@theme/TabItem';
7
+
5
8
  > 🛑 This file is source code, not the primary documentation location! 🛑
6
9
  >
7
10
  > See **https://typescript-eslint.io/rules/no-floating-promises** for documentation.
@@ -26,14 +29,13 @@ This rule also reports when an Array containing Promises is created and not prop
26
29
 
27
30
  :::tip
28
31
  `no-floating-promises` only detects unhandled Promise _statements_.
29
- See [`no-misused-promises`](./no-misused-promises.md) for detecting code that provides Promises to _logical_ locations such as if statements.
32
+ See [`no-misused-promises`](./no-misused-promises.mdx) for detecting code that provides Promises to _logical_ locations such as if statements.
30
33
  :::
31
34
 
32
35
  ## Examples
33
36
 
34
- <!--tabs-->
35
-
36
- ### ❌ Incorrect
37
+ <Tabs>
38
+ <TabItem value="❌ Incorrect">
37
39
 
38
40
  ```ts
39
41
  const promise = new Promise((resolve, reject) => resolve('value'));
@@ -51,7 +53,8 @@ Promise.reject('value').finally();
51
53
  [1, 2, 3].map(async x => x + 1);
52
54
  ```
53
55
 
54
- ### ✅ Correct
56
+ </TabItem>
57
+ <TabItem value="✅ Correct">
55
58
 
56
59
  ```ts
57
60
  const promise = new Promise((resolve, reject) => resolve('value'));
@@ -72,6 +75,9 @@ await Promise.reject('value').finally(() => {});
72
75
  await Promise.all([1, 2, 3].map(async x => x + 1));
73
76
  ```
74
77
 
78
+ </TabItem>
79
+ </Tabs>
80
+
75
81
  ## Options
76
82
 
77
83
  ### `ignoreVoid`
@@ -117,7 +123,7 @@ You might consider using `void`s and/or [ESLint disable comments](https://eslint
117
123
 
118
124
  ## Related To
119
125
 
120
- - [`no-misused-promises`](./no-misused-promises.md)
126
+ - [`no-misused-promises`](./no-misused-promises.mdx)
121
127
 
122
128
  ## Further Reading
123
129
 
@@ -2,6 +2,9 @@
2
2
  description: 'Disallow iterating over an array with a for-in loop.'
3
3
  ---
4
4
 
5
+ import Tabs from '@theme/Tabs';
6
+ import TabItem from '@theme/TabItem';
7
+
5
8
  > 🛑 This file is source code, not the primary documentation location! 🛑
6
9
  >
7
10
  > See **https://typescript-eslint.io/rules/no-for-in-array** for documentation.
@@ -17,9 +20,8 @@ You may have confused for-in with for-of, which iterates over the elements of th
17
20
 
18
21
  ## Examples
19
22
 
20
- <!--tabs-->
21
-
22
- ### ❌ Incorrect
23
+ <Tabs>
24
+ <TabItem value="❌ Incorrect">
23
25
 
24
26
  ```ts
25
27
  declare const array: string[];
@@ -33,7 +35,8 @@ for (const i in array) {
33
35
  }
34
36
  ```
35
37
 
36
- ### ✅ Correct
38
+ </TabItem>
39
+ <TabItem value="✅ Correct">
37
40
 
38
41
  ```ts
39
42
  declare const array: string[];
@@ -55,6 +58,9 @@ for (const [i, value] of array.entries()) {
55
58
  }
56
59
  ```
57
60
 
61
+ </TabItem>
62
+ </Tabs>
63
+
58
64
  ## When Not To Use It
59
65
 
60
66
  If your project is a rare one that intentionally loops over string indices of arrays, you can turn off this rule.
@@ -2,6 +2,9 @@
2
2
  description: 'Disallow the use of `eval()`-like methods.'
3
3
  ---
4
4
 
5
+ import Tabs from '@theme/Tabs';
6
+ import TabItem from '@theme/TabItem';
7
+
5
8
  > 🛑 This file is source code, not the primary documentation location! 🛑
6
9
  >
7
10
  > See **https://typescript-eslint.io/rules/no-implied-eval** for documentation.
@@ -29,9 +32,8 @@ The best practice is to avoid using `new Function()` or `execScript()` and alway
29
32
 
30
33
  This rule aims to eliminate implied `eval()` through the use of `new Function()`, `setTimeout()`, `setInterval()`, `setImmediate()` or `execScript()`.
31
34
 
32
- <!--tabs-->
33
-
34
- ### ❌ Incorrect
35
+ <Tabs>
36
+ <TabItem value="❌ Incorrect">
35
37
 
36
38
  ```ts
37
39
  /* eslint @typescript-eslint/no-implied-eval: "error" */
@@ -59,7 +61,8 @@ setTimeout(fn(), 100);
59
61
  const fn = new Function('a', 'b', 'return a + b');
60
62
  ```
61
63
 
62
- ### ✅ Correct
64
+ </TabItem>
65
+ <TabItem value="✅ Correct">
63
66
 
64
67
  ```ts
65
68
  /* eslint @typescript-eslint/no-implied-eval: "error" */
@@ -96,6 +99,9 @@ class Foo {
96
99
  setTimeout(Foo.fn, 100);
97
100
  ```
98
101
 
102
+ </TabItem>
103
+ </Tabs>
104
+
99
105
  ## When Not To Use It
100
106
 
101
107
  If your project is a rare one that needs to allow `new Function()` or `setTimeout()`, `setInterval()`, `setImmediate()` and `execScript()` with string arguments, then you can disable this rule.
@@ -2,6 +2,9 @@
2
2
  description: 'Enforce the use of top-level import type qualifier when an import only has specifiers with inline type qualifiers.'
3
3
  ---
4
4
 
5
+ import Tabs from '@theme/Tabs';
6
+ import TabItem from '@theme/TabItem';
7
+
5
8
  > 🛑 This file is source code, not the primary documentation location! 🛑
6
9
  >
7
10
  > See **https://typescript-eslint.io/rules/no-import-type-side-effects** for documentation.
@@ -27,9 +30,8 @@ For the rare case of needing to import for side effects, this may be desirable -
27
30
 
28
31
  This rule enforces that you use a top-level `type` qualifier for imports when it only imports specifiers with an inline `type` qualifier
29
32
 
30
- <!--tabs-->
31
-
32
- ### ❌ Incorrect
33
+ <Tabs>
34
+ <TabItem value="❌ Incorrect">
33
35
 
34
36
  ```ts
35
37
  import { type A } from 'mod';
@@ -38,7 +40,8 @@ import { type A, type B } from 'mod';
38
40
  import { type A as AA, type B as BB } from 'mod';
39
41
  ```
40
42
 
41
- ### ✅ Correct
43
+ </TabItem>
44
+ <TabItem value="✅ Correct">
42
45
 
43
46
  ```ts
44
47
  import type { A } from 'mod';
@@ -63,12 +66,15 @@ import type T, { U } from 'mod';
63
66
  import T, { type U } from 'mod';
64
67
  ```
65
68
 
69
+ </TabItem>
70
+ </Tabs>
71
+
66
72
  ## When Not To Use It
67
73
 
68
74
  If you're not using TypeScript 5.0's `verbatimModuleSyntax` option and your project is built with a bundler that manages import side effects for you, this rule may not be as useful for you.
69
75
 
70
76
  ## Related To
71
77
 
72
- - [`consistent-type-imports`](./consistent-type-imports.md)
73
- - [`import/consistent-type-specifier-style`](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/consistent-type-specifier-style.md)
78
+ - [`consistent-type-imports`](./consistent-type-imports.mdx)
79
+ - [`import/consistent-type-specifier-style`](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/consistent-type-specifier-style.mdx)
74
80
  - [`import/no-duplicates` with `{"prefer-inline": true}`](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-duplicates.md#inline-type-imports)
@@ -2,6 +2,9 @@
2
2
  description: 'Disallow explicit type declarations for variables or parameters initialized to a number, string, or boolean.'
3
3
  ---
4
4
 
5
+ import Tabs from '@theme/Tabs';
6
+ import TabItem from '@theme/TabItem';
7
+
5
8
  > 🛑 This file is source code, not the primary documentation location! 🛑
6
9
  >
7
10
  > See **https://typescript-eslint.io/rules/no-inferrable-types** for documentation.
@@ -12,9 +15,8 @@ Doing so adds unnecessary verbosity to code -making it harder to read- and in so
12
15
 
13
16
  ## Examples
14
17
 
15
- <!--tabs-->
16
-
17
- ### ❌ Incorrect
18
+ <Tabs>
19
+ <TabItem value="❌ Incorrect">
18
20
 
19
21
  ```ts
20
22
  const a: bigint = 10n;
@@ -42,7 +44,8 @@ class Foo {
42
44
  function fn(a: number = 5, b: boolean = true) {}
43
45
  ```
44
46
 
45
- ### ✅ Correct
47
+ </TabItem>
48
+ <TabItem value="✅ Correct">
46
49
 
47
50
  ```ts
48
51
  const a = 10n;
@@ -70,7 +73,8 @@ class Foo {
70
73
  function fn(a = 5, b = true) {}
71
74
  ```
72
75
 
73
- <!--/tabs-->
76
+ </TabItem>
77
+ </Tabs>
74
78
 
75
79
  ## Options
76
80
 
@@ -2,11 +2,14 @@
2
2
  description: 'Disallow `this` keywords outside of classes or class-like objects.'
3
3
  ---
4
4
 
5
+ import Tabs from '@theme/Tabs';
6
+ import TabItem from '@theme/TabItem';
7
+
5
8
  > 🛑 This file is source code, not the primary documentation location! 🛑
6
9
  >
7
10
  > See **https://typescript-eslint.io/rules/no-invalid-this** for documentation.
8
11
 
9
- import TypeScriptOverlap from "@site/src/components/TypeScriptOverlap";
12
+ import TypeScriptOverlap from '@site/src/components/TypeScriptOverlap';
10
13
 
11
14
  <TypeScriptOverlap strict />
12
15
 
@@ -2,6 +2,9 @@
2
2
  description: 'Disallow `void` type outside of generic or return types.'
3
3
  ---
4
4
 
5
+ import Tabs from '@theme/Tabs';
6
+ import TabItem from '@theme/TabItem';
7
+
5
8
  > 🛑 This file is source code, not the primary documentation location! 🛑
6
9
  >
7
10
  > See **https://typescript-eslint.io/rules/no-invalid-void-type** for documentation.
@@ -15,9 +18,8 @@ Attempting to use a `void` type outside of a return type or generic type argumen
15
18
 
16
19
  ## Examples
17
20
 
18
- <!--tabs-->
19
-
20
- ### ❌ Incorrect
21
+ <Tabs>
22
+ <TabItem value="❌ Incorrect">
21
23
 
22
24
  ```ts
23
25
  type PossibleValues = string | number | void;
@@ -38,7 +40,8 @@ class MyClass {
38
40
  }
39
41
  ```
40
42
 
41
- ### ✅ Correct
43
+ </TabItem>
44
+ <TabItem value="✅ Correct">
42
45
 
43
46
  ```ts
44
47
  type NoOp = () => void;
@@ -52,6 +55,9 @@ async function promiseMeSomething(): Promise<void> {}
52
55
  type stillVoid = void | never;
53
56
  ```
54
57
 
58
+ </TabItem>
59
+ </Tabs>
60
+
55
61
  ## Options
56
62
 
57
63
  ### `allowInGenericTypeArguments`
@@ -2,6 +2,9 @@
2
2
  description: 'Disallow function declarations that contain unsafe references inside loop statements.'
3
3
  ---
4
4
 
5
+ import Tabs from '@theme/Tabs';
6
+ import TabItem from '@theme/TabItem';
7
+
5
8
  > 🛑 This file is source code, not the primary documentation location! 🛑
6
9
  >
7
10
  > See **https://typescript-eslint.io/rules/no-loop-func** for documentation.
@@ -2,6 +2,9 @@
2
2
  description: 'Disallow literal numbers that lose precision.'
3
3
  ---
4
4
 
5
+ import Tabs from '@theme/Tabs';
6
+ import TabItem from '@theme/TabItem';
7
+
5
8
  > 🛑 This file is source code, not the primary documentation location! 🛑
6
9
  >
7
10
  > See **https://typescript-eslint.io/rules/no-loss-of-precision** for documentation.
@@ -2,6 +2,9 @@
2
2
  description: 'Disallow magic numbers.'
3
3
  ---
4
4
 
5
+ import Tabs from '@theme/Tabs';
6
+ import TabItem from '@theme/TabItem';
7
+
5
8
  > 🛑 This file is source code, not the primary documentation location! 🛑
6
9
  >
7
10
  > See **https://typescript-eslint.io/rules/no-magic-numbers** for documentation.
@@ -2,13 +2,16 @@
2
2
  description: 'Disallow the `void` operator except when used to discard a value.'
3
3
  ---
4
4
 
5
+ import Tabs from '@theme/Tabs';
6
+ import TabItem from '@theme/TabItem';
7
+
5
8
  > 🛑 This file is source code, not the primary documentation location! 🛑
6
9
  >
7
10
  > See **https://typescript-eslint.io/rules/no-meaningless-void-operator** for documentation.
8
11
 
9
12
  `void` in TypeScript refers to a function return that is meant to be ignored.
10
13
  The `void` operator is a useful tool to convey the programmer's intent to discard a value.
11
- For example, it is recommended as one way of suppressing [`@typescript-eslint/no-floating-promises`](./no-floating-promises.md) instead of adding `.catch()` to a promise.
14
+ For example, it is recommended as one way of suppressing [`@typescript-eslint/no-floating-promises`](./no-floating-promises.mdx) instead of adding `.catch()` to a promise.
12
15
 
13
16
  This rule helps an authors catch API changes where previously a value was being discarded at a call site, but the callee changed so it no longer returns a value.
14
17
  When combined with [no-unused-expressions](https://eslint.org/docs/rules/no-unused-expressions), it also helps _readers_ of the code by ensuring consistency: a statement that looks like `void foo();` is **always** discarding a return value, and a statement that looks like `foo();` is **never** discarding a return value.
@@ -16,9 +19,10 @@ This rule reports on any `void` operator whose argument is already of type `void
16
19
 
17
20
  ## Examples
18
21
 
19
- <!--tabs-->
22
+ ## Examples
20
23
 
21
- ### ❌ Incorrect
24
+ <Tabs>
25
+ <TabItem value="❌ Incorrect">
22
26
 
23
27
  ```ts
24
28
  void (() => {})();
@@ -27,7 +31,8 @@ function foo() {}
27
31
  void foo();
28
32
  ```
29
33
 
30
- ### ✅ Correct
34
+ </TabItem>
35
+ <TabItem value="✅ Correct">
31
36
 
32
37
  ```ts
33
38
  (() => {})();
@@ -42,6 +47,9 @@ function bar(x: number) {
42
47
  void bar(); // discarding a number
43
48
  ```
44
49
 
50
+ </TabItem>
51
+ </Tabs>
52
+
45
53
  ## Options
46
54
 
47
55
  ### `checkNever`
@@ -2,6 +2,9 @@
2
2
  description: 'Enforce valid definition of `new` and `constructor`.'
3
3
  ---
4
4
 
5
+ import Tabs from '@theme/Tabs';
6
+ import TabItem from '@theme/TabItem';
7
+
5
8
  > 🛑 This file is source code, not the primary documentation location! 🛑
6
9
  >
7
10
  > See **https://typescript-eslint.io/rules/no-misused-new** for documentation.
@@ -14,9 +17,8 @@ This rule reports when a class defines a method named `new` or an interface defi
14
17
 
15
18
  ## Examples
16
19
 
17
- <!--tabs-->
18
-
19
- ### ❌ Incorrect
20
+ <Tabs>
21
+ <TabItem value="❌ Incorrect">
20
22
 
21
23
  ```ts
22
24
  declare class C {
@@ -29,7 +31,8 @@ interface I {
29
31
  }
30
32
  ```
31
33
 
32
- ### ✅ Correct
34
+ </TabItem>
35
+ <TabItem value="✅ Correct">
33
36
 
34
37
  ```ts
35
38
  declare class C {
@@ -41,6 +44,9 @@ interface I {
41
44
  }
42
45
  ```
43
46
 
47
+ </TabItem>
48
+ </Tabs>
49
+
44
50
  ## When Not To Use It
45
51
 
46
52
  If you intentionally want a class with a `new` method, and you're confident nobody working in your code will mistake it with a constructor, you might not want this rule.