@typescript-eslint/eslint-plugin 7.2.1-alpha.2 → 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 (179) 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/index.js +2 -0
  14. package/dist/rules/index.js.map +1 -1
  15. package/dist/rules/no-floating-promises.js +4 -1
  16. package/dist/rules/no-floating-promises.js.map +1 -1
  17. package/dist/rules/no-misused-promises.js +1 -1
  18. package/dist/rules/no-misused-promises.js.map +1 -1
  19. package/dist/rules/no-unnecessary-qualifier.js +1 -1
  20. package/dist/rules/no-unnecessary-qualifier.js.map +1 -1
  21. package/dist/rules/no-unsafe-argument.js +1 -25
  22. package/dist/rules/no-unsafe-argument.js.map +1 -1
  23. package/dist/rules/no-unused-expressions.js +6 -2
  24. package/dist/rules/no-unused-expressions.js.map +1 -1
  25. package/dist/rules/restrict-plus-operands.js +12 -1
  26. package/dist/rules/restrict-plus-operands.js.map +1 -1
  27. package/dist/rules/restrict-template-expressions.js +13 -1
  28. package/dist/rules/restrict-template-expressions.js.map +1 -1
  29. package/dist/rules/use-unknown-in-catch-callback-variable.js +283 -0
  30. package/dist/rules/use-unknown-in-catch-callback-variable.js.map +1 -0
  31. package/dist/util/misc.js +10 -1
  32. package/dist/util/misc.js.map +1 -1
  33. package/docs/rules/TEMPLATE.md +10 -4
  34. package/docs/rules/{adjacent-overload-signatures.md → adjacent-overload-signatures.mdx} +11 -5
  35. package/docs/rules/{array-type.md → array-type.mdx} +24 -12
  36. package/docs/rules/{await-thenable.md → await-thenable.mdx} +10 -4
  37. package/docs/rules/{ban-ts-comment.md → ban-ts-comment.mdx} +32 -18
  38. package/docs/rules/{ban-tslint-comment.md → ban-tslint-comment.mdx} +10 -4
  39. package/docs/rules/{ban-types.md → ban-types.mdx} +11 -5
  40. package/docs/rules/{block-spacing.md → block-spacing.mdx} +3 -0
  41. package/docs/rules/{brace-style.md → brace-style.mdx} +3 -0
  42. package/docs/rules/camelcase.md +3 -5
  43. package/docs/rules/{class-literal-property-style.md → class-literal-property-style.mdx} +18 -11
  44. package/docs/rules/{class-methods-use-this.md → class-methods-use-this.mdx} +12 -6
  45. package/docs/rules/{comma-dangle.md → comma-dangle.mdx} +3 -0
  46. package/docs/rules/{comma-spacing.md → comma-spacing.mdx} +3 -0
  47. package/docs/rules/{consistent-generic-constructors.md → consistent-generic-constructors.mdx} +17 -8
  48. package/docs/rules/{consistent-indexed-object-style.md → consistent-indexed-object-style.mdx} +17 -8
  49. package/docs/rules/{consistent-return.md → consistent-return.mdx} +10 -4
  50. package/docs/rules/{consistent-type-assertions.md → consistent-type-assertions.mdx} +15 -10
  51. package/docs/rules/{consistent-type-definitions.md → consistent-type-definitions.mdx} +17 -8
  52. package/docs/rules/{consistent-type-exports.md → consistent-type-exports.mdx} +17 -8
  53. package/docs/rules/{consistent-type-imports.md → consistent-type-imports.mdx} +13 -8
  54. package/docs/rules/{default-param-last.md → default-param-last.mdx} +10 -4
  55. package/docs/rules/{dot-notation.md → dot-notation.mdx} +3 -0
  56. package/docs/rules/{explicit-function-return-type.md → explicit-function-return-type.mdx} +59 -32
  57. package/docs/rules/{explicit-member-accessibility.md → explicit-member-accessibility.mdx} +3 -0
  58. package/docs/rules/{explicit-module-boundary-types.md → explicit-module-boundary-types.mdx} +39 -21
  59. package/docs/rules/{func-call-spacing.md → func-call-spacing.mdx} +3 -0
  60. package/docs/rules/{indent.md → indent.mdx} +3 -0
  61. package/docs/rules/{init-declarations.md → init-declarations.mdx} +3 -0
  62. package/docs/rules/{key-spacing.md → key-spacing.mdx} +3 -0
  63. package/docs/rules/{keyword-spacing.md → keyword-spacing.mdx} +3 -0
  64. package/docs/rules/{lines-around-comment.md → lines-around-comment.mdx} +3 -0
  65. package/docs/rules/{lines-between-class-members.md → lines-between-class-members.mdx} +3 -0
  66. package/docs/rules/{max-params.md → max-params.mdx} +3 -0
  67. package/docs/rules/{member-delimiter-style.md → member-delimiter-style.mdx} +13 -7
  68. package/docs/rules/{member-ordering.md → member-ordering.mdx} +92 -56
  69. package/docs/rules/{method-signature-style.md → method-signature-style.mdx} +17 -8
  70. package/docs/rules/{naming-convention.md → naming-convention.mdx} +3 -0
  71. package/docs/rules/{no-array-constructor.md → no-array-constructor.mdx} +10 -4
  72. package/docs/rules/{no-array-delete.md → no-array-delete.mdx} +9 -5
  73. package/docs/rules/{no-base-to-string.md → no-base-to-string.mdx} +12 -6
  74. package/docs/rules/{no-confusing-non-null-assertion.md → no-confusing-non-null-assertion.mdx} +11 -5
  75. package/docs/rules/{no-confusing-void-expression.md → no-confusing-void-expression.mdx} +10 -4
  76. package/docs/rules/{no-dupe-class-members.md → no-dupe-class-members.mdx} +4 -1
  77. package/docs/rules/{no-duplicate-enum-values.md → no-duplicate-enum-values.mdx} +10 -4
  78. package/docs/rules/{no-duplicate-imports.md → no-duplicate-imports.mdx} +1 -1
  79. package/docs/rules/{no-duplicate-type-constituents.md → no-duplicate-type-constituents.mdx} +10 -4
  80. package/docs/rules/{no-dynamic-delete.md → no-dynamic-delete.mdx} +10 -4
  81. package/docs/rules/{no-empty-function.md → no-empty-function.mdx} +3 -0
  82. package/docs/rules/{no-empty-interface.md → no-empty-interface.mdx} +9 -5
  83. package/docs/rules/{no-explicit-any.md → no-explicit-any.mdx} +15 -9
  84. package/docs/rules/{no-extra-non-null-assertion.md → no-extra-non-null-assertion.mdx} +11 -5
  85. package/docs/rules/{no-extra-parens.md → no-extra-parens.mdx} +3 -0
  86. package/docs/rules/{no-extra-semi.md → no-extra-semi.mdx} +3 -0
  87. package/docs/rules/{no-extraneous-class.md → no-extraneous-class.mdx} +61 -33
  88. package/docs/rules/{no-floating-promises.md → no-floating-promises.mdx} +12 -6
  89. package/docs/rules/{no-for-in-array.md → no-for-in-array.mdx} +10 -4
  90. package/docs/rules/{no-implied-eval.md → no-implied-eval.mdx} +10 -4
  91. package/docs/rules/{no-import-type-side-effects.md → no-import-type-side-effects.mdx} +12 -6
  92. package/docs/rules/{no-inferrable-types.md → no-inferrable-types.mdx} +9 -5
  93. package/docs/rules/{no-invalid-this.md → no-invalid-this.mdx} +4 -1
  94. package/docs/rules/{no-invalid-void-type.md → no-invalid-void-type.mdx} +10 -4
  95. package/docs/rules/{no-loop-func.md → no-loop-func.mdx} +3 -0
  96. package/docs/rules/{no-loss-of-precision.md → no-loss-of-precision.mdx} +3 -0
  97. package/docs/rules/{no-magic-numbers.md → no-magic-numbers.mdx} +3 -0
  98. package/docs/rules/{no-meaningless-void-operator.md → no-meaningless-void-operator.mdx} +12 -4
  99. package/docs/rules/{no-misused-new.md → no-misused-new.mdx} +10 -4
  100. package/docs/rules/{no-misused-promises.md → no-misused-promises.mdx} +24 -16
  101. package/docs/rules/{no-mixed-enums.md → no-mixed-enums.mdx} +14 -6
  102. package/docs/rules/{no-namespace.md → no-namespace.mdx} +29 -18
  103. package/docs/rules/{no-non-null-asserted-nullish-coalescing.md → no-non-null-asserted-nullish-coalescing.mdx} +10 -4
  104. package/docs/rules/{no-non-null-asserted-optional-chain.md → no-non-null-asserted-optional-chain.mdx} +10 -4
  105. package/docs/rules/{no-non-null-assertion.md → no-non-null-assertion.mdx} +10 -4
  106. package/docs/rules/{no-redeclare.md → no-redeclare.mdx} +4 -1
  107. package/docs/rules/{no-redundant-type-constituents.md → no-redundant-type-constituents.mdx} +10 -4
  108. package/docs/rules/{no-require-imports.md → no-require-imports.mdx} +18 -9
  109. package/docs/rules/{no-restricted-imports.md → no-restricted-imports.mdx} +10 -4
  110. package/docs/rules/{no-shadow.md → no-shadow.mdx} +4 -1
  111. package/docs/rules/{no-this-alias.md → no-this-alias.mdx} +24 -12
  112. package/docs/rules/{no-throw-literal.md → no-throw-literal.mdx} +11 -5
  113. package/docs/rules/{no-type-alias.md → no-type-alias.mdx} +5 -2
  114. package/docs/rules/{no-unnecessary-boolean-literal-compare.md → no-unnecessary-boolean-literal-compare.mdx} +24 -12
  115. package/docs/rules/{no-unnecessary-condition.md → no-unnecessary-condition.mdx} +11 -5
  116. package/docs/rules/{no-unnecessary-qualifier.md → no-unnecessary-qualifier.mdx} +10 -4
  117. package/docs/rules/{no-unnecessary-type-arguments.md → no-unnecessary-type-arguments.mdx} +10 -4
  118. package/docs/rules/{no-unnecessary-type-assertion.md → no-unnecessary-type-assertion.mdx} +10 -4
  119. package/docs/rules/{no-unnecessary-type-constraint.md → no-unnecessary-type-constraint.mdx} +10 -4
  120. package/docs/rules/{no-unsafe-argument.md → no-unsafe-argument.mdx} +14 -10
  121. package/docs/rules/{no-unsafe-assignment.md → no-unsafe-assignment.mdx} +14 -10
  122. package/docs/rules/{no-unsafe-call.md → no-unsafe-call.mdx} +15 -9
  123. package/docs/rules/{no-unsafe-declaration-merging.md → no-unsafe-declaration-merging.mdx} +10 -4
  124. package/docs/rules/{no-unsafe-enum-comparison.md → no-unsafe-enum-comparison.mdx} +9 -5
  125. package/docs/rules/{no-unsafe-member-access.md → no-unsafe-member-access.mdx} +15 -9
  126. package/docs/rules/{no-unsafe-return.md → no-unsafe-return.mdx} +14 -10
  127. package/docs/rules/{no-unsafe-unary-minus.md → no-unsafe-unary-minus.mdx} +11 -5
  128. package/docs/rules/{no-unused-expressions.md → no-unused-expressions.mdx} +3 -0
  129. package/docs/rules/{no-unused-vars.md → no-unused-vars.mdx} +3 -0
  130. package/docs/rules/{no-use-before-define.md → no-use-before-define.mdx} +10 -4
  131. package/docs/rules/{no-useless-constructor.md → no-useless-constructor.mdx} +3 -0
  132. package/docs/rules/{no-useless-empty-export.md → no-useless-empty-export.mdx} +10 -4
  133. package/docs/rules/{no-useless-template-literals.md → no-useless-template-literals.mdx} +10 -6
  134. package/docs/rules/{no-var-requires.md → no-var-requires.mdx} +18 -9
  135. package/docs/rules/{non-nullable-type-assertion-style.md → non-nullable-type-assertion-style.mdx} +10 -4
  136. package/docs/rules/{object-curly-spacing.md → object-curly-spacing.mdx} +3 -0
  137. package/docs/rules/{padding-line-between-statements.md → padding-line-between-statements.mdx} +3 -0
  138. package/docs/rules/{parameter-properties.md → parameter-properties.mdx} +66 -36
  139. package/docs/rules/{prefer-as-const.md → prefer-as-const.mdx} +9 -5
  140. package/docs/rules/{prefer-destructuring.md → prefer-destructuring.mdx} +23 -12
  141. package/docs/rules/{prefer-enum-initializers.md → prefer-enum-initializers.mdx} +10 -4
  142. package/docs/rules/{prefer-find.md → prefer-find.mdx} +10 -4
  143. package/docs/rules/{prefer-for-of.md → prefer-for-of.mdx} +11 -5
  144. package/docs/rules/{prefer-function-type.md → prefer-function-type.mdx} +10 -4
  145. package/docs/rules/{prefer-includes.md → prefer-includes.mdx} +11 -5
  146. package/docs/rules/{prefer-literal-enum-member.md → prefer-literal-enum-member.mdx} +16 -9
  147. package/docs/rules/{prefer-namespace-keyword.md → prefer-namespace-keyword.mdx} +9 -5
  148. package/docs/rules/{prefer-nullish-coalescing.md → prefer-nullish-coalescing.mdx} +3 -0
  149. package/docs/rules/{prefer-optional-chain.md → prefer-optional-chain.mdx} +58 -33
  150. package/docs/rules/{prefer-promise-reject-errors.md → prefer-promise-reject-errors.mdx} +10 -4
  151. package/docs/rules/{prefer-readonly-parameter-types.md → prefer-readonly-parameter-types.mdx} +36 -22
  152. package/docs/rules/{prefer-readonly.md → prefer-readonly.mdx} +17 -8
  153. package/docs/rules/{prefer-reduce-type-parameter.md → prefer-reduce-type-parameter.mdx} +10 -4
  154. package/docs/rules/{prefer-regexp-exec.md → prefer-regexp-exec.mdx} +10 -4
  155. package/docs/rules/{prefer-return-this-type.md → prefer-return-this-type.mdx} +10 -4
  156. package/docs/rules/{prefer-string-starts-ends-with.md → prefer-string-starts-ends-with.mdx} +9 -5
  157. package/docs/rules/{prefer-ts-expect-error.md → prefer-ts-expect-error.mdx} +10 -4
  158. package/docs/rules/{promise-function-async.md → promise-function-async.mdx} +24 -12
  159. package/docs/rules/{quotes.md → quotes.mdx} +3 -0
  160. package/docs/rules/{require-array-sort-compare.md → require-array-sort-compare.mdx} +17 -8
  161. package/docs/rules/{require-await.md → require-await.mdx} +3 -0
  162. package/docs/rules/{restrict-plus-operands.md → restrict-plus-operands.mdx} +54 -30
  163. package/docs/rules/{restrict-template-expressions.md → restrict-template-expressions.mdx} +13 -7
  164. package/docs/rules/{return-await.md → return-await.mdx} +24 -12
  165. package/docs/rules/{semi.md → semi.mdx} +4 -1
  166. package/docs/rules/{sort-type-constituents.md → sort-type-constituents.mdx} +31 -16
  167. package/docs/rules/{space-before-blocks.md → space-before-blocks.mdx} +10 -4
  168. package/docs/rules/{space-before-function-paren.md → space-before-function-paren.mdx} +3 -0
  169. package/docs/rules/{space-infix-ops.md → space-infix-ops.mdx} +3 -0
  170. package/docs/rules/{strict-boolean-expressions.md → strict-boolean-expressions.mdx} +11 -5
  171. package/docs/rules/{switch-exhaustiveness-check.md → switch-exhaustiveness-check.mdx} +19 -14
  172. package/docs/rules/{triple-slash-reference.md → triple-slash-reference.mdx} +30 -17
  173. package/docs/rules/{type-annotation-spacing.md → type-annotation-spacing.mdx} +49 -31
  174. package/docs/rules/{typedef.md → typedef.mdx} +60 -33
  175. package/docs/rules/{unbound-method.md → unbound-method.mdx} +12 -6
  176. package/docs/rules/{unified-signatures.md → unified-signatures.mdx} +18 -9
  177. package/docs/rules/use-unknown-in-catch-callback-variable.mdx +84 -0
  178. package/package.json +7 -7
  179. /package/docs/rules/{no-parameter-properties.md → no-parameter-properties.mdx} +0 -0
