@typescript-eslint/eslint-plugin 8.0.0-alpha.8 → 8.0.0

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 (283) hide show
  1. package/dist/configs/all.js +7 -6
  2. package/dist/configs/all.js.map +1 -1
  3. package/dist/configs/disable-type-checked.js +3 -3
  4. package/dist/configs/disable-type-checked.js.map +1 -1
  5. package/dist/configs/recommended-type-checked-only.js +6 -0
  6. package/dist/configs/recommended-type-checked-only.js.map +1 -1
  7. package/dist/configs/recommended-type-checked.js +13 -2
  8. package/dist/configs/recommended-type-checked.js.map +1 -1
  9. package/dist/configs/recommended.js +7 -2
  10. package/dist/configs/recommended.js.map +1 -1
  11. package/dist/configs/strict-type-checked-only.js +8 -2
  12. package/dist/configs/strict-type-checked-only.js.map +1 -1
  13. package/dist/configs/strict-type-checked.js +15 -5
  14. package/dist/configs/strict-type-checked.js.map +1 -1
  15. package/dist/configs/strict.js +7 -3
  16. package/dist/configs/strict.js.map +1 -1
  17. package/dist/configs/stylistic-type-checked-only.js +3 -0
  18. package/dist/configs/stylistic-type-checked-only.js.map +1 -1
  19. package/dist/configs/stylistic-type-checked.js +3 -2
  20. package/dist/configs/stylistic-type-checked.js.map +1 -1
  21. package/dist/configs/stylistic.js +0 -2
  22. package/dist/configs/stylistic.js.map +1 -1
  23. package/dist/rules/adjacent-overload-signatures.js +2 -6
  24. package/dist/rules/adjacent-overload-signatures.js.map +1 -1
  25. package/dist/rules/array-type.js +14 -5
  26. package/dist/rules/array-type.js.map +1 -1
  27. package/dist/rules/class-literal-property-style.js +16 -16
  28. package/dist/rules/class-literal-property-style.js.map +1 -1
  29. package/dist/rules/class-methods-use-this.js.map +1 -1
  30. package/dist/rules/consistent-type-assertions.js +5 -19
  31. package/dist/rules/consistent-type-assertions.js.map +1 -1
  32. package/dist/rules/consistent-type-definitions.js +1 -1
  33. package/dist/rules/consistent-type-definitions.js.map +1 -1
  34. package/dist/rules/consistent-type-imports.js +13 -13
  35. package/dist/rules/consistent-type-imports.js.map +1 -1
  36. package/dist/rules/default-param-last.js +6 -1
  37. package/dist/rules/default-param-last.js.map +1 -1
  38. package/dist/rules/dot-notation.js +8 -1
  39. package/dist/rules/dot-notation.js.map +1 -1
  40. package/dist/rules/enum-utils/shared.js +3 -4
  41. package/dist/rules/enum-utils/shared.js.map +1 -1
  42. package/dist/rules/explicit-member-accessibility.js +49 -37
  43. package/dist/rules/explicit-member-accessibility.js.map +1 -1
  44. package/dist/rules/index.js +14 -6
  45. package/dist/rules/index.js.map +1 -1
  46. package/dist/rules/init-declarations.js +57 -1
  47. package/dist/rules/init-declarations.js.map +1 -1
  48. package/dist/rules/member-ordering.js +8 -2
  49. package/dist/rules/member-ordering.js.map +1 -1
  50. package/dist/rules/method-signature-style.js +1 -3
  51. package/dist/rules/method-signature-style.js.map +1 -1
  52. package/dist/rules/naming-convention-utils/parse-options.js +2 -5
  53. package/dist/rules/naming-convention-utils/parse-options.js.map +1 -1
  54. package/dist/rules/naming-convention-utils/shared.js +3 -4
  55. package/dist/rules/naming-convention-utils/shared.js.map +1 -1
  56. package/dist/rules/naming-convention-utils/validator.js +1 -2
  57. package/dist/rules/naming-convention-utils/validator.js.map +1 -1
  58. package/dist/rules/naming-convention.js +3 -1
  59. package/dist/rules/naming-convention.js.map +1 -1
  60. package/dist/rules/no-array-delete.js +1 -1
  61. package/dist/rules/no-array-delete.js.map +1 -1
  62. package/dist/rules/no-base-to-string.js +1 -1
  63. package/dist/rules/no-base-to-string.js.map +1 -1
  64. package/dist/rules/no-duplicate-type-constituents.js +29 -3
  65. package/dist/rules/no-duplicate-type-constituents.js.map +1 -1
  66. package/dist/rules/no-dynamic-delete.js +8 -40
  67. package/dist/rules/no-dynamic-delete.js.map +1 -1
  68. package/dist/rules/no-empty-interface.js +2 -1
  69. package/dist/rules/no-empty-interface.js.map +1 -1
  70. package/dist/rules/no-empty-object-type.js +141 -0
  71. package/dist/rules/no-empty-object-type.js.map +1 -0
  72. package/dist/rules/no-extraneous-class.js +11 -3
  73. package/dist/rules/no-extraneous-class.js.map +1 -1
  74. package/dist/rules/no-floating-promises.js +91 -55
  75. package/dist/rules/no-floating-promises.js.map +1 -1
  76. package/dist/rules/no-implied-eval.js +6 -24
  77. package/dist/rules/no-implied-eval.js.map +1 -1
  78. package/dist/rules/no-inferrable-types.js +1 -2
  79. package/dist/rules/no-inferrable-types.js.map +1 -1
  80. package/dist/rules/no-invalid-this.js +6 -0
  81. package/dist/rules/no-invalid-this.js.map +1 -1
  82. package/dist/rules/no-magic-numbers.js +32 -1
  83. package/dist/rules/no-magic-numbers.js.map +1 -1
  84. package/dist/rules/no-misused-new.js +4 -3
  85. package/dist/rules/no-misused-new.js.map +1 -1
  86. package/dist/rules/no-misused-promises.js +76 -1
  87. package/dist/rules/no-misused-promises.js.map +1 -1
  88. package/dist/rules/no-mixed-enums.js +6 -9
  89. package/dist/rules/no-mixed-enums.js.map +1 -1
  90. package/dist/rules/no-non-null-assertion.js +12 -14
  91. package/dist/rules/no-non-null-assertion.js.map +1 -1
  92. package/dist/rules/no-require-imports.js +13 -3
  93. package/dist/rules/no-require-imports.js.map +1 -1
  94. package/dist/rules/no-restricted-imports.js +5 -6
  95. package/dist/rules/no-restricted-imports.js.map +1 -1
  96. package/dist/rules/{ban-types.js → no-restricted-types.js} +17 -91
  97. package/dist/rules/no-restricted-types.js.map +1 -0
  98. package/dist/rules/no-shadow.js +4 -9
  99. package/dist/rules/no-shadow.js.map +1 -1
  100. package/dist/rules/no-unnecessary-condition.js +8 -6
  101. package/dist/rules/no-unnecessary-condition.js.map +1 -1
  102. package/dist/rules/no-unnecessary-parameter-property-assignment.js +151 -0
  103. package/dist/rules/no-unnecessary-parameter-property-assignment.js.map +1 -0
  104. package/dist/rules/no-unnecessary-qualifier.js.map +1 -1
  105. package/dist/rules/no-unnecessary-template-expression.js +223 -0
  106. package/dist/rules/no-unnecessary-template-expression.js.map +1 -0
  107. package/dist/rules/no-unnecessary-type-assertion.js +16 -13
  108. package/dist/rules/no-unnecessary-type-assertion.js.map +1 -1
  109. package/dist/rules/no-unnecessary-type-parameters.js +309 -0
  110. package/dist/rules/no-unnecessary-type-parameters.js.map +1 -0
  111. package/dist/rules/no-unsafe-argument.js +4 -2
  112. package/dist/rules/no-unsafe-argument.js.map +1 -1
  113. package/dist/rules/no-unsafe-assignment.js +24 -9
  114. package/dist/rules/no-unsafe-assignment.js.map +1 -1
  115. package/dist/rules/no-unsafe-call.js +5 -1
  116. package/dist/rules/no-unsafe-call.js.map +1 -1
  117. package/dist/rules/no-unsafe-enum-comparison.js +1 -5
  118. package/dist/rules/no-unsafe-enum-comparison.js.map +1 -1
  119. package/dist/rules/no-unsafe-function-type.js +47 -0
  120. package/dist/rules/no-unsafe-function-type.js.map +1 -0
  121. package/dist/rules/no-unsafe-member-access.js +10 -4
  122. package/dist/rules/no-unsafe-member-access.js.map +1 -1
  123. package/dist/rules/no-unsafe-return.js +9 -3
  124. package/dist/rules/no-unsafe-return.js.map +1 -1
  125. package/dist/rules/no-unsafe-unary-minus.js +1 -0
  126. package/dist/rules/no-unsafe-unary-minus.js.map +1 -1
  127. package/dist/rules/no-unused-expressions.js +1 -0
  128. package/dist/rules/no-unused-expressions.js.map +1 -1
  129. package/dist/rules/no-unused-vars.js +198 -79
  130. package/dist/rules/no-unused-vars.js.map +1 -1
  131. package/dist/rules/no-use-before-define.js +2 -16
  132. package/dist/rules/no-use-before-define.js.map +1 -1
  133. package/dist/rules/no-useless-constructor.js +1 -3
  134. package/dist/rules/no-useless-constructor.js.map +1 -1
  135. package/dist/rules/no-var-requires.js +2 -1
  136. package/dist/rules/no-var-requires.js.map +1 -1
  137. package/dist/rules/no-wrapper-object-types.js +61 -0
  138. package/dist/rules/no-wrapper-object-types.js.map +1 -0
  139. package/dist/rules/only-throw-error.js +1 -1
  140. package/dist/rules/only-throw-error.js.map +1 -1
  141. package/dist/rules/prefer-as-const.js +1 -1
  142. package/dist/rules/prefer-as-const.js.map +1 -1
  143. package/dist/rules/prefer-destructuring.js +3 -1
  144. package/dist/rules/prefer-destructuring.js.map +1 -1
  145. package/dist/rules/prefer-find.js +2 -1
  146. package/dist/rules/prefer-find.js.map +1 -1
  147. package/dist/rules/prefer-includes.js +1 -1
  148. package/dist/rules/prefer-includes.js.map +1 -1
  149. package/dist/rules/prefer-literal-enum-member.js +43 -2
  150. package/dist/rules/prefer-literal-enum-member.js.map +1 -1
  151. package/dist/rules/prefer-namespace-keyword.js +1 -1
  152. package/dist/rules/prefer-namespace-keyword.js.map +1 -1
  153. package/dist/rules/prefer-nullish-coalescing.js +8 -6
  154. package/dist/rules/prefer-nullish-coalescing.js.map +1 -1
  155. package/dist/rules/prefer-optional-chain-utils/analyzeChain.js +32 -37
  156. package/dist/rules/prefer-optional-chain-utils/analyzeChain.js.map +1 -1
  157. package/dist/rules/prefer-optional-chain-utils/checkNullishAndReport.js +1 -2
  158. package/dist/rules/prefer-optional-chain-utils/checkNullishAndReport.js.map +1 -1
  159. package/dist/rules/prefer-optional-chain-utils/compareNodes.js +1 -2
  160. package/dist/rules/prefer-optional-chain-utils/compareNodes.js.map +1 -1
  161. package/dist/rules/prefer-optional-chain-utils/gatherLogicalOperands.js +6 -11
  162. package/dist/rules/prefer-optional-chain-utils/gatherLogicalOperands.js.map +1 -1
  163. package/dist/rules/prefer-promise-reject-errors.js +1 -1
  164. package/dist/rules/prefer-promise-reject-errors.js.map +1 -1
  165. package/dist/rules/prefer-readonly.js +24 -12
  166. package/dist/rules/prefer-readonly.js.map +1 -1
  167. package/dist/rules/prefer-regexp-exec.js +15 -6
  168. package/dist/rules/prefer-regexp-exec.js.map +1 -1
  169. package/dist/rules/prefer-string-starts-ends-with.js.map +1 -1
  170. package/dist/rules/prefer-ts-expect-error.js +2 -1
  171. package/dist/rules/prefer-ts-expect-error.js.map +1 -1
  172. package/dist/rules/require-await.js +1 -1
  173. package/dist/rules/require-await.js.map +1 -1
  174. package/dist/rules/restrict-template-expressions.js +3 -3
  175. package/dist/rules/restrict-template-expressions.js.map +1 -1
  176. package/dist/rules/return-await.js +167 -86
  177. package/dist/rules/return-await.js.map +1 -1
  178. package/dist/rules/sort-type-constituents.js +23 -1
  179. package/dist/rules/sort-type-constituents.js.map +1 -1
  180. package/dist/rules/strict-boolean-expressions.js +112 -5
  181. package/dist/rules/strict-boolean-expressions.js.map +1 -1
  182. package/dist/rules/switch-exhaustiveness-check.js +7 -9
  183. package/dist/rules/switch-exhaustiveness-check.js.map +1 -1
  184. package/dist/rules/unbound-method.js +96 -27
  185. package/dist/rules/unbound-method.js.map +1 -1
  186. package/dist/rules/unified-signatures.js +3 -1
  187. package/dist/rules/unified-signatures.js.map +1 -1
  188. package/dist/util/astUtils.js +2 -3
  189. package/dist/util/astUtils.js.map +1 -1
  190. package/dist/util/collectUnusedVariables.js +110 -73
  191. package/dist/util/collectUnusedVariables.js.map +1 -1
  192. package/dist/util/createRule.js.map +1 -1
  193. package/dist/util/escapeRegExp.js +1 -2
  194. package/dist/util/escapeRegExp.js.map +1 -1
  195. package/dist/util/explicitReturnTypeUtils.js +11 -7
  196. package/dist/util/explicitReturnTypeUtils.js.map +1 -1
  197. package/dist/util/getESLintCoreRule.js +2 -2
  198. package/dist/util/getESLintCoreRule.js.map +1 -1
  199. package/dist/util/getForStatementHeadLoc.js +1 -2
  200. package/dist/util/getForStatementHeadLoc.js.map +1 -1
  201. package/dist/util/getFunctionHeadLoc.js +3 -4
  202. package/dist/util/getFunctionHeadLoc.js.map +1 -1
  203. package/dist/util/getMemberHeadLoc.js +80 -0
  204. package/dist/util/getMemberHeadLoc.js.map +1 -0
  205. package/dist/util/getOperatorPrecedence.js +5 -5
  206. package/dist/util/getOperatorPrecedence.js.map +1 -1
  207. package/dist/util/getStaticStringValue.js +1 -2
  208. package/dist/util/getStaticStringValue.js.map +1 -1
  209. package/dist/util/getStringLength.js +1 -2
  210. package/dist/util/getStringLength.js.map +1 -1
  211. package/dist/util/getTextWithParentheses.js +17 -0
  212. package/dist/util/getTextWithParentheses.js.map +1 -0
  213. package/dist/util/getThisExpression.js +1 -2
  214. package/dist/util/getThisExpression.js.map +1 -1
  215. package/dist/util/getWrappedCode.js +1 -2
  216. package/dist/util/getWrappedCode.js.map +1 -1
  217. package/dist/util/getWrappingFixer.js +2 -3
  218. package/dist/util/getWrappingFixer.js.map +1 -1
  219. package/dist/util/index.js +2 -0
  220. package/dist/util/index.js.map +1 -1
  221. package/dist/util/isAssignee.js +1 -2
  222. package/dist/util/isAssignee.js.map +1 -1
  223. package/dist/util/isNodeEqual.js +1 -2
  224. package/dist/util/isNodeEqual.js.map +1 -1
  225. package/dist/util/isNullLiteral.js +1 -2
  226. package/dist/util/isNullLiteral.js.map +1 -1
  227. package/dist/util/isTypeImport.js +22 -0
  228. package/dist/util/isTypeImport.js.map +1 -0
  229. package/dist/util/isUndefinedIdentifier.js +1 -2
  230. package/dist/util/isUndefinedIdentifier.js.map +1 -1
  231. package/dist/util/misc.js +15 -15
  232. package/dist/util/misc.js.map +1 -1
  233. package/dist/util/objectIterators.js +3 -4
  234. package/dist/util/objectIterators.js.map +1 -1
  235. package/dist/util/referenceContainsTypeQuery.js +20 -0
  236. package/dist/util/referenceContainsTypeQuery.js.map +1 -0
  237. package/dist/util/scopeUtils.js +11 -0
  238. package/dist/util/scopeUtils.js.map +1 -0
  239. package/docs/rules/array-type.mdx +4 -1
  240. package/docs/rules/ban-types.md +22 -0
  241. package/docs/rules/class-methods-use-this.mdx +1 -1
  242. package/docs/rules/consistent-indexed-object-style.mdx +1 -1
  243. package/docs/rules/naming-convention.mdx +16 -0
  244. package/docs/rules/no-base-to-string.mdx +1 -1
  245. package/docs/rules/no-duplicate-type-constituents.mdx +6 -2
  246. package/docs/rules/no-dynamic-delete.mdx +12 -7
  247. package/docs/rules/no-empty-interface.mdx +10 -0
  248. package/docs/rules/no-empty-object-type.mdx +145 -0
  249. package/docs/rules/no-extraneous-class.mdx +6 -0
  250. package/docs/rules/no-floating-promises.mdx +146 -2
  251. package/docs/rules/no-misused-promises.mdx +18 -20
  252. package/docs/rules/no-redundant-type-constituents.mdx +4 -0
  253. package/docs/rules/no-require-imports.mdx +28 -1
  254. package/docs/rules/no-restricted-types.mdx +71 -0
  255. package/docs/rules/no-type-alias.mdx +1 -1
  256. package/docs/rules/no-unnecessary-parameter-property-assignment.mdx +42 -0
  257. package/docs/rules/no-unnecessary-template-expression.mdx +85 -0
  258. package/docs/rules/no-unnecessary-type-parameters.mdx +114 -0
  259. package/docs/rules/no-unsafe-function-type.mdx +63 -0
  260. package/docs/rules/no-unused-expressions.mdx +41 -1
  261. package/docs/rules/no-unused-vars.mdx +5 -0
  262. package/docs/rules/no-useless-template-literals.mdx +3 -59
  263. package/docs/rules/no-var-requires.mdx +6 -0
  264. package/docs/rules/no-wrapper-object-types.mdx +75 -0
  265. package/docs/rules/only-throw-error.mdx +7 -0
  266. package/docs/rules/prefer-readonly-parameter-types.mdx +10 -4
  267. package/docs/rules/prefer-ts-expect-error.mdx +10 -0
  268. package/docs/rules/require-await.mdx +2 -2
  269. package/docs/rules/restrict-template-expressions.mdx +1 -1
  270. package/docs/rules/return-await.mdx +119 -23
  271. package/docs/rules/sort-type-constituents.mdx +29 -9
  272. package/docs/rules/sort-type-union-intersection-members.mdx +12 -0
  273. package/docs/rules/strict-boolean-expressions.mdx +6 -0
  274. package/docs/rules/unbound-method.mdx +2 -1
  275. package/package.json +14 -20
  276. package/rules.d.ts +31 -4
  277. package/dist/rules/ban-types.js.map +0 -1
  278. package/dist/rules/no-throw-literal.js +0 -97
  279. package/dist/rules/no-throw-literal.js.map +0 -1
  280. package/dist/rules/no-useless-template-literals.js +0 -153
  281. package/dist/rules/no-useless-template-literals.js.map +0 -1
  282. package/docs/rules/ban-types.mdx +0 -138
  283. package/docs/rules/no-throw-literal.mdx +0 -25
