@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: 'Require using `namespace` keyword over `module` keyword to declare custom TypeScript modules.'
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/prefer-namespace-keyword** for documentation.
@@ -18,15 +21,15 @@ This rule reports when the `module` keyword is used instead of `namespace`.
18
21
 
19
22
  ## Examples
20
23
 
21
- <!--tabs-->
22
-
23
- ### ❌ Incorrect
24
+ <Tabs>
25
+ <TabItem value="❌ Incorrect">
24
26
 
25
27
  ```ts
26
28
  module Example {}
27
29
  ```
28
30
 
29
- ### ✅ Correct
31
+ </TabItem>
32
+ <TabItem value="✅ Correct">
30
33
 
31
34
  ```ts
32
35
  namespace Example {}
@@ -34,7 +37,8 @@ namespace Example {}
34
37
  declare module 'foo' {}
35
38
  ```
36
39
 
37
- <!--/tabs-->
40
+ </TabItem>
41
+ </Tabs>
38
42
 
39
43
  ## When Not To Use It
40
44
 
@@ -2,6 +2,9 @@
2
2
  description: 'Enforce using the nullish coalescing operator instead of logical assignments or chaining.'
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/prefer-nullish-coalescing** for documentation.
@@ -2,6 +2,9 @@
2
2
  description: 'Enforce using concise optional chain expressions instead of chained logical ands, negated logical ors, or empty 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/prefer-optional-chain** for documentation.
@@ -14,9 +17,8 @@ This rule reports on code where an `&&` operator can be safely replaced with `?.
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
  foo && foo.a && foo.a.b && foo.a.b.c;
@@ -41,7 +43,8 @@ foo &&
41
43
  foo.a.b.c.d.e;
42
44
  ```
43
45
 
44
- ### ✅ Correct
46
+ </TabItem>
47
+ <TabItem value="✅ Correct">
45
48
 
46
49
  ```ts
47
50
  foo?.a?.b?.c;
@@ -55,7 +58,8 @@ foo?.a?.b?.c?.d?.e;
55
58
  !foo?.bar?.baz?.();
56
59
  ```
57
60
 
58
- <!--/tabs-->
61
+ </TabItem>
62
+ </Tabs>
59
63
 
60
64
  ## Options
61
65
 
@@ -87,9 +91,9 @@ When this option is `false` unsafe cases will have suggestion fixers provided in
87
91
 
88
92
  When this option is `true` the rule will check operands that are typed as `any` when inspecting "loose boolean" operands.
89
93
 
90
- <!--tabs-->
94
+ <Tabs>
91
95
 
92
- #### ❌ Incorrect for `checkAny: true`
96
+ <TabItem value="❌ Incorrect for `checkAny: true`">
93
97
 
94
98
  ```ts option='{ "checkAny": true }'
95
99
  declare const thing: any;
@@ -97,7 +101,9 @@ declare const thing: any;
97
101
  thing && thing.toString();
98
102
  ```
99
103
 
100
- #### ✅ Correct for `checkAny: false`
104
+ </TabItem>
105
+ <TabItem value="✅ Correct">
106
+ for `checkAny: false`
101
107
 
102
108
  ```ts option='{ "checkAny": false }'
103
109
  declare const thing: any;
@@ -105,15 +111,16 @@ declare const thing: any;
105
111
  thing && thing.toString();
106
112
  ```
107
113
 
108
- <!--/tabs-->
114
+ </TabItem>
115
+ </Tabs>
109
116
 
110
117
  ### `checkUnknown`
111
118
 
112
119
  When this option is `true` the rule will check operands that are typed as `unknown` when inspecting "loose boolean" operands.
113
120
 
114
- <!--tabs-->
121
+ <Tabs>
115
122
 
116
- #### ❌ Incorrect for `checkUnknown: true`
123
+ <TabItem value="❌ Incorrect for `checkUnknown: true`">
117
124
 