@@ -2,6 +2,9 @@
2
2
  description: 'Disallow `@ts-<directive>` comments or require descriptions after directives.'
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/ban-ts-comment** for documentation.
@@ -29,9 +32,8 @@ By default, only `@ts-check` is allowed, as it enables rather than suppresses er
29
32
 
30
33
  A value of `true` for a particular directive means that this rule will report if it finds any usage of said directive.
31
34
 
32
- <!--tabs-->
33
-
34
- #### ❌ Incorrect
35
+ <Tabs>
36
+ <TabItem value="❌ Incorrect">
35
37
 
36
38
  ```ts option='{ "ts-ignore": true }'
37
39
  if (false) {
@@ -46,7 +48,8 @@ if (false) {
46
48
  }
47
49
  ```
48
50
 
49
- #### ✅ Correct
51
+ </TabItem>
52
+ <TabItem value="✅ Correct">
50
53
 
51
54
  ```ts option='{ "ts-ignore": true }'
52
55
  if (false) {
@@ -55,15 +58,17 @@ if (false) {
55
58
  }
56
59
  ```
57
60
 
61
+ </TabItem>
62
+ </Tabs>
63
+
58
64
  ### `allow-with-description`
59
65
 
60
66
  A value of `'allow-with-description'` for a particular directive means that this rule will report if it finds a directive that does not have a description following the directive (on the same line).