@@ -0,0 +1,63 @@
1
+ ---
2
+ description: 'Disallow using the unsafe built-in Function type.'
3
+ ---
4
+
5
+ import Tabs from '@theme/Tabs';
6
+ import TabItem from '@theme/TabItem';
7
+
8
+ > 🛑 This file is source code, not the primary documentation location! 🛑
9
+ >
10
+ > See **https://typescript-eslint.io/rules/no-unsafe-function-type** for documentation.
11
+
12
+ TypeScript's built-in `Function` type allows being called with any number of arguments and returns type `any`.
13
+ `Function` also allows classes or plain objects that happen to possess all properties of the `Function` class.
14
+ It's generally better to specify function parameters and return types with the function type syntax.
15
+
16
+ "Catch-all" function types include:
17
+
18
+ - `() => void`: a function that has no parameters and whose return is ignored
19
+ - `(...args: never) => unknown`: a "top type" for functions that can be assigned any function type, but can't be called
20
+
21
+ Examples of code for this rule:
22
+
23
+ <Tabs>
24
+ <TabItem value="❌ Incorrect">
25
+
26
+ ```ts
27
+ let noParametersOrReturn: Function;
28
+ noParametersOrReturn = () => {};
29
+
30
+ let stringToNumber: Function;
31
+ stringToNumber = (text: string) => text.length;
32
+
33
+ let identity: Function;
34
+ identity = value => value;
35
+ ```
36
+
37
+ </TabItem>
38
+ <TabItem value="✅ Correct">
39
+
40
+ ```ts
41
+ let noParametersOrReturn: () => void;
42
+ noParametersOrReturn = () => {};
43
+
44
+ let stringToNumber: (text: string) => number;
45
+ stringToNumber = text => text.length;
46
+
47
+ let identity: <T>(value: T) => T;
48
+ identity = value => value;
49
+ ```
50
+
51
+ </TabItem>
52
+ </Tabs>
53
+
54
+ ## When Not To Use It
55
+
56
+ If your project is still onboarding to TypeScript, it might be difficult to fully replace all unsafe `Function` types with more precise function types.
57
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
58
+
59
+ ## Related To
60
+
61
+ - [`no-empty-object-type`](./no-empty-object-type.mdx)
62
+ - [`no-restricted-types`](./no-restricted-types.mdx)
63
+ - [`no-wrapper-object-types`](./no-wrapper-object-types.mdx)
@@ -10,4 +10,44 @@ import TabItem from '@theme/TabItem';
10
10
  > See **https://typescript-eslint.io/rules/no-unused-expressions** for documentation.