118
125
  ```ts option='{ "checkUnknown": true }'
119
126
  declare const thing: unknown;
@@ -121,7 +128,9 @@ declare const thing: unknown;
121
128
  thing && thing.toString();
122
129
  ```
123
130
 
124
- #### ✅ Correct for `checkUnknown: false`
131
+ </TabItem>
132
+ <TabItem value="✅ Correct">
133
+ for `checkUnknown: false`
125
134
 
126
135
  ```ts option='{ "checkUnknown": false }'
127
136
  declare const thing: unknown;
@@ -129,15 +138,16 @@ declare const thing: unknown;
129
138
  thing && thing.toString();
130
139
  ```
131
140
 
132
- <!--/tabs-->
141
+ </TabItem>
142
+ </Tabs>
133
143
 
134
144
  ### `checkString`
135
145
 
136
146
  When this option is `true` the rule will check operands that are typed as `string` when inspecting "loose boolean" operands.
137
147
 
138
- <!--tabs-->
148
+ <Tabs>
139
149
 
140
- #### ❌ Incorrect for `checkString: true`
150
+ <TabItem value="❌ Incorrect for `checkString: true`">
141
151
 
142
152
  ```ts option='{ "checkString": true }'
143
153
  declare const thing: string;
@@ -145,7 +155,9 @@ declare const thing: string;
145
155
  thing && thing.toString();
146
156
  ```
147
157
 
148
- #### ✅ Correct for `checkString: false`
158
+ </TabItem>
159
+ <TabItem value="✅ Correct">
160
+ for `checkString: false`
149
161
 
150
162
  ```ts option='{ "checkString": false }'
151
163
  declare const thing: string;
@@ -153,15 +165,16 @@ declare const thing: string;
153
165
  thing && thing.toString();
154
166
  ```
155
167
 
156
- <!--/tabs-->
168
+ </TabItem>
169
+ </Tabs>
157
170
 
158
171
  ### `checkNumber`
159
172
 
160
173
  When this option is `true` the rule will check operands that are typed as `number` when inspecting "loose boolean" operands.
161
174
 
162
- <!--tabs-->
175
+ <Tabs>
163
176
 
164
- #### ❌ Incorrect for `checkNumber: true`
177
+ <TabItem value="❌ Incorrect for `checkNumber: true`">
165
178
 
166
179
  ```ts option='{ "checkNumber": true }'
167
180
  declare const thing: number;
@@ -169,7 +182,9 @@ declare const thing: number;
169
182
  thing && thing.toString();
170
183
  ```
171
184
 
172
- #### ✅ Correct for `checkNumber: false`
185
+ </TabItem>
186
+ <TabItem value="✅ Correct">
187
+ for `checkNumber: false`
173
188
 
174
189
  ```ts option='{ "checkNumber": false }'
175
190
  declare const thing: number;
@@ -177,15 +192,16 @@ declare const thing: number;
177
192
  thing && thing.toString();
178
193
  ```
179
194
 
180
- <!--/tabs-->
195
+ </TabItem>
196
+ </Tabs>
181
197
 
182
198
  ### `checkBoolean`
183
199
 
184
200
  When this option is `true` the rule will check operands that are typed as `boolean` when inspecting "loose boolean" operands.
185
201
 
186
- <!--tabs-->
202
+ <Tabs>
187
203
 
188
- #### ❌ Incorrect for `checkBoolean: true`
204
+ <TabItem value="❌ Incorrect for `checkBoolean: true`">
189
205
 
190
206
  ```ts option='{ "checkBoolean": true }'
191
207
  declare const thing: boolean;
@@ -193,7 +209,9 @@ declare const thing: boolean;
193
209
  thing && thing.toString();
194
210
  ```
195
211
 
196
- #### ✅ Correct for `checkBoolean: false`
212
+ </TabItem>
213
+ <TabItem value="✅ Correct">
214
+ for `checkBoolean: false`
197
215
 