61
67
 
62
68
  For example, with `{ 'ts-expect-error': 'allow-with-description' }`:
63
69
 
64
- <!--tabs-->
65
-
66
- #### ❌ Incorrect
70
+ <Tabs>
71
+ <TabItem value="❌ Incorrect">
67
72
 
68
73
  ```ts option='{ "ts-expect-error": "allow-with-description" }'
69
74
  if (false) {
@@ -76,7 +81,8 @@ if (false) {
76
81
  }
77
82
  ```
78
83
 
79
- #### ✅ Correct
84
+ </TabItem>
85
+ <TabItem value="✅ Correct">
80
86
 
81
87
  ```ts option='{ "ts-expect-error": "allow-with-description" }'
82
88
  if (false) {
@@ -91,39 +97,43 @@ if (false) {
91
97
  }
92
98
  ```
93
99
 
100
+ </TabItem>
101
+ </Tabs>
94
102
  ### `descriptionFormat`
95
103
 
96
104
  For each directive type, you can specify a custom format in the form of a regular expression. Only description that matches the pattern will be allowed.
97
105
 
98
106
  For example, with `{ 'ts-expect-error': { descriptionFormat: '^: TS\\d+ because .+$' } }`:
99
107
 
100
- <!--tabs-->
108
+ <Tabs>
109
+ <TabItem value="❌ Incorrect">
101
110
 