11
11
 
12
12
  This rule extends the base [`eslint/no-unused-expressions`](https://eslint.org/docs/rules/no-unused-expressions) rule.
13
- It adds support for optional call expressions `x?.()`, and directive in module declarations.
13
+ It supports TypeScript-specific expressions:
14
+
15
+ - Marks directives in modules declarations (`"use strict"`, etc.) as not unused
16
+ - Marks the following expressions as unused if their wrapped value expressions are unused:
17
+ - Assertion expressions: `x as number;`, `x!;`, `<number>x;`
18
+ - Instantiation expressions: `Set<number>;`
19
+
20
+ Although the type expressions never have runtime side effects (that is, `x!;` is the same as `x;`), they can be used to assert types for testing purposes.
21
+
22
+ ## Examples
23
+
24
+ <Tabs>
25
+ <TabItem value="❌ Incorrect">
26
+
27
+ ```ts
28
+ Set<number>;
29
+ 1 as number;
30
+ window!;
31
+ ```
32
+
33
+ </TabItem>
34
+ <TabItem value="✅ Correct">
35
+
36
+ ```ts
37
+ function getSet() {
38
+ return Set;
39
+ }
40
+
41
+ // Funtion calls are allowed, so type expressions that wrap function calls are allowed
42
+ getSet()<number>;
43
+ getSet() as Set<unknown>;
44
+ getSet()!;
45
+
46
+ // Namespaces can have directives
47
+ namespace A {
48
+ 'use strict';
49
+ }
50
+ ```
51
+
52
+ </TabItem>
53
+ </Tabs>
@@ -47,3 +47,8 @@ We generally recommend using `@typescript-eslint/no-unused-vars` to flag unused
47
47
  :::tip
48
48
  Editors such as VS Code will still generally "grey out" unused variables even if `noUnusedLocals` and `noUnusedParameters` are not enabled in a project.
49
49
  :::
50
+
51
+ Also see similar rules provided by ESLint:
52
+
53
+ - [`no-unused-private-class-members`](https://eslint.org/docs/latest/rules/no-unused-private-class-members)
54
+ - [`no-unused-labels`](https://eslint.org/docs/latest/rules/no-unused-labels)
@@ -1,61 +1,5 @@
1
- ---
2
- description: 'Disallow unnecessary template literals.'
3
- ---
1
+ :::danger Deprecated
4
2
 
5
- import Tabs from '@theme/Tabs';
6
- import TabItem from '@theme/TabItem';
3
+ This rule has been renamed to [`no-unnecessary-template-expression`](./no-unnecessary-template-expression.mdx). See [#8544](https://github.com/typescript-eslint/typescript-eslint/issues/8544) for more information.
7
4
 
8
- > 🛑 This file is source code, not the primary documentation location! 🛑
9
- >
10
- > See **https://typescript-eslint.io/rules/no-useless-template-literals** for documentation.
11
-
12
- This rule reports template literals that can be simplified to a normal string literal.
13
-
14
- ## Examples
15
-
16
- <Tabs>
17
- <TabItem value="❌ Incorrect">
18
-
19
- ```ts
20
- const ab1 = `${'a'}${'b'}`;
21
- const ab2 = `a${'b'}`;
22
-
23
- const stringWithNumber = `${'1 + 1 = '}${2}`;
24
-
25
- const stringWithBoolean = `${'true is '}${true}`;
26
-
27
- const text = 'a';
28
- const wrappedText = `${text}`;
29
-
30
- declare const intersectionWithString: string & { _brand: 'test-brand' };
31
- const wrappedIntersection = `${intersectionWithString}`;
32
- ```
33
-
34
- </TabItem>
35
- <TabItem value="✅ Correct">
36
-
37
- ```ts
38
- const ab1 = 'ab';
39
- const ab2 = 'ab';
40
-
41
- const stringWithNumber = `1 + 1 = 2`;
42
-
43
- const stringWithBoolean = `true is true`;
44
-
45
- const text = 'a';
46
- const wrappedText = text;
47
-
48
- declare const intersectionWithString: string & { _brand: 'test-brand' };
49
- const wrappedIntersection = intersectionWithString;
50
- ```
51
-
52
- </TabItem>
53
- </Tabs>
54
-
55
- ## When Not To Use It
56
-
57
- When you want to allow string expressions inside template literals.
58
-
59
- ## Related To
60
-
61
- - [`restrict-template-expressions`](./restrict-template-expressions.mdx)
5
+ :::
@@ -9,6 +9,12 @@ import TabItem from '@theme/TabItem';
9
9
  >
10
10
  > See **https://typescript-eslint.io/rules/no-var-requires** for documentation.
11
11
 
12
+ :::danger Deprecated
13
+
14
+ This rule has been deprecated in favour of the [`@typescript-eslint/no-require-imports`](./no-require-imports.mdx) rule.
15
+
16
+ :::
17
+
12
18
  In other words, the use of forms such as `var foo = require("foo")` are banned. Instead use ES6 style imports or `import foo = require("foo")` imports.
13
19
 
14
20
  ## Examples
@@ -0,0 +1,75 @@
1
+ ---
2
+ description: 'Disallow using confusing built-in primitive class wrappers.'
3
+ ---
4
+
5
+ import Tabs from '@theme/Tabs';
6
+ import TabItem from '@theme/TabItem';
7
+
8
+ > 🛑 This file is source code, not the primary documentation location! 🛑
9
+ >
10
+ > See **https://typescript-eslint.io/rules/no-wrapper-object-types** for documentation.
11
+
12
+ TypeScript defines several confusing pairs of types that look very similar to each other, but actually mean different things: `boolean`/`Boolean`, `number`/`Number`, `string`/`String`, `bigint`/`BigInt`, `symbol`/`Symbol`, `object`/`Object`.
13
+ In general, only the lowercase variant is appropriate to use.
14
+ Therefore, this rule enforces that you only use the lowercase variant.
15
+
16
+ JavaScript has [8 data types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures) at runtime, and these are described in TypeScript by the lowercase types `undefined`, `null`, `boolean`, `number`, `string`, `bigint`, `symbol`, and `object`.
17
+
18
+ As for the uppercase types, these are _structural types_ which describe JavaScript "wrapper" objects for each of the data types, such as [`Boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) and [`Number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number).
19
+ Additionally, due to the quirks of structural typing, the corresponding primitives are _also_ assignable to these uppercase types, since they have the same "shape".
20
+
21
+ It is a universal best practice to work directly with the built-in primitives, like `0`, rather than objects that "look like" the corresponding primitive, like `new Number(0)`.
22
+
23
+ - Primitives have the expected value semantics with `==` and `===` equality checks, whereas their object counterparts are compared by reference.
24
+ That is to say, `"str" === "str"` but `new String("str") !== new String("str")`.
25
+ - Primitives have well-known behavior around truthiness/falsiness which is common to rely on, whereas all objects are truthy, regardless of the wrapped value (e.g. `new Boolean(false)` is truthy).
26
+ - TypeScript only allows arithmetic operations (e.g. `x - y`) to be performed on numeric primitives, not objects.
27
+
28
+ As a result, using the lowercase type names like `number` in TypeScript types instead of the uppercase names like `Number` is a better practice that describes code more accurately.
29
+
30
+ Examples of code for this rule:
31
+
32
+ <Tabs>
33
+ <TabItem value="❌ Incorrect">
34
+
35
+ ```ts
36
+ let myBigInt: BigInt;
37
+ let myBoolean: Boolean;
38
+ let myNumber: Number;
39
+ let myString: String;
40
+ let mySymbol: Symbol;
41
+
42
+ let myObject: Object = 'allowed by TypeScript';
43
+ ```
44
+
45
+ </TabItem>
46
+ <TabItem value="✅ Correct">
47
+
48
+ ```ts
49
+ let myBigint: bigint;
50
+ let myBoolean: boolean;
51
+ let myNumber: number;
52
+ let myString: string;
53
+ let mySymbol: symbol;
54
+
55
+ let myObject: object = "Type 'string' is not assignable to type 'object'.";
56
+ ```
57
+
58
+ </TabItem>
59
+ </Tabs>
60
+
61
+ ## When Not To Use It
62
+
63
+ If your project is a rare one that intentionally deals with the class equivalents of primitives, it might not be worthwhile to use this rule.
64
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
65
+
66
+ ## Further Reading
67
+
68
+ - [MDN documentation on primitives](https://developer.mozilla.org/en-US/docs/Glossary/Primitive)
69
+ - [MDN documentation on `string` primitives and `String` objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#string_primitives_and_string_objects)
70
+
71
+ ## Related To
72
+
73
+ - [`no-empty-object-type`](./no-empty-object-type.mdx)
74
+ - [`no-restricted-types`](./no-restricted-types.mdx)
75
+ - [`no-unsafe-function-type`](./no-unsafe-function-type.mdx)
@@ -14,6 +14,13 @@ The fundamental benefit of `Error` objects is that they automatically keep track
14
14
 
15
15
  This rule restricts what can be thrown as an exception.
16
16
 
17
+ :::info[Migration from `no-throw-literal`]
18
+
19
+ This rule was formerly known as `no-throw-literal`.
20
+ The new name is a drop-in replacement with identical functionality.
21
+
22
+ :::
23
+
17
24
  ## Examples
18
25
 
19
26
  This rule is aimed at maintaining consistency when throwing exception by disallowing to throw literals and other expressions which cannot possibly be an `Error` object.
@@ -142,11 +142,12 @@ interface Foo {
142
142
 
143
143
  Some complex types cannot easily be made readonly, for example the `HTMLElement` type or the `JQueryStatic` type from `@types/jquery`. This option allows you to globally disable reporting of such types.
144
144
 
145
- Each item must be one of:
145
+ This option takes an array of type specifiers to ignore.
146
+ Each item in the array must have one of the following forms:
146
147
 
147
- - A type defined in a file (`{from: "file", name: "Foo", path: "src/foo-file.ts"}` with `path` being an optional path relative to the project root directory)
148
- - A type from the default library (`{from: "lib", name: "Foo"}`)
149
- - A type from a package (`{from: "package", name: "Foo", package: "foo-lib"}`, this also works for types defined in a typings package).
148
+ - A type defined in a file (`{ from: "file", name: "Foo", path: "src/foo-file.ts" }` with `path` being an optional path relative to the project root directory)
149
+ - A type from the default library (`{ from: "lib", name: "Foo" }`)
150
+ - A type from a package (`{ from: "package", name: "Foo", package: "foo-lib" }`, this also works for types defined in a typings package).
150
151
 
151
152
  Additionally, a type may be defined just as a simple string, which then matches the type independently of its origin.
152
153
 
@@ -401,3 +402,8 @@ function foo(arg: MyType) {}
401
402
  ## When Not To Use It
402
403
 
403
404
  If your project does not attempt to enforce strong immutability guarantees of parameters, you can avoid this rule.
405
+
406
+ This rule is very strict on what it considers mutable.
407
+ Many types that describe themselves as readonly are considered mutable because they have mutable properties such as arrays or tuples.
408
+ To work around these limitations, you might need to use the rule's options.
409
+ In particular, the [`allow` option](#allow) can explicitly mark a type as readonly.
@@ -9,6 +9,16 @@ import TabItem from '@theme/TabItem';
9
9
  >
10
10
  > See **https://typescript-eslint.io/rules/prefer-ts-expect-error** for documentation.
11
11
 
12
+ :::danger Deprecated
13
+
14
+ This rule has been deprecated in favor of [`@typescript-eslint/ban-ts-comment`](./ban-ts-comment.mdx).
15
+ This rule (`@typescript-eslint/prefer-ts-expect-error`) will be removed in a future major version of typescript-eslint.
16
+
17
+ When it was first created, `@typescript-eslint/ban-ts-comment` rule was only responsible for suggesting to remove `@ts-ignore` directive.
18
+ It was later updated to suggest replacing `@ts-ignore` with `@ts-expect-error` directive, so that it replaces `@typescript-eslint/prefer-ts-expect-error` entirely.
19
+
20
+ :::
21
+
12
22
  TypeScript allows you to suppress all errors on a line by placing a comment starting with `@ts-ignore` or `@ts-expect-error` immediately before the erroring line.
13
23
  The two directives work the same, except `@ts-expect-error` causes a type error if placed before a line that's not erroring in the first place.
14
24
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: 'Disallow async functions which have no `await` expression.'
2
+ description: 'Disallow async functions which do not return promises and have no `await` expression.'
3
3
  ---
4
4
 
5
5
  import Tabs from '@theme/Tabs';
@@ -10,7 +10,7 @@ import TabItem from '@theme/TabItem';
10
10
  > See **https://typescript-eslint.io/rules/require-await** for documentation.
11
11
 
12
12
  This rule extends the base [`eslint/require-await`](https://eslint.org/docs/rules/require-await) rule.
13
- It uses type information to add support for `async` functions that return a `Promise`.
13
+ It uses type information to allow promise-returning functions to be marked as `async` without containing an `await` expression.
14
14
 
15
15
  ## Examples
16
16
 
@@ -10,7 +10,7 @@ import TabItem from '@theme/TabItem';
10
10
  > See **https://typescript-eslint.io/rules/restrict-template-expressions** for documentation.
11
11
 
12
12
  JavaScript automatically [converts an object to a string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#string_coercion) in a string context, such as when concatenating it with a string using `+` or embedding it in a template literal using `${}`.
13
- The default `toString()` method of objects returns `"[object Object]"`, which is often not what was intended.
13
+ The default `toString()` method of objects uses the format `"[object Object]"`, which is often not what was intended.
14
14
  This rule reports on values used in a template literal string that aren't strings, optionally allowing other data types that provide useful stringification results.
15
15
 
16
16
  :::note
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: 'Enforce consistent returning of awaited values.'
2
+ description: 'Enforce consistent awaiting of returned promises.'
3
3
  ---
4
4
 
5
5
  import Tabs from '@theme/Tabs';
@@ -9,30 +9,53 @@ import TabItem from '@theme/TabItem';
9
9
  >
10
10
  > See **https://typescript-eslint.io/rules/return-await** for documentation.
11
11
 
12
- Returning an awaited promise can make sense for better stack trace information as well as for consistent error handling (returned promises will not be caught in an async function try/catch).
13
-
14
12
  This rule builds on top of the [`eslint/no-return-await`](https://eslint.org/docs/rules/no-return-await) rule.
15
13
  It expands upon the base rule to add support for optionally requiring `return await` in certain cases.
16
14
 
17
- The extended rule is named `return-await` instead of `no-return-await` because the extended rule can enforce the positive or the negative. Additionally, while the core rule is now deprecated, the extended rule is still useful in many contexts.
15
+ The extended rule is named `return-await` instead of `no-return-await` because the extended rule can enforce the positive or the negative. Additionally, while the core rule is now deprecated, the extended rule is still useful in many contexts:
16
+
17
+ - Returning an awaited promise [improves stack trace information](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await#improving_stack_trace).
18
+ - When the `return` statement is in `try...catch`, awaiting the promise also allows the promise's rejection to be caught instead of leaving the error to the caller.
19
+ - Contrary to popular belief, `return await promise;` is [at least as fast as directly returning the promise](https://github.com/tc39/proposal-faster-promise-adoption).
18
20
 
19
21
  ## Options
20
22
 
21
23
  ```ts
22
- type Options = 'in-try-catch' | 'always' | 'never';
24
+ type Options =
25
+ | 'in-try-catch'
26
+ | 'always'
27
+ | 'error-handling-correctness-only'
28
+ | 'never';
23
29
 
24
30
  const defaultOptions: Options = 'in-try-catch';
25
31
  ```
26
32
 
33
+ The options in this rule distinguish between "ordinary contexts" and "error-handling contexts".
34
+ An error-handling context is anywhere where returning an unawaited promise would cause unexpected control flow regarding exceptions/rejections.
35
+ See detailed examples in the sections for each option.
36
+
37
+ - If you return a promise within a `try` block, it should be awaited in order to trigger subsequent `catch` or `finally` blocks as expected.
38
+ - If you return a promise within a `catch` block, and there _is_ a `finally` block, it should be awaited in order to trigger the `finally` block as expected.
39
+ - If you return a promise between a `using` or `await using` declaration and the end of its scope, it should be awaited, since it behaves equivalently to code wrapped in a `try` block followed by a `finally`.
40
+
41
+ Ordinary contexts are anywhere else a promise may be returned.
42
+ The choice of whether to await a returned promise in an ordinary context is mostly stylistic.
43
+
44
+ With these terms defined, the options may be summarized as follows:
45
+
46
+ | Option | Ordinary Context <br/> (stylistic preference 🎨) | Error-Handling Context <br/> (catches bugs 🐛) | Should I use this option? |
47
+ | :-------------------------------: | :----------------------------------------------: | :----------------------------------------------------------: | :--------------------------------------------------------: |
48
+ | `always` | `return await promise;` | `return await promise;` | ✅ Yes! |
49
+ | `in-try-catch` | `return promise;` | `return await promise;` | ✅ Yes! |
50
+ | `error-handling-correctness-only` | don't care 🤷 | `return await promise;` | 🟡 Okay to use, but the above options would be preferable. |
51
+ | `never` | `return promise;` | `return promise;` <br/> (⚠️ This behavior may be harmful ⚠️) | ❌ No. This option is deprecated. |
52
+
27
53
  ### `in-try-catch`
28
54
 
29
- Requires that a returned promise must be `await`ed in `try-catch-finally` blocks, and disallows it elsewhere.
30
- Specifically:
55
+ In error-handling contexts, the rule enforces that returned promises must be awaited.
56
+ In ordinary contexts, the rule enforces that returned promises _must not_ be awaited.
31
57
 
32
- - if you `return` a promise within a `try`, then it must be `await`ed.
33
- - if you `return` a promise within a `catch`, and there **_is no_** `finally`, then it **_must not_** be `await`ed.
34
- - if you `return` a promise within a `catch`, and there **_is a_** `finally`, then it **_must_** be `await`ed.
35
- - if you `return` a promise within a `finally`, then it **_must not_** be `await`ed.
58
+ This is a good option if you prefer the shorter `return promise` form for stylistic reasons, wherever it's safe to use.
36
59
 
37
60
  Examples of code with `in-try-catch`:
38
61
 
@@ -42,23 +65,34 @@ Examples of code with `in-try-catch`:
42
65
  ```ts option='"in-try-catch"'
43
66
  async function invalidInTryCatch1() {
44
67
  try {
45
- return Promise.resolve('try');
46
- } catch (e) {}
68
+ return Promise.reject('try');
69
+ } catch (e) {
70
+ // Doesn't execute due to missing await.
71
+ }
47
72
  }
48
73
 
49
74
  async function invalidInTryCatch2() {
50
75
  try {
51
76
  throw new Error('error');
52
77
  } catch (e) {
53
- return await Promise.resolve('catch');
78
+ // Unnecessary await; rejections here don't impact control flow.
79
+ return await Promise.reject('catch');
54
80
  }
55
81
  }
56
82
 
83
+ // Prints 'starting async work', 'cleanup', 'async work done'.
57
84
  async function invalidInTryCatch3() {
85
+ async function doAsyncWork(): Promise<void> {
86
+ console.log('starting async work');
87
+ await new Promise(resolve => setTimeout(resolve, 1000));
88
+ console.log('async work done');
89
+ }
90
+
58
91
  try {
59
92
  throw new Error('error');
60
93
  } catch (e) {
61
- return Promise.resolve('catch');
94
+ // Missing await.
95
+ return doAsyncWork();
62
96
  } finally {
63
97
  console.log('cleanup');
64
98
  }
@@ -70,7 +104,8 @@ async function invalidInTryCatch4() {
70
104
  } catch (e) {
71
105
  throw new Error('error2');
72
106
  } finally {
73
- return await Promise.resolve('finally');
107
+ // Unnecessary await; rejections here don't impact control flow.
108
+ return await Promise.reject('finally');
74
109
  }
75
110
  }
76
111
 
@@ -81,6 +116,11 @@ async function invalidInTryCatch5() {
81
116
  async function invalidInTryCatch6() {
82
117
  return await 'value';
83
118
  }
119
+
120
+ async function invalidInTryCatch7() {
121
+ using x = createDisposable();
122
+ return Promise.reject('using in scope');
123
+ }
84
124
  ```
85
125
 
86
126
  </TabItem>
@@ -89,23 +129,32 @@ async function invalidInTryCatch6() {
89
129
  ```ts option='"in-try-catch"'
90
130
  async function validInTryCatch1() {
91
131
  try {
92
- return await Promise.resolve('try');
93
- } catch (e) {}
132
+ return await Promise.reject('try');
133
+ } catch (e) {
134
+ // Executes as expected.
135
+ }
94
136
  }
95
137
 
96
138
  async function validInTryCatch2() {
97
139
  try {
98
140
  throw new Error('error');
99
141
  } catch (e) {
100
- return Promise.resolve('catch');
142
+ return Promise.reject('catch');
101
143
  }
102
144
  }
103
145
 
146
+ // Prints 'starting async work', 'async work done', 'cleanup'.
104
147
  async function validInTryCatch3() {
148
+ async function doAsyncWork(): Promise<void> {
149
+ console.log('starting async work');
150
+ await new Promise(resolve => setTimeout(resolve, 1000));
151
+ console.log('async work done');
152
+ }
153
+
105
154
  try {
106
155
  throw new Error('error');
107
156
  } catch (e) {
108
- return await Promise.resolve('catch');
157
+ return await doAsyncWork();
109
158
  } finally {
110
159
  console.log('cleanup');
111
160
  }
@@ -117,7 +166,7 @@ async function validInTryCatch4() {
117
166
  } catch (e) {
118
167
  throw new Error('error2');
119
168
  } finally {
120
- return Promise.resolve('finally');
169
+ return Promise.reject('finally');
121
170
  }
122
171
  }
123
172
 
@@ -128,6 +177,11 @@ async function validInTryCatch5() {
128
177
  async function validInTryCatch6() {
129
178
  return 'value';
130
179
  }
180
+
181
+ async function validInTryCatch7() {
182
+ using x = createDisposable();
183
+ return await Promise.reject('using in scope');
184
+ }
131
185
  ```
132
186
 
133
187
  </TabItem>
@@ -135,7 +189,9 @@ async function validInTryCatch6() {
135
189
 
136
190
  ### `always`
137
191
 
138
- Requires that all returned promises are `await`ed.
192
+ Requires that all returned promises be awaited.
193
+
194
+ This is a good option if you like the consistency of simply always awaiting promises, or prefer not having to consider the distinction between error-handling contexts and ordinary contexts.
139
195
 
140
196
  Examples of code with `always`:
141
197
 
@@ -180,9 +236,49 @@ async function validAlways3() {
180
236
  </TabItem>
181
237
  </Tabs>
182
238
 
239
+ ### `error-handling-correctness-only`
240
+
241
+ In error-handling contexts, the rule enforces that returned promises must be awaited.
242
+ In ordinary contexts, the rule does not enforce any particular behavior around whether returned promises are awaited.
243
+
244
+ This is a good option if you only want to benefit from rule's ability to catch control flow bugs in error-handling contexts, but don't want to enforce a particular style otherwise.
245
+
246
+ :::info
247
+ We recommend you configure either `in-try-catch` or `always` instead of this option.
248
+ While the choice of whether to await promises outside of error-handling contexts is mostly stylistic, it's generally best to be consistent.
249
+ :::
250
+
251
+ Examples of additional correct code with `error-handling-correctness-only`:
252
+
253
+ <Tabs>
254
+ <TabItem value="✅ Correct">
255
+
256
+ ```ts option='"error-handling-correctness-only"'
257
+ async function asyncFunction(): Promise<void> {
258
+ if (Math.random() < 0.5) {
259
+ return await Promise.resolve();
260
+ } else {
261
+ return Promise.resolve();
262
+ }
263
+ }
264
+ ```
265
+
266
+ </TabItem>
267
+ </Tabs>
268
+
183
269
  ### `never`
184
270
 
185
- Disallows all `await`ing any returned promises.
271
+ Disallows awaiting any returned promises.
272
+
273
+ :::warning
274
+
275
+ This option is deprecated and will be removed in a future major version of typescript-eslint.
276
+
277
+ The `never` option introduces undesirable behavior in error-handling contexts.
278
+ If you prefer to minimize returning awaited promises, consider instead using `in-try-catch` instead, which also generally bans returning awaited promises, but only where it is _safe_ not to await a promise.
279
+
280
+ See more details at [typescript-eslint#9433](https://github.com/typescript-eslint/typescript-eslint/issues/9433).
281
+ :::
186
282
 
187
283
  Examples of code with `never`:
188
284
 
@@ -9,6 +9,12 @@ import TabItem from '@theme/TabItem';
9
9
  >
10
10
  > See **https://typescript-eslint.io/rules/sort-type-constituents** for documentation.
11
11
 
12
+ :::danger Deprecated
13
+ This rule has been deprecated in favor of the [`perfectionist/sort-intersection-types`](https://perfectionist.dev/rules/sort-intersection-types) and [`perfectionist/sort-union-types`](https://perfectionist.dev/rules/sort-union-types) rules.
14
+
15
+ See [Docs: Deprecate sort-type-constituents in favor of eslint-plugin-perfectionist](https://github.com/typescript-eslint/typescript-eslint/issues/8915) and [eslint-plugin: Feature freeze naming and sorting stylistic rules](https://github.com/typescript-eslint/typescript-eslint/issues/8792) for more information.
16
+ :::
17
+
12
18
  Sorting union (`|`) and intersection (`&`) types can help:
13
19
 
14
20
  - keep your codebase standardized
@@ -19,15 +25,6 @@ This rule reports on any types that aren't sorted alphabetically.
19
25
 
20
26
  > Types are sorted case-insensitively and treating numbers like a human would, falling back to character code sorting in case of ties.
21
27
 
22
- :::note
23
- This rule is _feature frozen_: it will no longer receive new features such as new options.
24
- It still will accept bug and documentation fixes for its existing area of features.
25
-
26
- Stylistic rules that enforce naming and/or sorting conventions tend to grow incomprehensibly complex as increasingly obscure features are requested.
27
- This rule has reached the limit of what is reasonable for the typescript-eslint project to maintain.
28
- See [eslint-plugin: Feature freeze naming and sorting stylistic rules](https://github.com/typescript-eslint/typescript-eslint/issues/8792) for more information.
29
- :::
30
-
31
28
  ## Examples
32
29
 
33
30
  <Tabs>
@@ -97,6 +94,29 @@ type T4 =
97
94
 
98
95
  ## Options
99
96
 
97
+ ### `caseSensitive`
98
+
99
+ Whether to sort using case sensitive string comparisons.
100
+
101
+ Examples of code with `{ "caseSensitive": true }`:
102
+
103
+ <Tabs>
104
+ <TabItem value="❌ Incorrect">
105
+
106
+ ```ts option='{ "caseSensitive": true }'
107
+ type T = 'DeletedAt' | 'DeleteForever';
108
+ ```
109
+
110
+ </TabItem>
111
+ <TabItem value="✅ Correct">
112
+
113
+ ```ts option='{ "caseSensitive": true }'
114
+ type T = 'DeleteForever' | 'DeletedAt';
115
+ ```
116
+
117
+ </TabItem>
118
+ </Tabs>
119
+
100
120
  ### `checkIntersections`
101
121
 
102
122
  Whether to check intersection types (`&`).