198
216
  ```ts option='{ "checkBoolean": false }'
199
217
  declare const thing: boolean;
@@ -201,15 +219,16 @@ declare const thing: boolean;
201
219
  thing && thing.toString();
202
220
  ```
203
221
 
204
- <!--/tabs-->
222
+ </TabItem>
223
+ </Tabs>
205
224
 
206
225
  ### `checkBigInt`
207
226
 
208
227
  When this option is `true` the rule will check operands that are typed as `bigint` when inspecting "loose boolean" operands.
209
228
 
210
- <!--tabs-->
229
+ <Tabs>
211
230
 
212
- #### ❌ Incorrect for `checkBigInt: true`
231
+ <TabItem value="❌ Incorrect for `checkBigInt: true`">
213
232
 
214
233
  ```ts option='{ "checkBigInt": true }'
215
234
  declare const thing: bigint;
@@ -217,7 +236,9 @@ declare const thing: bigint;
217
236
  thing && thing.toString();
218
237
  ```
219
238
 
220
- #### ✅ Correct for `checkBigInt: false`
239
+ </TabItem>
240
+ <TabItem value="✅ Correct">
241
+ for `checkBigInt: false`
221
242
 
222
243
  ```ts option='{ "checkBigInt": false }'
223
244
  declare const thing: bigint;
@@ -225,22 +246,25 @@ declare const thing: bigint;
225
246
  thing && thing.toString();
226
247
  ```
227
248
 
228
- <!--/tabs-->
249
+ </TabItem>
250
+ </Tabs>
229
251
 
230
252
  ### `requireNullish`
231
253
 
232
254
  When this option is `true` the rule will skip operands that are not typed with `null` and/or `undefined` when inspecting "loose boolean" operands.
233
255
 
234
- <!--tabs-->
256
+ <Tabs>
235
257
 
236
- #### ❌ Incorrect for `requireNullish: true`
258
+ <TabItem value="❌ Incorrect for `requireNullish: true`">
237
259
 
238
260
  ```ts option='{ "requireNullish": true }'
239
261
  declare const thing1: string | null;
240
262
  thing1 && thing1.toString();
241
263
  ```
242
264
 
243
- #### ✅ Correct for `requireNullish: true`
265
+ </TabItem>
266
+ <TabItem value="✅ Correct">
267
+ for `requireNullish: true`
244
268
 
245
269
  ```ts option='{ "requireNullish": true }'
246
270
  declare const thing1: string | null;
@@ -250,7 +274,8 @@ declare const thing2: string;
250
274
  thing2 && thing2.toString();
251
275
  ```
252
276
 
253
- <!--/tabs-->
277
+ </TabItem>
278
+ </Tabs>
254
279
 
255
280
  ## When Not To Use It
256
281
 
@@ -2,6 +2,9 @@
2
2
  description: 'Require using Error objects as Promise rejection reasons.'
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/prefer-promise-reject-errors** for documentation.
@@ -11,9 +14,8 @@ It uses type information to enforce that `Promise`s are only rejected with `Erro
11
14
 
12
15
  ## Examples
13
16
 
14
- <!--tabs-->
15
-
16
- ### ❌ Incorrect
17
+ <Tabs>
18
+ <TabItem value="❌ Incorrect">
17
19
 
18
20
  ```ts
19
21
  Promise.reject('error');
@@ -29,7 +31,8 @@ new Promise((resolve, reject) => {
29
31
  });
30
32
  ```
31
33
 
32
- ### ✅ Correct
34
+ </TabItem>
35
+ <TabItem value="✅ Correct">
33
36
 
34
37
  ```ts
35
38
  Promise.reject(new Error());
@@ -48,3 +51,6 @@ new Promise((resolve, reject) => {
48
51
  return reject(new CustomError());
49
52
  });