102
- #### Incorrect
103
-
104
- <!-- prettier-ignore -->
111
+ {/* prettier-ignore */}
105
112
  ```ts option='{ "ts-expect-error": { "descriptionFormat": "^: TS\\\\d+ because .+$" } }'
106
113
  // @ts-expect-error: the library definition is wrong
107
114
  const a = doSomething('hello');
108
115
  ```
109
116
 
110
- #### ✅ Correct
117
+ </TabItem>
118
+ <TabItem value="✅ Correct">
111
119
 
112
- <!-- prettier-ignore -->
120
+ {/* prettier-ignore */}
113
121
  ```ts option='{ "ts-expect-error": { "descriptionFormat": "^: TS\\\\d+ because .+$" } }'
114
122
  // @ts-expect-error: TS1234 because the library definition is wrong
115
123
  const a = doSomething('hello');
116
124
  ```
117
125
 
126
+ </TabItem>
127
+ </Tabs>
128
+
118
129
  ### `minimumDescriptionLength`
119
130
 
120
131
  Use `minimumDescriptionLength` to set a minimum length for descriptions when using the `allow-with-description` option for a directive.
121
132
 
122
133
  For example, with `{ 'ts-expect-error': 'allow-with-description', minimumDescriptionLength: 10 }` the following pattern is:
