@typescript-eslint/eslint-plugin 7.2.1-alpha.2 → 7.2.1-alpha.4

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: 'Enforce type definitions to consistently use either `interface` or `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-type-definitions** for documentation.
@@ -32,15 +35,15 @@ Using the same type declaration style consistently helps with code readability.
32
35
 
33
36
  ### `interface`
34
37
 
35
- <!--tabs-->
36
-
37
- #### ❌ Incorrect
38
+ <Tabs>
39
+ <TabItem value="❌ Incorrect">
38
40
 
39
41
  ```ts option='"interface"'
40
42
  type T = { x: number };
41
43
  ```
42
44
 
43
- #### ✅ Correct
45
+ </TabItem>
46
+ <TabItem value="✅ Correct">
44
47
 
45
48
  ```ts option='"interface"'
46
49
  type T = string;
@@ -51,11 +54,13 @@ interface T {
51
54
  }
52
55
  ```
53
56
 
54
- ### `type`
57
+ </TabItem>
58
+ </Tabs>
55
59
 
56
- <!--tabs-->
60
+ ### `type`
57
61
 
58
- #### ❌ Incorrect
62
+ <Tabs>
63
+ <TabItem value="❌ Incorrect">
59
64
 
60
65
  ```ts option='"type"'
61
66
  interface T {
@@ -63,12 +68,16 @@ interface T {
63
68
  }
64
69
  ```
65
70
 
66
- #### ✅ Correct
71
+ </TabItem>
72
+ <TabItem value="✅ Correct">
67
73
 
68
74
  ```ts option='"type"'
69
75
  type T = { x: number };
70
76
  ```
71
77
 
78
+ </TabItem>
79
+ </Tabs>
80
+
72
81
  ## When Not To Use It
73
82
 
74
83
  If you specifically want to use an interface or type literal for stylistic reasons, you can avoid this rule.