50
53
  ```
54
+
55
+ </TabItem>
56
+ </Tabs>
@@ -2,6 +2,9 @@
2
2
  description: 'Require function parameters to be typed as `readonly` to prevent accidental mutation of inputs.'
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/prefer-readonly-parameter-types** for documentation.
@@ -21,9 +24,8 @@ A type is considered readonly if:
21
24
 
22
25
  ## Examples
23
26
 
24
- <!--tabs-->
25
-
26
- ### ❌ Incorrect
27
+ <Tabs>
28
+ <TabItem value="❌ Incorrect">
27
29
 
28
30
  ```ts
29
31
  function array1(arg: string[]) {} // array is not readonly
@@ -65,7 +67,8 @@ interface Foo {
65
67
  }
66
68
  ```
67
69
 
68
- ### ✅ Correct
70
+ </TabItem>
71
+ <TabItem value="✅ Correct">
69
72
 
70
73
  ```ts
71
74
  function array1(arg: readonly string[]) {}
@@ -130,6 +133,9 @@ interface Foo {
130
133
  }
131
134
  ```
132
135
 
136
+ </TabItem>
137
+ </Tabs>
138
+
133
139
  ## Options
134
140
 
135
141
  ### `allow`
@@ -157,9 +163,8 @@ Examples of code for this rule with:
157
163
  }
158
164
  ```
159
165
 
160
- <!--tabs-->
161
-
162
- #### ❌ Incorrect
166
+ <Tabs>
167
+ <TabItem value="❌ Incorrect">
163
168
 
164
169
  ```ts option='{"allow":["$",{"from":"file","name":"Foo"},{"from":"lib","name":"HTMLElement"},{"from":"package","name":"Bar","package":"bar-lib"}]}'
165
170
  interface ThisIsMutable {
@@ -203,7 +208,8 @@ function fn2(arg: HTMLElement) {}
203
208
  function fn3(arg: Bar) {}
204
209
  ```
205
210
 
206
- #### ✅ Correct
211
+ </TabItem>
212
+ <TabItem value="✅ Correct">
207
213
 
208
214
  ```ts option='{"allow":["$",{"from":"file","name":"Foo"},{"from":"lib","name":"HTMLElement"},{"from":"package","name":"Bar","package":"bar-lib"}]}'
209
215
  interface Foo {
@@ -246,6 +252,9 @@ import { Foo } from './foo';
246
252
  function fn(arg: Foo) {}
247
253
  ```
248
254
 
255
+ </TabItem>
256
+ </Tabs>
257
+
249
258
  ### `checkParameterProperties`
250
259
 
251
260
  This option allows you to enable or disable the checking of parameter properties.
@@ -253,9 +262,8 @@ Because parameter properties create properties on the class, it may be undesirab
253
262
 
254
263
  Examples of code for this rule with `{checkParameterProperties: true}`:
255
264
 
256
- <!--tabs-->
257
-
258
- #### ❌ Incorrect
265
+ <Tabs>
266
+ <TabItem value="❌ Incorrect">
259
267
 
260
268
  ```ts option='{ "checkParameterProperties": true }'
261
269
  class Foo {
@@ -263,7 +271,8 @@ class Foo {
263
271
  }
264
272
  ```
265
273
 
266
- #### ✅ Correct
274
+ </TabItem>
275
+ <TabItem value="✅ Correct">
267
276
 
268
277
  ```ts option='{ "checkParameterProperties": true }'
269
278
  class Foo {
@@ -271,7 +280,8 @@ class Foo {
271
280
  }
272
281
  ```
273
282
 
274
- <!--/tabs-->
283
+ </TabItem>
284
+ </Tabs>
275
285
 
276
286
  Examples of **correct** code for this rule with `{checkParameterProperties: false}`:
277
287
 
@@ -290,9 +300,8 @@ This option allows you to ignore parameters which don't explicitly specify a typ
290
300
 
291
301
  Examples of code for this rule with `{ignoreInferredTypes: true}`:
292
302
 
293
- <!--tabs-->
294
-
295
- #### ❌ Incorrect
303
+ <Tabs>
304
+ <TabItem value="❌ Incorrect">
296
305
 