123
134
 
124
- <!--tabs-->
125
-
126
- #### ❌ Incorrect
135
+ <Tabs>
136
+ <TabItem value="❌ Incorrect">
127
137
 
128
138
  ```ts option='{ "ts-expect-error": "allow-with-description", "minimumDescriptionLength": 10 }'
129
139
  if (false) {
@@ -132,7 +142,8 @@ if (false) {
132
142
  }
133
143
  ```
134
144
 
135
- #### ✅ Correct
145
+ </TabItem>
146
+ <TabItem value="✅ Correct">
136
147
 
137
148
  ```ts option='{ "ts-expect-error": "allow-with-description", "minimumDescriptionLength": 10 }'
138
149
  if (false) {
@@ -141,6 +152,9 @@ if (false) {
141
152
  }
142
153
  ```
143
154
 
155
+ </TabItem>
156
+ </Tabs>
157
+
144
158
  ## When Not To Use It
145
159
 
146
160
  If your project or its dependencies were not architected with strong type safety in mind, it can be difficult to always adhere to proper TypeScript semantics.
@@ -2,6 +2,9 @@
2
2
  description: 'Disallow `// tslint:<rule-flag>` comments.'
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/ban-tslint-comment** for documentation.
@@ -12,9 +15,8 @@ Useful when migrating from TSLint to ESLint. Once TSLint has been removed, this
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
  /* tslint:disable */
@@ -26,7 +28,8 @@ someCode(); // tslint:disable-line
26
28
  // tslint:disable-next-line:rule1 rule2 rule3...
27
29
  ```
28
30
 
29
- ### ✅ Correct
31
+ </TabItem>
32
+ <TabItem value="✅ Correct">
30
33
 
31
34
  ```ts
32
35
  // This is a comment that just happens to mention tslint
@@ -34,6 +37,9 @@ someCode(); // tslint:disable-line
34
37
  someCode(); // This is a comment that just happens to mention tslint
35
38
  ```
36
39
 
40
+ </TabItem>
41
+ </Tabs>
42
+
37
43
  ## When Not To Use It
38
44
 
39
45
  If you are still using TSLint alongside ESLint.
@@ -2,6 +2,9 @@
2
2
  description: 'Disallow certain 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/ban-types** for documentation.
@@ -16,9 +19,8 @@ Note that it does not ban the corresponding runtime objects from being used.
16
19
 
17
20
  Examples of code with the default options:
18
21
 
19
- <!--tabs-->
20
-
21
- ### ❌ Incorrect
22
+ <Tabs>
23
+ <TabItem value="❌ Incorrect">
22
24
 
23
25
  ```ts
24
26
  // use lower-case primitives for consistency
@@ -39,7 +41,8 @@ const curly1: {} = 1;
39
41
  const curly2: {} = { a: 'string' };
40
42
  ```
41
43
 
42
- ### ✅ Correct
44
+ </TabItem>
45
+ <TabItem value="✅ Correct">
43
46
 
44
47
  ```ts
45
48
  // use lower-case primitives for consistency
@@ -60,6 +63,9 @@ const curly1: number = 1;
60
63
  const curly2: Record<'a', string> = { a: 'string' };