@@ -2,6 +2,9 @@
2
2
  description: 'Enforce consistent usage of type exports.'
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-exports** for documentation.
@@ -13,9 +16,8 @@ This allows transpilers to drop exports without knowing the types of the depende
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
  interface ButtonProps {
@@ -29,7 +31,8 @@ class Button implements ButtonProps {
29
31
  export { Button, ButtonProps };
30
32
  ```
31
33
 
32
- ### ✅ Correct
34
+ </TabItem>
35
+ <TabItem value="✅ Correct">
33
36
 
34
37
  ```ts
35
38
  interface ButtonProps {
@@ -44,6 +47,9 @@ export { Button };
44
47
  export type { ButtonProps };
45
48
  ```
46
49
 
50
+ </TabItem>
51
+ </Tabs>
52
+
47
53
  ## Options
48
54
 
49
55
  ### `fixMixedExportsWithInlineTypeSpecifier`
@@ -79,21 +85,24 @@ export type { T };
79
85
  export { x };
80
86
  ```
81
87
 
82
- <!--tabs-->
83
-
84
- ### ❌ Incorrect
88
+ <Tabs>
89
+ <TabItem value="❌ Incorrect">
85
90
 
86
91
  ```ts option='{ "fixMixedExportsWithInlineTypeSpecifier": true }'
87
92
  export { Button } from 'some-library';
88
93
  export type { ButtonProps } from 'some-library';
89
94
  ```
90
95
 
91
- ### ✅ Correct
96
+ </TabItem>
97
+ <TabItem value="✅ Correct">
92
98
 
93
99
  ```ts option='{ "fixMixedExportsWithInlineTypeSpecifier": true }'
94
100
  export { Button, type ButtonProps } from 'some-library';
95
101
  ```
96
102
 
103
+ </TabItem>
104
+ </Tabs>
105
+
97
106
  ## When Not To Use It
98
107
 
99
108
  If you use `--isolatedModules` the compiler would error if a type is not re-exported using `export type`.
@@ -2,6 +2,9 @@
2
2
  description: 'Enforce consistent usage of type imports.'
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-imports** for documentation.
@@ -45,9 +48,8 @@ This option defines the expected type modifier to be added when an import is det
45
48
  - `separate-type-imports` will add the type keyword after the import keyword `import type { A } from '...'`. It is the default.
46
49
  - `inline-type-imports` will inline the type keyword `import { type A } from '...'` and is only available in TypeScript 4.5 and onwards. See [documentation here](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-5.html#type-modifiers-on-import-names 'TypeScript 4.5 documentation on type modifiers and import names').
47
50
 
48
- <!--tabs-->
49
-
50
- #### ❌ Incorrect
51
+ <Tabs>
52
+ <TabItem value="❌ Incorrect">
51
53
 
52
54
  ```ts
53
55
  import { Foo } from 'Foo';
@@ -56,7 +58,8 @@ type T = Foo;
56
58
  const x: Bar = 1;
57
59
  ```
58
60
 
59
- #### ✅ With `separate-type-imports`
61
+ </TabItem>
62
+ <TabItem value="✅ With `separate-type-imports`">
60
63
 
61
64
  ```ts option='{ "fixStyle": "separate-type-imports" }'
62
65
  import type { Foo } from 'Foo';
@@ -65,7 +68,8 @@ type T = Foo;
65
68
  const x: Bar = 1;
66
69
  ```
67
70
 
68
- #### ✅ With `inline-type-imports`
71
+ </TabItem>
72
+ <TabItem value="✅ With `inline-type-imports`">
69
73
 
70
74
  ```ts option='{ "fixStyle": "inline-type-imports" }'
71
75
  import { type Foo } from 'Foo';
@@ -74,7 +78,8 @@ type T = Foo;
74
78
  const x: Bar = 1;
75
79
  ```
76
80
 
77
- <!--tabs-->
81
+ </TabItem>
82
+ </Tabs>
78
83
 
79
84
  ### `disallowTypeAnnotations`
80
85
 
@@ -103,6 +108,6 @@ We recommend picking a single option for this rule that works best for your proj
103
108
 
104
109
  ## Related To
105
110
 
106
- - [`no-import-type-side-effects`](./no-import-type-side-effects.md)
107
- - [`import/consistent-type-specifier-style`](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/consistent-type-specifier-style.md)
111
+ - [`no-import-type-side-effects`](./no-import-type-side-effects.mdx)
112
+ - [`import/consistent-type-specifier-style`](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/consistent-type-specifier-style.mdx)
108
113
  - [`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: 'Enforce default parameters to be last.'
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/default-param-last** for documentation.
@@ -9,9 +12,8 @@ description: 'Enforce default parameters to be last.'
9
12
  This rule extends the base [`eslint/default-param-last`](https://eslint.org/docs/rules/default-param-last) rule.
10
13
  It adds support for optional parameters.
11
14
 
12
- <!--tabs-->
13
-
14
- ### ❌ Incorrect
15
+ <Tabs>
16
+ <TabItem value="❌ Incorrect">
15
17
 
16
18
  ```ts
17
19
  /* eslint @typescript-eslint/default-param-last: "error" */
@@ -33,7 +35,8 @@ class Foo {
33
35
  }
34
36
  ```
35
37
 
36
- ### ✅ Correct
38
+ </TabItem>
39
+ <TabItem value="✅ Correct">
37
40
 
38
41
  ```ts
39
42
  /* eslint @typescript-eslint/default-param-last: "error" */
@@ -56,3 +59,6 @@ class Foo {
56
59
  ) {}
57
60
  }
58
61
  ```
62
+
63
+ </TabItem>
64
+ </Tabs>
@@ -2,6 +2,9 @@
2
2
  description: 'Enforce dot notation whenever possible.'
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/dot-notation** for documentation.
@@ -2,6 +2,9 @@
2
2
  description: 'Require explicit return types on functions and class 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/explicit-function-return-type** for documentation.
@@ -16,9 +19,8 @@ This rule enforces that functions do have an explicit return type annotation.
16
19
 
17
20
  ## Examples
18
21
 
19
- <!--tabs-->
20
-
21
- ### ❌ Incorrect
22
+ <Tabs>
23
+ <TabItem value="❌ Incorrect">
22
24
 
23
25
  ```ts
24
26
  // Should indicate that no value is returned (void)
@@ -42,7 +44,8 @@ class Test {
42
44
  }
43
45
  ```
44
46
 
45
- ### ✅ Correct
47
+ </TabItem>
48
+ <TabItem value="✅ Correct">
46
49
 
47
50
  ```ts
48
51
  // No return value should be expected (void)
@@ -66,6 +69,9 @@ class Test {
66
69
  }
67
70
  ```
68
71
 
72
+ </TabItem>
73
+ </Tabs>
74
+
69
75
  ## Options
70
76
 
71
77
  ### Configuring in a mixed JS/TS codebase
@@ -94,9 +100,8 @@ If you are working on a codebase within which you lint non-TypeScript code (i.e.
94
100
 
95
101
  Examples of code for this rule with `{ allowExpressions: true }`:
96
102
 
97
- <!--tabs-->
98
-
99
- #### ❌ Incorrect
103
+ <Tabs>
104
+ <TabItem value="❌ Incorrect">
100
105
 
101
106
  ```ts option='{ "allowExpressions": true }'
102
107
  function test() {}
@@ -106,7 +111,8 @@ const fn = () => {};
106
111
  export default () => {};
107
112
  ```
108
113
 
109
- #### ✅ Correct
114
+ </TabItem>
115
+ <TabItem value="✅ Correct">
110
116
 
111
117
  ```ts option='{ "allowExpressions": true }'
112
118
  node.addEventListener('click', () => {});
@@ -116,13 +122,15 @@ node.addEventListener('click', function () {});
116
122
  const foo = arr.map(i => i * i);
117
123
  ```
118
124
 
125
+ </TabItem>
126
+ </Tabs>
127
+
119
128
  ### `allowTypedFunctionExpressions`
120
129
 
121
130
  Examples of code for this rule with `{ allowTypedFunctionExpressions: true }`:
122
131
 
123
- <!--tabs-->
124
-
125
- #### ❌ Incorrect
132
+ <Tabs>
133
+ <TabItem value="❌ Incorrect">
126
134
 
127
135
  ```ts option='{ "allowTypedFunctionExpressions": true }'
128
136
  let arrowFn = () => 'test';
@@ -136,7 +144,8 @@ let objectProp = {
136
144
  };
137
145
  ```
138
146
 
139
- #### ✅ Correct
147
+ </TabItem>
148
+ <TabItem value="✅ Correct">
140
149
 
141
150
  ```ts option='{ "allowTypedFunctionExpressions": true }'
142
151
  type FuncType = () => string;
@@ -174,13 +183,15 @@ functionWithObjectArg({
174
183
  });
175
184
  ```
176
185
 
186
+ </TabItem>
187
+ </Tabs>
188
+
177
189
  ### `allowHigherOrderFunctions`
178
190
 
179
191
  Examples of code for this rule with `{ allowHigherOrderFunctions: true }`:
180
192
 
181
- <!--tabs-->
182
-
183
- #### ❌ Incorrect
193
+ <Tabs>
194
+ <TabItem value="❌ Incorrect">
184
195
 
185
196
  ```ts option='{ "allowHigherOrderFunctions": true }'
186
197
  var arrowFn = () => () => {};
@@ -190,7 +201,8 @@ function fn() {
190
201
  }
191
202
  ```
192
203
 
193
- #### ✅ Correct
204
+ </TabItem>
205
+ <TabItem value="✅ Correct">
194
206
 
195
207
  ```ts option='{ "allowHigherOrderFunctions": true }'
196
208
  var arrowFn = () => (): void => {};
@@ -200,33 +212,38 @@ function fn() {
200
212
  }
201
213
  ```
202
214
 
215
+ </TabItem>
216
+ </Tabs>
217
+
203
218
  ### `allowDirectConstAssertionInArrowFunctions`
204
219
 
205
220
  Examples of code for this rule with `{ allowDirectConstAssertionInArrowFunctions: true }`:
206
221
 
207
- <!--tabs-->
208
-
209
- #### ❌ Incorrect
222
+ <Tabs>
223
+ <TabItem value="❌ Incorrect">
210
224
 
211
225
  ```ts option='{ "allowDirectConstAssertionInArrowFunctions": true }'
212
226
  const func = (value: number) => ({ type: 'X', value }) as any;
213
227
  const func = (value: number) => ({ type: 'X', value }) as Action;
214
228
  ```
215
229
 
216
- #### ✅ Correct
230
+ </TabItem>
231
+ <TabItem value="✅ Correct">
217
232
 
218
233
  ```ts option='{ "allowDirectConstAssertionInArrowFunctions": true }'
219
234
  const func = (value: number) => ({ foo: 'bar', value }) as const;
220
235
  const func = () => x as const;
221
236
  ```
222
237
 
238
+ </TabItem>
239
+ </Tabs>
240
+
223
241
  ### `allowConciseArrowFunctionExpressionsStartingWithVoid`
224
242
 
225
243
  Examples of code for this rule with `{ allowConciseArrowFunctionExpressionsStartingWithVoid: true }`:
226
244
 
227
- <!--tabs-->
228
-
229
- #### ❌ Incorrect
245
+ <Tabs>
246
+ <TabItem value="❌ Incorrect">
230
247
 
231
248
  ```ts option='{ "allowConciseArrowFunctionExpressionsStartingWithVoid": true }'
232
249
  var join = (a: string, b: string) => `${a}${b}`;
@@ -236,19 +253,22 @@ const log = (message: string) => {
236
253
  };
237
254
  ```
238
255
 
239
- #### ✅ Correct
256
+ </TabItem>
257
+ <TabItem value="✅ Correct">
240
258
 
241
259
  ```ts option='{ "allowConciseArrowFunctionExpressionsStartingWithVoid": true }'
242
260
  var log = (message: string) => void console.log(message);
243
261
  ```
244
262
 
263
+ </TabItem>
264
+ </Tabs>
265
+
245
266
  ### `allowFunctionsWithoutTypeParameters`
246
267
 
247
268
  Examples of code for this rule with `{ allowFunctionsWithoutTypeParameters: true }`:
248
269
 
249
- <!--tabs-->
250
-
251
- #### ❌ Incorrect
270
+ <Tabs>
271
+ <TabItem value="❌ Incorrect">
252
272
 
253
273
  ```ts option='{ "allowFunctionsWithoutTypeParameters": true }'
254
274
  function foo<T>(t: T) {
@@ -258,7 +278,8 @@ function foo<T>(t: T) {
258
278
  const bar = <T>(t: T) => t;
259
279
  ```
260
280
 
261
- #### ✅ Correct
281
+ </TabItem>
282
+ <TabItem value="✅ Correct">
262
283
 
263
284
  ```ts option='{ "allowFunctionsWithoutTypeParameters": true }'
264
285
  function foo<T>(t: T): T {
@@ -274,6 +295,9 @@ function allowedFunction(x: string) {
274
295
  const allowedArrow = (x: string) => x;
275
296
  ```
276
297
 
298
+ </TabItem>
299
+ </Tabs>
300
+
277
301
  ### `allowedNames`
278
302
 
279
303
  You may pass function/method names you would like this rule to ignore, like so:
@@ -293,15 +317,15 @@ You may pass function/method names you would like this rule to ignore, like so:
293
317
 
294
318
  Examples of code for this rule with `{ allowIIFEs: true }`:
295
319
 
296
- <!--tabs-->
297
-
298
- #### ❌ Incorrect
320
+ <Tabs>
321
+ <TabItem value="❌ Incorrect">
299
322
 
300
323
  ```ts option='{ "allowIIFEs": true }'
301
324
  var func = () => 'foo';
302
325
  ```
303
326
 
304
- #### ✅ Correct
327
+ </TabItem>
328
+ <TabItem value="✅ Correct">
305
329
 
306
330
  ```ts option='{ "allowIIFEs": true }'
307
331
  var foo = (() => 'foo')();
@@ -311,6 +335,9 @@ var bar = (function () {
311
335
  })();
312
336
  ```
313
337
 
338
+ </TabItem>
339
+ </Tabs>
340
+
314
341
  ## When Not To Use It
315
342
 
316
343
  If you don't find the added cost of explicitly writing function return types to be worth the visual clarity, or your project is not large enough for it to be a factor in type checking performance, then you will not need this rule.
@@ -2,6 +2,9 @@
2
2
  description: 'Require explicit accessibility modifiers on class properties and 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/explicit-member-accessibility** for documentation.
@@ -2,6 +2,9 @@
2
2
  description: "Require explicit return and argument types on exported functions' and classes' public class 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/explicit-module-boundary-types** for documentation.
@@ -12,9 +15,8 @@ It can also improve TypeScript type checking performance on larger codebases.
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
  // Should indicate that no value is returned (void)
@@ -37,7 +39,8 @@ export class Test {
37
39
  }
38
40
  ```
39
41
 
40
- ### ✅ Correct
42
+ </TabItem>
43
+ <TabItem value="✅ Correct">
41
44
 
42
45
  ```ts
43
46
  // A function with no return value (void)
@@ -65,6 +68,9 @@ function test() {
65
68
  }
66
69
  ```
67
70
 
71
+ </TabItem>
72
+ </Tabs>
73
+
68
74
  ## Options
69
75
 
70
76
  ### Configuring in a mixed JS/TS codebase
@@ -93,27 +99,29 @@ If you are working on a codebase within which you lint non-TypeScript code (i.e.
93
99
 
94
100
  Examples of code for this rule with `{ allowArgumentsExplicitlyTypedAsAny: false }`:
95
101
 
96
- <!--tabs-->
97
-
98
- #### ❌ Incorrect
102
+ <Tabs>
103
+ <TabItem value="❌ Incorrect">
99
104
 
100
105
  ```ts option='{ "allowArgumentsExplicitlyTypedAsAny": false }'
101
106
  export const func = (value: any): number => value + 1;
102
107
  ```
103
108
 
104
- #### ✅ Correct
109
+ </TabItem>
110
+ <TabItem value="✅ Correct">
105
111
 
106
112
  ```ts option='{ "allowArgumentsExplicitlyTypedAsAny": false }'
107
113
  export const func = (value: number): number => value + 1;
108
114
  ```
109
115
 
116
+ </TabItem>
117
+ </Tabs>
118
+
110
119
  ### `allowDirectConstAssertionInArrowFunctions`
111
120
 
112
121
  Examples of code for this rule with `{ allowDirectConstAssertionInArrowFunctions: false }`:
113
122
 
114
- <!--tabs-->
115
-
116
- #### ❌ Incorrect
123
+ <Tabs>
124
+ <TabItem value="❌ Incorrect">
117
125
 
118
126
  ```ts option='{ "allowArgumentsExplicitlyTypedAsAny": false }'
119
127
  export const func = (value: number) => ({ type: 'X', value });
@@ -123,7 +131,8 @@ export const foo = () => ({
123
131
  export const bar = () => 1;
124
132
  ```
125
133
 
126
- #### ✅ Correct
134
+ </TabItem>
135
+ <TabItem value="✅ Correct">
127
136
 
128
137
  ```ts option='{ "allowArgumentsExplicitlyTypedAsAny": false }'
129
138
  export const func = (value: number) => ({ type: 'X', value }) as const;
@@ -134,6 +143,9 @@ export const foo = () =>
134
143
  export const bar = () => 1 as const;
135
144
  ```
136
145
 
146
+ </TabItem>
147
+ </Tabs>
148
+
137
149
  ### `allowedNames`
138
150
 
139
151
  You may pass function/method names you would like this rule to ignore, like so:
@@ -153,9 +165,8 @@ You may pass function/method names you would like this rule to ignore, like so:
153
165
 
154
166
  Examples of code for this rule with `{ allowHigherOrderFunctions: false }`:
155
167
 
156
- <!--tabs-->
157
-
158
- #### ❌ Incorrect
168
+ <Tabs>
169
+ <TabItem value="❌ Incorrect">
159
170
 
160
171
  ```ts option='{ "allowHigherOrderFunctions": false }'
161
172
  export const arrowFn = () => () => {};
@@ -169,7 +180,8 @@ export function foo(outer: string) {
169
180
  }
170
181
  ```
171
182
 
172
- #### ✅ Correct
183
+ </TabItem>
184
+ <TabItem value="✅ Correct">
173
185
 
174
186
  ```ts option='{ "allowHigherOrderFunctions": false }'
175
187
  export const arrowFn = () => (): void => {};
@@ -183,13 +195,15 @@ export function foo(outer: string) {
183
195
  }
184
196
  ```
185
197
 
198
+ </TabItem>
199
+ </Tabs>
200
+
186
201
  ### `allowTypedFunctionExpressions`
187
202
 
188
203
  Examples of code for this rule with `{ allowTypedFunctionExpressions: false }`:
189
204
 
190
- <!--tabs-->
191
-
192
- #### ❌ Incorrect
205
+ <Tabs>
206
+ <TabItem value="❌ Incorrect">
193
207
 
194
208
  ```ts option='{ "allowTypedFunctionExpressions": false }'
195
209
  export let arrowFn = () => 'test';
@@ -205,7 +219,8 @@ export let objectProp = {
205
219
  export const foo = bar => {};
206
220
  ```
207
221
 
208
- #### ✅ Correct
222
+ </TabItem>
223
+ <TabItem value="✅ Correct">
209
224
 
210
225
  ```ts option='{ "allowTypedFunctionExpressions": false }'
211
226
  type FuncType = () => string;
@@ -236,6 +251,9 @@ type FooType = (bar: string) => void;
236
251
  export const foo: FooType = bar => {};
237
252
  ```
238
253
 
254
+ </TabItem>
255
+ </Tabs>
256
+
239
257
  ## When Not To Use It
240
258
 
241
259
  If your project is not used by downstream consumers that are sensitive to API types, you can disable this rule.
@@ -246,4 +264,4 @@ If your project is not used by downstream consumers that are sensitive to API ty
246
264
 
247
265
  ## Related To
248
266
 
249
- - [explicit-function-return-type](./explicit-function-return-type.md)
267
+ - [explicit-function-return-type](./explicit-function-return-type.mdx)
@@ -2,6 +2,9 @@
2
2
  description: 'Require or disallow spacing between function identifiers and their invocations.'
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/func-call-spacing** for documentation.
@@ -2,6 +2,9 @@
2
2
  description: 'Enforce consistent indentation.'
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/indent** for documentation.
@@ -2,6 +2,9 @@
2
2
  description: 'Require or disallow initialization in variable declarations.'
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/init-declarations** for documentation.