297
306
  ```ts option='{ "ignoreInferredTypes": true }'
298
307
  import { acceptsCallback, CallbackOptions } from 'external-dependency';
@@ -315,7 +324,8 @@ export const acceptsCallback: AcceptsCallback;
315
324
 
316
325
  </details>
317
326
 
318
- #### ✅ Correct
327
+ </TabItem>
328
+ <TabItem value="✅ Correct">
319
329
 
320
330
  ```ts option='{ "ignoreInferredTypes": true }'
321
331
  import { acceptsCallback } from 'external-dependency';
@@ -338,15 +348,17 @@ export const acceptsCallback: AcceptsCallback;
338
348
 
339
349
  </details>
340
350
 
351
+ </TabItem>
352
+ </Tabs>
353
+
341
354
  ### `treatMethodsAsReadonly`
342
355
 
343
356
  This option allows you to treat all mutable methods as though they were readonly. This may be desirable when you are never reassigning methods.
344
357
 
345
358
  Examples of code for this rule with `{treatMethodsAsReadonly: false}`:
346
359
 
347
- <!--tabs-->
348
-
349
- #### ❌ Incorrect
360
+ <Tabs>
361
+ <TabItem value="❌ Incorrect">
350
362
 
351
363
  ```ts option='{ "treatMethodsAsReadonly": false }'
352
364
  type MyType = {
@@ -356,7 +368,8 @@ type MyType = {
356
368
  function foo(arg: MyType) {}
357
369
  ```
358
370
 
359
- #### ✅ Correct
371
+ </TabItem>
372
+ <TabItem value="✅ Correct">
360
373
 
361
374
  ```ts option='{ "treatMethodsAsReadonly": false }'
362
375
  type MyType = Readonly<{
@@ -372,7 +385,8 @@ type MyOtherType = {
372
385
  function bar(arg: MyOtherType) {}
373
386
  ```
374
387
 
375
- <!--/tabs-->
388
+ </TabItem>
389
+ </Tabs>
376
390
 
377
391
  Examples of **correct** code for this rule with `{treatMethodsAsReadonly: true}`:
378
392
 
@@ -2,6 +2,9 @@
2
2
  description: "Require private members to be marked as `readonly` if they're never modified outside of the 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/prefer-readonly** for documentation.
@@ -13,9 +16,8 @@ This rule reports on private members are marked as `readonly` if they're never m
13
16
 
14
17
  ## Examples
15
18
 
16
- <!--tabs-->
17
-
18
- ### ❌ Incorrect
19
+ <Tabs>
20
+ <TabItem value="❌ Incorrect">
19
21
 
20
22
  ```ts
21
23
  class Container {
@@ -34,7 +36,8 @@ class Container {
34
36
  }
35
37
  ```
36
38
 
37
- ### ✅ Correct
39
+ </TabItem>
40
+ <TabItem value="✅ Correct">
38
41
 
39
42
  ```ts
40
43
  class Container {
@@ -60,6 +63,9 @@ class Container {
60
63
  }
61
64
  ```
62
65
 
66
+ </TabItem>
67
+ </Tabs>
68
+
63
69
  ## Options
64
70
 
65
71
  ### `onlyInlineLambdas`
@@ -77,9 +83,8 @@ You may pass `"onlyInlineLambdas": true` as a rule option within an object to re
77
83
 
78
84
  Example of code for the `{ "onlyInlineLambdas": true }` options:
79
85
 
80
- <!--tabs-->
81
-
82
- #### ❌ Incorrect
86
+ <Tabs>
87
+ <TabItem value="❌ Incorrect">
83
88
 
84
89
  ```ts option='{ "onlyInlineLambdas": true }'
85
90
  class Container {
@@ -89,7 +94,8 @@ class Container {
89
94
  }
90
95
  ```
91
96
 
92
- #### ✅ Correct
97
+ </TabItem>
98
+ <TabItem value="✅ Correct">
93
99
 