61
64
  ```
62
65
 
66
+ </TabItem>
67
+ </Tabs>
68
+
63
69
  ## Options
64
70
 
65
71
  The default options provide a set of "best practices", intended to provide safety and standardization in your codebase:
@@ -75,7 +81,7 @@ The default options provide a set of "best practices", intended to provide safet
75
81
  <details>
76
82
  <summary>Default Options</summary>
77
83
 
78
- <!-- Inject default options -->
84
+ {/* Inject default options */}
79
85
 
80
86
  </details>
81
87
 
@@ -2,6 +2,9 @@
2
2
  description: 'Disallow or enforce spaces inside of blocks after opening block and before closing block.'
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/block-spacing** for documentation.
@@ -2,6 +2,9 @@
2
2
  description: 'Enforce consistent brace style for blocks.'
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/brace-style** for documentation.
@@ -1,13 +1,11 @@
1
1
  :::danger Deprecated
2
2
 
3
- This rule has been deprecated in favour of the [`naming-convention`](./naming-convention.md) rule.
3
+ This rule has been deprecated in favour of the [`naming-convention`](./naming-convention.mdx) rule.
4
4
 
5
5
  :::
6
6
 
7
- <!--
8
- This doc file has been left on purpose because `camelcase` is a core ESLint
7
+ <!-- This doc file has been left on purpose because `camelcase` is a core ESLint
9
8
  rule. This exists to help direct people to the replacement rule.
10
9
 
11
10
  Note that there is no actual way to get to this page in the normal navigation,
12
- so end-users will only be able to get to this page from the search bar.
13
- -->
11
+ so end-users will only be able to get to this page from the search bar. -->
@@ -2,6 +2,9 @@
2
2
  description: 'Enforce that literals on classes are exposed in a consistent style.'
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/class-literal-property-style** for documentation.
@@ -15,10 +18,8 @@ By default this rule prefers the `fields` style as it means JS doesn't have to s
15
18
  ## Options
16
19
 
17
20
  :::note
18
-
19
21
  This rule only checks for constant _literal_ values (string, template string, number, bigint, boolean, regexp, null). It does not check objects or arrays, because a readonly field behaves differently to a getter in those cases. It also does not check functions, as it is a common pattern to use readonly fields with arrow function values as auto-bound methods.
20
22
  This is because these types can be mutated and carry with them more complex implications about their usage.
21
-
22
23
  :::
23
24
 
24
25
  ### `"fields"`
@@ -27,9 +28,8 @@ This style checks for any getter methods that return literal values, and require
27
28
 
28
29
  Examples of code with the `fields` style:
29
30
 
30
- <!--tabs-->
31
-
32
- #### ❌ Incorrect
31
+ <Tabs>
32
+ <TabItem value="❌ Incorrect">
33
33
 
34
34
  ```ts option='"fields"'