94
100
  ```ts option='{ "onlyInlineLambdas": true }'
95
101
  class Container {
@@ -97,6 +103,9 @@ class Container {
97
103
  }
98
104
  ```
99
105
 
106
+ </TabItem>
107
+ </Tabs>
108
+
100
109
  ## When Not To Use It
101
110
 
102
111
  If you aren't trying to enforce strong immutability guarantees, this rule may be too restrictive for your project.
@@ -2,6 +2,9 @@
2
2
  description: 'Enforce using type parameter when calling `Array#reduce` instead of casting.'
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/prefer-reduce-type-parameter** for documentation.
@@ -23,9 +26,8 @@ It will suggest instead pass the asserted type to `Array#reduce` as a generic ty
23
26
 
24
27
  ## Examples
25
28
 
26
- <!--tabs-->
27
-
28
- ### ❌ Incorrect
29
+ <Tabs>
30
+ <TabItem value="❌ Incorrect">
29
31
 
30
32
  ```ts
31
33
  [1, 2, 3].reduce((arr, num) => arr.concat(num * 2), [] as number[]);
@@ -39,7 +41,8 @@ It will suggest instead pass the asserted type to `Array#reduce` as a generic ty
39
41
  );
40
42
  ```
41
43
 
42
- ### ✅ Correct
44
+ </TabItem>
45
+ <TabItem value="✅ Correct">
43
46
 
44
47
  ```ts
45
48
  [1, 2, 3].reduce<number[]>((arr, num) => arr.concat(num * 2), []);
@@ -53,6 +56,9 @@ It will suggest instead pass the asserted type to `Array#reduce` as a generic ty
53
56
  );
54
57
  ```
55
58
 
59
+ </TabItem>
60
+ </Tabs>
61
+
56
62
  ## When Not To Use It
57
63
 
58
64
  This rule can sometimes be difficult to work around when creating objects using a `.reduce`.
@@ -2,6 +2,9 @@
2
2
  description: 'Enforce `RegExp#exec` over `String#match` if no global flag is provided.'
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/prefer-regexp-exec** for documentation.
@@ -15,9 +18,8 @@ This rule reports when a `String#match` call can be replaced with an equivalent
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
  'something'.match(/thing/);
@@ -29,7 +31,8 @@ const search = /thing/;
29
31
  text.match(search);
30
32
  ```
31
33
 
32
- ### ✅ Correct
34
+ </TabItem>
35
+ <TabItem value="✅ Correct">
33
36
 
34
37
  ```ts
35
38
  /thing/.exec('something');
@@ -41,6 +44,9 @@ const search = /thing/;
41
44
  search.exec(text);
42
45
  ```
43
46
 
47
+ </TabItem>
48
+ </Tabs>
49
+
44
50
  ## When Not To Use It
45
51
 
46
52
  If you prefer consistent use of `String#match` for both with `g` flag and without it, you can turn this rule off.
@@ -2,6 +2,9 @@
2
2
  description: 'Enforce that `this` is used when only `this` type is returned.'
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/prefer-return-this-type** for documentation.
@@ -38,9 +41,8 @@ cat.eat().meow();
38
41
 
39
42
  ## Examples
40
43
 
41
- <!--tabs-->
42
-
43
- ### ❌ Incorrect
44
+ <Tabs>
45
+ <TabItem value="❌ Incorrect">
44
46
 
45
47
  ```ts
46
48
  class Foo {
@@ -56,7 +58,8 @@ class Foo {
56
58
  }
57
59
  ```
58
60
 
59
- ### ✅ Correct
61
+ </TabItem>
62
+ <TabItem value="✅ Correct">
60
63
 
61
64
  ```ts
62
65
  class Foo {
@@ -82,6 +85,9 @@ class Derived extends Base {
82
85
  }
83
86
  ```
84
87
 
88
+ </TabItem>
89
+ </Tabs>
90
+
85
91
  ## When Not To Use It
86
92
 
87
93
  If you don't use method chaining or explicit return values, you can safely turn this rule off.