35
35
  class Mx {
@@ -43,7 +43,8 @@ class Mx {
43
43
  }
44
44
  ```
45
45
 
46
- #### ✅ Correct
46
+ </TabItem>
47
+ <TabItem value="✅ Correct">
47
48
 
48
49
  ```ts option='"fields"'
49
50
  class Mx {
@@ -60,17 +61,19 @@ class Mx {
60
61
  }
61
62
  ```
62
63
 
64
+ </TabItem>
65
+ </Tabs>
66
+
63
67
  ### `"getters"`
64
68
 
65
69
  This style checks for any `readonly` fields that are assigned literal values, and requires them to be defined as getters instead.
66
- This style pairs well with the [`@typescript-eslint/prefer-readonly`](prefer-readonly.md) rule,
70
+ This style pairs well with the [`@typescript-eslint/prefer-readonly`](prefer-readonly.mdx) rule,
67
71
  as it will identify fields that can be `readonly`, and thus should be made into getters.
68
72
 
69
73
  Examples of code with the `getters` style:
70
74
 
71
- <!--tabs-->
72
-
73
- #### ❌ Incorrect
75
+ <Tabs>
76
+ <TabItem value="❌ Incorrect">
74
77
 
75
78
  ```ts option='"getters"'
76
79
  class Mx {
@@ -80,7 +83,8 @@ class Mx {
80
83
  }
81
84
  ```
82
85
 
83
- #### ✅ Correct
86
+ </TabItem>
87
+ <TabItem value="✅ Correct">
84
88
 
85
89
  ```ts option='"getters"'
86
90
  class Mx {
@@ -100,6 +104,9 @@ class Mx {
100
104
  }
101
105
  ```
102
106
 
107
+ </TabItem>
108
+ </Tabs>
109
+
103
110
  ## When Not To Use It
104
111
 
105
112
  When you have no strong preference, or do not wish to enforce a particular style for how literal values are exposed by your classes.
@@ -2,6 +2,9 @@
2
2
  description: 'Enforce that class methods utilize `this`.'
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/class-methods-use-this** for documentation.
@@ -51,7 +54,7 @@ It's important to note that this option does not only apply to members defined i
51
54
 
52
55
  #### `true`
53
56
 
54
- Example of a correct code when `ignoreClassesThatImplementAnInterface` is set to `true`:
57
+ Example of correct code when `ignoreClassesThatImplementAnInterface` is set to `true`:
55
58
 
56
59
  ```ts option='{ "ignoreClassesThatImplementAnInterface": true }' showPlaygroundButton
57
60
  class X implements Y {
@@ -62,11 +65,10 @@ class X implements Y {
62
65
 
63
66
  #### `'public-fields'`
64
67
 
65
- Example of a incorrect code when `ignoreClassesThatImplementAnInterface` is set to `'public-fields'`:
66
-
67
- <!--tabs-->
68
+ Example of incorrect code when `ignoreClassesThatImplementAnInterface` is set to `'public-fields'`:
68
69
 
69
- ##### ❌ Incorrect
70
+ <Tabs>
71
+ <TabItem value="❌ Incorrect">
70
72
 
71
73
  ```ts
72
74
  class X implements Y {
@@ -81,7 +83,8 @@ class X implements Y {
81
83
  }
82
84
  ```
83
85
 
84
- ##### ✅ Correct
86
+ </TabItem>
87
+ <TabItem value="✅ Correct">
85
88
 
86
89
  ```ts
87
90
  class X implements Y {
@@ -90,6 +93,9 @@ class X implements Y {
90
93
  }
91
94
  ```
92
95
 
96
+ </TabItem>
97
+ </Tabs>
98
+
93
99
  ## When Not To Use It
94
100
 
95
101
  If your project dynamically changes `this` scopes around in a way TypeScript has difficulties modeling, this rule may not be viable to use.
@@ -2,6 +2,9 @@
2
2
  description: 'Require or disallow trailing commas.'
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/comma-dangle** for documentation.
@@ -2,6 +2,9 @@
2
2
  description: 'Enforce consistent spacing before and after commas.'
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/comma-spacing** for documentation.
@@ -2,6 +2,9 @@
2
2
  description: 'Enforce specifying generic type arguments on type annotation or constructor name of a constructor call.'
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/consistent-generic-constructors** for documentation.
@@ -29,16 +32,16 @@ Keeping to one side consistently improve code readability.
29
32
 
30
33
  ### `constructor`
31
34
 
32
- <!--tabs-->
33
-
34
- #### ❌ Incorrect
35
+ <Tabs>
36
+ <TabItem value="❌ Incorrect">
35
37
 
36
38
  ```ts option='"constructor"'
37
39
  const map: Map<string, number> = new Map();
38
40
  const set: Set<string> = new Set();
39
41
  ```
40
42
 
41
- #### ✅ Correct
43
+ </TabItem>
44
+ <TabItem value="✅ Correct">
42
45
 
43
46
  ```ts option='"constructor"'
44
47
  const map = new Map<string, number>();
@@ -48,18 +51,21 @@ const set = new Set();
48
51
  const set: Set<string> = new Set<string>();
49
52
  ```
50
53
 
51
- ### `type-annotation`
54
+ </TabItem>
55
+ </Tabs>
52
56
 
53
- <!--tabs-->
57
+ ### `type-annotation`
54
58
 
55
- #### ❌ Incorrect
59
+ <Tabs>
60
+ <TabItem value="❌ Incorrect">
56
61
 
57
62
  ```ts option='"type-annotation"'
58
63
  const map = new Map<string, number>();
59
64
  const set = new Set<string>();
60
65
  ```
61
66
 
62
- #### ✅ Correct
67
+ </TabItem>
68
+ <TabItem value="✅ Correct">
63
69
 
64
70
  ```ts option='"type-annotation"'
65
71
  const map: Map<string, number> = new Map();
@@ -68,6 +74,9 @@ const set = new Set();
68
74
  const set: Set<string> = new Set<string>();
69
75
  ```
70
76
 
77
+ </TabItem>
78
+ </Tabs>
79
+
71
80
  ## When Not To Use It
72
81
 
73
82
  You can turn this rule off if you don't want to enforce one kind of generic constructor style over the other.
@@ -2,6 +2,9 @@
2
2
  description: 'Require or disallow the `Record` type.'
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/consistent-indexed-object-style** for documentation.
@@ -29,9 +32,8 @@ Keeping to one declaration form consistently improve code readability.
29
32
 
30
33
  ### `record`
31
34
 
32
- <!--tabs-->
33
-
34
- #### ❌ Incorrect
35
+ <Tabs>
36
+ <TabItem value="❌ Incorrect">
35
37
 
36
38
  ```ts option='"record"'
37
39
  interface Foo {
@@ -43,23 +45,27 @@ type Foo = {
43
45
  };
44
46
  ```
45
47
 
46
- #### ✅ Correct
48
+ </TabItem>
49
+ <TabItem value="✅ Correct">
47
50
 
48
51
  ```ts option='"record"'
49
52
  type Foo = Record<string, unknown>;
50
53
  ```
51
54
 
52
- ### `index-signature`
55
+ </TabItem>
56
+ </Tabs>
53
57
 
54
- <!--tabs-->
58
+ ### `index-signature`
55
59
 
56
- #### ❌ Incorrect
60
+ <Tabs>
61
+ <TabItem value="❌ Incorrect">
57
62
 
58
63
  ```ts option='"index-signature"'
59
64
  type Foo = Record<string, unknown>;
60
65
  ```
61
66
 
62
- #### ✅ Correct
67
+ </TabItem>
68
+ <TabItem value="✅ Correct">
63
69
 
64
70
  ```ts option='"index-signature"'
65
71
  interface Foo {
@@ -71,6 +77,9 @@ type Foo = {
71
77
  };
72
78
  ```
73
79
 
80
+ </TabItem>
81
+ </Tabs>
82
+
74
83
  ## When Not To Use It
75
84
 
76
85
  This rule is purely a stylistic rule for maintaining consistency in your project.
@@ -2,6 +2,9 @@
2
2
  description: 'Require `return` statements to either always or never specify values.'
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/consistent-return** for documentation.
@@ -9,9 +12,8 @@ description: 'Require `return` statements to either always or never specify valu
9
12
  This rule extends the base [`eslint/consistent-return`](https://eslint.org/docs/rules/consistent-return) rule.
10
13
  This version adds support for functions that return `void` or `Promise<void>`.
11
14
 
12
- <!--tabs-->
13
-
14
- ### ❌ Incorrect
15
+ <Tabs>
16
+ <TabItem value="❌ Incorrect">
15
17
 
16
18
  ```ts
17
19
  function foo(): undefined {}
@@ -26,7 +28,8 @@ async function baz(flag: boolean): Promise<undefined> {
26
28
  }
27
29
  ```
28
30
 
29
- ### ✅ Correct
31
+ </TabItem>
32
+ <TabItem value="✅ Correct">
30
33
 
31
34
  ```ts
32
35
  function foo(): void {}
@@ -40,3 +43,6 @@ async function baz(flag: boolean): Promise<void | number> {
40
43
  return;
41
44
  }
42
45
  ```
46
+
47
+ </TabItem>
48
+ </Tabs>
@@ -2,6 +2,9 @@
2
2
  description: 'Enforce consistent usage of type assertions.'
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/consistent-type-assertions** for documentation.
@@ -49,9 +52,8 @@ Assertions to `any` are also ignored by this option.
49
52
 
50
53
  Examples of code for `{ assertionStyle: 'as', objectLiteralTypeAssertions: 'never' }`:
51
54
 
52
- <!--tabs-->
53
-
54
- #### ❌ Incorrect
55
+ <Tabs>
56
+ <TabItem value="❌ Incorrect">
55
57
 
56
58
  ```ts option='{ "assertionStyle": "as", "objectLiteralTypeAssertions": "never" }'
57
59
  const x = { foo: 1 } as T;
@@ -61,7 +63,8 @@ function bar() {
61
63
  }
62
64
  ```
63
65
 
64
- #### ✅ Correct
66
+ </TabItem>
67
+ <TabItem value="✅ Correct">
65
68
 
66
69
  ```ts option='{ "assertionStyle": "as", "objectLiteralTypeAssertions": "never" }'
67
70
  const x: T = { foo: 1 };
@@ -73,13 +76,13 @@ function bar(): T {
73
76
  }
74
77
  ```
75
78
 
76
- <!--/tabs-->
79
+ </TabItem>
80
+ </Tabs>
77
81
 
78
82
  Examples of code for `{ assertionStyle: 'as', objectLiteralTypeAssertions: 'allow-as-parameter' }`:
79
83
 
80
- <!--tabs-->
81
-
82
- #### ❌ Incorrect
84
+ <Tabs>
85
+ <TabItem value="❌ Incorrect">
83
86
 
84
87
  ```ts option='{ "assertionStyle": "as", "objectLiteralTypeAssertions": "allow-as-parameter" }'
85
88
  const x = { foo: 1 } as T;
@@ -89,7 +92,8 @@ function bar() {
89
92
  }
90
93
  ```
91
94
 
92
- #### ✅ Correct
95
+ </TabItem>
96
+ <TabItem value="✅ Correct">
93
97
 
94
98
  ```tsx option='{ "assertionStyle": "as", "objectLiteralTypeAssertions": "allow-as-parameter" }'
95
99
  const x: T = { foo: 1 };
@@ -103,7 +107,8 @@ function bar() {
103
107
  const foo = <Foo props={{ bar: 1 } as Bar} />;
104
108
  ```
105
109
 
106
- <!--/tabs-->
110
+ </TabItem>
111
+ </Tabs>
107
112
 
108
113
  ## When Not To Use It
109
114