@typescript-eslint/eslint-plugin 7.0.0-alpha.0 → 7.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 (484) hide show
  1. package/dist/configs/all.js +12 -40
  2. package/dist/configs/all.js.map +1 -1
  3. package/dist/configs/base.js +0 -6
  4. package/dist/configs/base.js.map +1 -1
  5. package/dist/configs/disable-type-checked.js +7 -1
  6. package/dist/configs/disable-type-checked.js.map +1 -1
  7. package/dist/configs/eslint-recommended-raw.js +40 -0
  8. package/dist/configs/eslint-recommended-raw.js.map +1 -0
  9. package/dist/configs/eslint-recommended.js +10 -27
  10. package/dist/configs/eslint-recommended.js.map +1 -1
  11. package/dist/configs/recommended-type-checked.js.map +1 -1
  12. package/dist/configs/recommended.js.map +1 -1
  13. package/dist/configs/strict-type-checked.js +4 -0
  14. package/dist/configs/strict-type-checked.js.map +1 -1
  15. package/dist/configs/strict.js.map +1 -1
  16. package/dist/configs/stylistic-type-checked.js.map +1 -1
  17. package/dist/configs/stylistic.js.map +1 -1
  18. package/dist/index.js +6 -0
  19. package/dist/index.js.map +1 -1
  20. package/dist/rules/adjacent-overload-signatures.js +31 -60
  21. package/dist/rules/adjacent-overload-signatures.js.map +1 -1
  22. package/dist/rules/array-type.js +7 -32
  23. package/dist/rules/array-type.js.map +1 -1
  24. package/dist/rules/await-thenable.js +15 -4
  25. package/dist/rules/await-thenable.js.map +1 -1
  26. package/dist/rules/ban-ts-comment.js +32 -34
  27. package/dist/rules/ban-ts-comment.js.map +1 -1
  28. package/dist/rules/ban-tslint-comment.js +5 -29
  29. package/dist/rules/ban-tslint-comment.js.map +1 -1
  30. package/dist/rules/ban-types.js +4 -27
  31. package/dist/rules/ban-types.js.map +1 -1
  32. package/dist/rules/block-spacing.js +11 -34
  33. package/dist/rules/block-spacing.js.map +1 -1
  34. package/dist/rules/brace-style.js +10 -9
  35. package/dist/rules/brace-style.js.map +1 -1
  36. package/dist/rules/class-literal-property-style.js +20 -31
  37. package/dist/rules/class-literal-property-style.js.map +1 -1
  38. package/dist/rules/class-methods-use-this.js +209 -0
  39. package/dist/rules/class-methods-use-this.js.map +1 -0
  40. package/dist/rules/comma-dangle.js +11 -31
  41. package/dist/rules/comma-dangle.js.map +1 -1
  42. package/dist/rules/comma-spacing.js +11 -12
  43. package/dist/rules/comma-spacing.js.map +1 -1
  44. package/dist/rules/consistent-generic-constructors.js +23 -25
  45. package/dist/rules/consistent-generic-constructors.js.map +1 -1
  46. package/dist/rules/consistent-indexed-object-style.js +10 -14
  47. package/dist/rules/consistent-indexed-object-style.js.map +1 -1
  48. package/dist/rules/consistent-type-assertions.js +36 -21
  49. package/dist/rules/consistent-type-assertions.js.map +1 -1
  50. package/dist/rules/consistent-type-definitions.js +14 -40
  51. package/dist/rules/consistent-type-definitions.js.map +1 -1
  52. package/dist/rules/consistent-type-exports.js +19 -39
  53. package/dist/rules/consistent-type-exports.js.map +1 -1
  54. package/dist/rules/consistent-type-imports.js +88 -101
  55. package/dist/rules/consistent-type-imports.js.map +1 -1
  56. package/dist/rules/default-param-last.js +1 -1
  57. package/dist/rules/default-param-last.js.map +1 -1
  58. package/dist/rules/dot-notation.js.map +1 -1
  59. package/dist/rules/enum-utils/shared.js +57 -6
  60. package/dist/rules/enum-utils/shared.js.map +1 -1
  61. package/dist/rules/explicit-function-return-type.js +6 -31
  62. package/dist/rules/explicit-function-return-type.js.map +1 -1
  63. package/dist/rules/explicit-member-accessibility.js +8 -32
  64. package/dist/rules/explicit-member-accessibility.js.map +1 -1
  65. package/dist/rules/explicit-module-boundary-types.js +11 -35
  66. package/dist/rules/explicit-module-boundary-types.js.map +1 -1
  67. package/dist/rules/func-call-spacing.js +12 -35
  68. package/dist/rules/func-call-spacing.js.map +1 -1
  69. package/dist/rules/indent.js +18 -42
  70. package/dist/rules/indent.js.map +1 -1
  71. package/dist/rules/index.js +16 -0
  72. package/dist/rules/index.js.map +1 -1
  73. package/dist/rules/init-declarations.js.map +1 -1
  74. package/dist/rules/key-spacing.js +27 -59
  75. package/dist/rules/key-spacing.js.map +1 -1
  76. package/dist/rules/keyword-spacing.js +9 -31
  77. package/dist/rules/keyword-spacing.js.map +1 -1
  78. package/dist/rules/lines-around-comment.js +24 -48
  79. package/dist/rules/lines-around-comment.js.map +1 -1
  80. package/dist/rules/lines-between-class-members.js +5 -26
  81. package/dist/rules/lines-between-class-members.js.map +1 -1
  82. package/dist/rules/max-params.js +67 -0
  83. package/dist/rules/max-params.js.map +1 -0
  84. package/dist/rules/member-delimiter-style.js +12 -34
  85. package/dist/rules/member-delimiter-style.js.map +1 -1
  86. package/dist/rules/member-ordering.js +48 -40
  87. package/dist/rules/member-ordering.js.map +1 -1
  88. package/dist/rules/method-signature-style.js +14 -38
  89. package/dist/rules/method-signature-style.js.map +1 -1
  90. package/dist/rules/naming-convention-utils/enums.js +13 -5
  91. package/dist/rules/naming-convention-utils/enums.js.map +1 -1
  92. package/dist/rules/naming-convention-utils/format.js.map +1 -1
  93. package/dist/rules/naming-convention-utils/parse-options.js +3 -25
  94. package/dist/rules/naming-convention-utils/parse-options.js.map +1 -1
  95. package/dist/rules/naming-convention-utils/schema.js +8 -33
  96. package/dist/rules/naming-convention-utils/schema.js.map +1 -1
  97. package/dist/rules/naming-convention-utils/validator.js +3 -26
  98. package/dist/rules/naming-convention-utils/validator.js.map +1 -1
  99. package/dist/rules/naming-convention.js +59 -60
  100. package/dist/rules/naming-convention.js.map +1 -1
  101. package/dist/rules/no-array-constructor.js +4 -27
  102. package/dist/rules/no-array-constructor.js.map +1 -1
  103. package/dist/rules/no-array-delete.js +81 -0
  104. package/dist/rules/no-array-delete.js.map +1 -0
  105. package/dist/rules/no-base-to-string.js +7 -7
  106. package/dist/rules/no-base-to-string.js.map +1 -1
  107. package/dist/rules/no-confusing-non-null-assertion.js +5 -30
  108. package/dist/rules/no-confusing-non-null-assertion.js.map +1 -1
  109. package/dist/rules/no-confusing-void-expression.js +33 -20
  110. package/dist/rules/no-confusing-void-expression.js.map +1 -1
  111. package/dist/rules/no-dupe-class-members.js +3 -37
  112. package/dist/rules/no-dupe-class-members.js.map +1 -1
  113. package/dist/rules/no-duplicate-enum-values.js +2 -25
  114. package/dist/rules/no-duplicate-enum-values.js.map +1 -1
  115. package/dist/rules/no-duplicate-type-constituents.js +7 -31
  116. package/dist/rules/no-duplicate-type-constituents.js.map +1 -1
  117. package/dist/rules/no-dynamic-delete.js +4 -5
  118. package/dist/rules/no-dynamic-delete.js.map +1 -1
  119. package/dist/rules/no-empty-function.js +9 -32
  120. package/dist/rules/no-empty-function.js.map +1 -1
  121. package/dist/rules/no-empty-interface.js +8 -33
  122. package/dist/rules/no-empty-interface.js.map +1 -1
  123. package/dist/rules/no-explicit-any.js +12 -36
  124. package/dist/rules/no-explicit-any.js.map +1 -1
  125. package/dist/rules/no-extra-non-null-assertion.js +2 -25
  126. package/dist/rules/no-extra-non-null-assertion.js.map +1 -1
  127. package/dist/rules/no-extra-parens.js +47 -86
  128. package/dist/rules/no-extra-parens.js.map +1 -1
  129. package/dist/rules/no-extra-semi.js +5 -37
  130. package/dist/rules/no-extra-semi.js.map +1 -1
  131. package/dist/rules/no-extraneous-class.js +2 -25
  132. package/dist/rules/no-extraneous-class.js.map +1 -1
  133. package/dist/rules/no-floating-promises.js +137 -54
  134. package/dist/rules/no-floating-promises.js.map +1 -1
  135. package/dist/rules/no-for-in-array.js +6 -6
  136. package/dist/rules/no-for-in-array.js.map +1 -1
  137. package/dist/rules/no-implied-eval.js +7 -7
  138. package/dist/rules/no-implied-eval.js.map +1 -1
  139. package/dist/rules/no-import-type-side-effects.js +4 -28
  140. package/dist/rules/no-import-type-side-effects.js.map +1 -1
  141. package/dist/rules/no-inferrable-types.js +12 -36
  142. package/dist/rules/no-inferrable-types.js.map +1 -1
  143. package/dist/rules/no-invalid-this.js +2 -10
  144. package/dist/rules/no-invalid-this.js.map +1 -1
  145. package/dist/rules/no-invalid-void-type.js +6 -30
  146. package/dist/rules/no-invalid-void-type.js.map +1 -1
  147. package/dist/rules/no-loop-func.js +4 -28
  148. package/dist/rules/no-loop-func.js.map +1 -1
  149. package/dist/rules/no-loss-of-precision.js +5 -32
  150. package/dist/rules/no-loss-of-precision.js.map +1 -1
  151. package/dist/rules/no-magic-numbers.js +5 -28
  152. package/dist/rules/no-magic-numbers.js.map +1 -1
  153. package/dist/rules/no-meaningless-void-operator.js +4 -5
  154. package/dist/rules/no-meaningless-void-operator.js.map +1 -1
  155. package/dist/rules/no-misused-new.js +2 -25
  156. package/dist/rules/no-misused-new.js.map +1 -1
  157. package/dist/rules/no-misused-promises.js +5 -5
  158. package/dist/rules/no-misused-promises.js.map +1 -1
  159. package/dist/rules/no-mixed-enums.js +6 -7
  160. package/dist/rules/no-mixed-enums.js.map +1 -1
  161. package/dist/rules/no-namespace.js +4 -29
  162. package/dist/rules/no-namespace.js.map +1 -1
  163. package/dist/rules/no-non-null-asserted-nullish-coalescing.js +5 -29
  164. package/dist/rules/no-non-null-asserted-nullish-coalescing.js.map +1 -1
  165. package/dist/rules/no-non-null-asserted-optional-chain.js +2 -25
  166. package/dist/rules/no-non-null-asserted-optional-chain.js.map +1 -1
  167. package/dist/rules/no-non-null-assertion.js +20 -46
  168. package/dist/rules/no-non-null-assertion.js.map +1 -1
  169. package/dist/rules/no-redeclare.js +7 -31
  170. package/dist/rules/no-redeclare.js.map +1 -1
  171. package/dist/rules/no-redundant-type-constituents.js +12 -13
  172. package/dist/rules/no-redundant-type-constituents.js.map +1 -1
  173. package/dist/rules/no-require-imports.js +30 -4
  174. package/dist/rules/no-require-imports.js.map +1 -1
  175. package/dist/rules/no-restricted-imports.js +100 -77
  176. package/dist/rules/no-restricted-imports.js.map +1 -1
  177. package/dist/rules/no-shadow.js +30 -56
  178. package/dist/rules/no-shadow.js.map +1 -1
  179. package/dist/rules/no-this-alias.js +2 -25
  180. package/dist/rules/no-this-alias.js.map +1 -1
  181. package/dist/rules/no-throw-literal.js +6 -36
  182. package/dist/rules/no-throw-literal.js.map +1 -1
  183. package/dist/rules/no-type-alias.js +2 -25
  184. package/dist/rules/no-type-alias.js.map +1 -1
  185. package/dist/rules/no-unnecessary-boolean-literal-compare.js +6 -7
  186. package/dist/rules/no-unnecessary-boolean-literal-compare.js.map +1 -1
  187. package/dist/rules/no-unnecessary-condition.js +62 -22
  188. package/dist/rules/no-unnecessary-condition.js.map +1 -1
  189. package/dist/rules/no-unnecessary-qualifier.js +8 -7
  190. package/dist/rules/no-unnecessary-qualifier.js.map +1 -1
  191. package/dist/rules/no-unnecessary-type-arguments.js +5 -6
  192. package/dist/rules/no-unnecessary-type-arguments.js.map +1 -1
  193. package/dist/rules/no-unnecessary-type-assertion.js +37 -32
  194. package/dist/rules/no-unnecessary-type-assertion.js.map +1 -1
  195. package/dist/rules/no-unnecessary-type-constraint.js +18 -6
  196. package/dist/rules/no-unnecessary-type-constraint.js.map +1 -1
  197. package/dist/rules/no-unsafe-argument.js +11 -11
  198. package/dist/rules/no-unsafe-argument.js.map +1 -1
  199. package/dist/rules/no-unsafe-assignment.js +15 -17
  200. package/dist/rules/no-unsafe-assignment.js.map +1 -1
  201. package/dist/rules/no-unsafe-call.js +5 -6
  202. package/dist/rules/no-unsafe-call.js.map +1 -1
  203. package/dist/rules/no-unsafe-declaration-merging.js +4 -27
  204. package/dist/rules/no-unsafe-declaration-merging.js.map +1 -1
  205. package/dist/rules/no-unsafe-enum-comparison.js +94 -45
  206. package/dist/rules/no-unsafe-enum-comparison.js.map +1 -1
  207. package/dist/rules/no-unsafe-member-access.js +8 -10
  208. package/dist/rules/no-unsafe-member-access.js.map +1 -1
  209. package/dist/rules/no-unsafe-return.js +15 -15
  210. package/dist/rules/no-unsafe-return.js.map +1 -1
  211. package/dist/rules/no-unsafe-unary-minus.js +68 -0
  212. package/dist/rules/no-unsafe-unary-minus.js.map +1 -0
  213. package/dist/rules/no-unused-expressions.js +10 -25
  214. package/dist/rules/no-unused-expressions.js.map +1 -1
  215. package/dist/rules/no-unused-vars.js +37 -79
  216. package/dist/rules/no-unused-vars.js.map +1 -1
  217. package/dist/rules/no-use-before-define.js +8 -35
  218. package/dist/rules/no-use-before-define.js.map +1 -1
  219. package/dist/rules/no-useless-constructor.js +3 -27
  220. package/dist/rules/no-useless-constructor.js.map +1 -1
  221. package/dist/rules/no-useless-empty-export.js +18 -36
  222. package/dist/rules/no-useless-empty-export.js.map +1 -1
  223. package/dist/rules/no-useless-template-literals.js +138 -0
  224. package/dist/rules/no-useless-template-literals.js.map +1 -0
  225. package/dist/rules/no-var-requires.js +36 -39
  226. package/dist/rules/no-var-requires.js.map +1 -1
  227. package/dist/rules/non-nullable-type-assertion-style.js +9 -8
  228. package/dist/rules/non-nullable-type-assertion-style.js.map +1 -1
  229. package/dist/rules/object-curly-spacing.js +20 -19
  230. package/dist/rules/object-curly-spacing.js.map +1 -1
  231. package/dist/rules/padding-line-between-statements.js +28 -54
  232. package/dist/rules/padding-line-between-statements.js.map +1 -1
  233. package/dist/rules/parameter-properties.js +4 -29
  234. package/dist/rules/parameter-properties.js.map +1 -1
  235. package/dist/rules/prefer-as-const.js +2 -25
  236. package/dist/rules/prefer-as-const.js.map +1 -1
  237. package/dist/rules/prefer-destructuring.js +200 -0
  238. package/dist/rules/prefer-destructuring.js.map +1 -0
  239. package/dist/rules/prefer-enum-initializers.js +3 -27
  240. package/dist/rules/prefer-enum-initializers.js.map +1 -1
  241. package/dist/rules/prefer-find.js +237 -0
  242. package/dist/rules/prefer-find.js.map +1 -0
  243. package/dist/rules/prefer-for-of.js +7 -32
  244. package/dist/rules/prefer-for-of.js.map +1 -1
  245. package/dist/rules/prefer-function-type.js +9 -32
  246. package/dist/rules/prefer-function-type.js.map +1 -1
  247. package/dist/rules/prefer-includes.js +2 -2
  248. package/dist/rules/prefer-includes.js.map +1 -1
  249. package/dist/rules/prefer-literal-enum-member.js.map +1 -1
  250. package/dist/rules/prefer-namespace-keyword.js +4 -28
  251. package/dist/rules/prefer-namespace-keyword.js.map +1 -1
  252. package/dist/rules/prefer-nullish-coalescing.js +42 -30
  253. package/dist/rules/prefer-nullish-coalescing.js.map +1 -1
  254. package/dist/rules/prefer-optional-chain-utils/analyzeChain.js +20 -22
  255. package/dist/rules/prefer-optional-chain-utils/analyzeChain.js.map +1 -1
  256. package/dist/rules/prefer-optional-chain-utils/compareNodes.js.map +1 -1
  257. package/dist/rules/prefer-optional-chain-utils/gatherLogicalOperands.js +8 -10
  258. package/dist/rules/prefer-optional-chain-utils/gatherLogicalOperands.js.map +1 -1
  259. package/dist/rules/prefer-optional-chain.js +9 -11
  260. package/dist/rules/prefer-optional-chain.js.map +1 -1
  261. package/dist/rules/prefer-promise-reject-errors.js +108 -0
  262. package/dist/rules/prefer-promise-reject-errors.js.map +1 -0
  263. package/dist/rules/prefer-readonly-parameter-types.js +8 -31
  264. package/dist/rules/prefer-readonly-parameter-types.js.map +1 -1
  265. package/dist/rules/prefer-readonly.js +61 -17
  266. package/dist/rules/prefer-readonly.js.map +1 -1
  267. package/dist/rules/prefer-reduce-type-parameter.js +6 -32
  268. package/dist/rules/prefer-reduce-type-parameter.js.map +1 -1
  269. package/dist/rules/prefer-regexp-exec.js +8 -10
  270. package/dist/rules/prefer-regexp-exec.js.map +1 -1
  271. package/dist/rules/prefer-return-this-type.js +2 -4
  272. package/dist/rules/prefer-return-this-type.js.map +1 -1
  273. package/dist/rules/prefer-string-starts-ends-with.js +44 -26
  274. package/dist/rules/prefer-string-starts-ends-with.js.map +1 -1
  275. package/dist/rules/prefer-ts-expect-error.js +3 -27
  276. package/dist/rules/prefer-ts-expect-error.js.map +1 -1
  277. package/dist/rules/promise-function-async.js +11 -12
  278. package/dist/rules/promise-function-async.js.map +1 -1
  279. package/dist/rules/quotes.js +5 -26
  280. package/dist/rules/quotes.js.map +1 -1
  281. package/dist/rules/require-array-sort-compare.js +17 -39
  282. package/dist/rules/require-array-sort-compare.js.map +1 -1
  283. package/dist/rules/require-await.js +22 -50
  284. package/dist/rules/require-await.js.map +1 -1
  285. package/dist/rules/restrict-plus-operands.js +7 -7
  286. package/dist/rules/restrict-plus-operands.js.map +1 -1
  287. package/dist/rules/restrict-template-expressions.js +11 -11
  288. package/dist/rules/restrict-template-expressions.js.map +1 -1
  289. package/dist/rules/return-await.js +12 -15
  290. package/dist/rules/return-await.js.map +1 -1
  291. package/dist/rules/semi.js +4 -25
  292. package/dist/rules/semi.js.map +1 -1
  293. package/dist/rules/sort-type-constituents.js +5 -30
  294. package/dist/rules/sort-type-constituents.js.map +1 -1
  295. package/dist/rules/space-before-blocks.js +8 -31
  296. package/dist/rules/space-before-blocks.js.map +1 -1
  297. package/dist/rules/space-before-function-paren.js +14 -39
  298. package/dist/rules/space-before-function-paren.js.map +1 -1
  299. package/dist/rules/space-infix-ops.js +18 -40
  300. package/dist/rules/space-infix-ops.js.map +1 -1
  301. package/dist/rules/strict-boolean-expressions.js +94 -85
  302. package/dist/rules/strict-boolean-expressions.js.map +1 -1
  303. package/dist/rules/switch-exhaustiveness-check.js +153 -50
  304. package/dist/rules/switch-exhaustiveness-check.js.map +1 -1
  305. package/dist/rules/triple-slash-reference.js +3 -27
  306. package/dist/rules/triple-slash-reference.js.map +1 -1
  307. package/dist/rules/type-annotation-spacing.js +17 -46
  308. package/dist/rules/type-annotation-spacing.js.map +1 -1
  309. package/dist/rules/typedef.js +6 -30
  310. package/dist/rules/typedef.js.map +1 -1
  311. package/dist/rules/unbound-method.js +21 -61
  312. package/dist/rules/unbound-method.js.map +1 -1
  313. package/dist/rules/unified-signatures.js +12 -37
  314. package/dist/rules/unified-signatures.js.map +1 -1
  315. package/dist/util/astUtils.js +4 -4
  316. package/dist/util/astUtils.js.map +1 -1
  317. package/dist/util/collectUnusedVariables.js +8 -9
  318. package/dist/util/collectUnusedVariables.js.map +1 -1
  319. package/dist/util/explicitReturnTypeUtils.js +43 -34
  320. package/dist/util/explicitReturnTypeUtils.js.map +1 -1
  321. package/dist/util/getESLintCoreRule.js +3 -31
  322. package/dist/util/getESLintCoreRule.js.map +1 -1
  323. package/dist/util/getFunctionHeadLoc.js +146 -36
  324. package/dist/util/getFunctionHeadLoc.js.map +1 -1
  325. package/dist/util/getOperatorPrecedence.js +1 -0
  326. package/dist/util/getOperatorPrecedence.js.map +1 -1
  327. package/dist/util/getStaticStringValue.js +46 -0
  328. package/dist/util/getStaticStringValue.js.map +1 -0
  329. package/dist/util/getStringLength.js.map +1 -1
  330. package/dist/util/getThisExpression.js +1 -1
  331. package/dist/util/getThisExpression.js.map +1 -1
  332. package/dist/util/getWrappedCode.js +8 -0
  333. package/dist/util/getWrappedCode.js.map +1 -0
  334. package/dist/util/getWrappingFixer.js +19 -5
  335. package/dist/util/getWrappingFixer.js.map +1 -1
  336. package/dist/util/index.js +1 -0
  337. package/dist/util/index.js.map +1 -1
  338. package/dist/util/isNodeEqual.js.map +1 -1
  339. package/dist/util/misc.js +5 -7
  340. package/dist/util/misc.js.map +1 -1
  341. package/dist/util/objectIterators.js.map +1 -1
  342. package/docs/rules/README.md +44 -7
  343. package/docs/rules/TEMPLATE.md +5 -1
  344. package/docs/rules/adjacent-overload-signatures.md +7 -1
  345. package/docs/rules/array-type.md +14 -6
  346. package/docs/rules/await-thenable.md +3 -1
  347. package/docs/rules/ban-ts-comment.md +12 -9
  348. package/docs/rules/ban-tslint-comment.md +3 -3
  349. package/docs/rules/ban-types.md +11 -62
  350. package/docs/rules/block-spacing.md +0 -2
  351. package/docs/rules/brace-style.md +0 -2
  352. package/docs/rules/camelcase.md +5 -2
  353. package/docs/rules/class-literal-property-style.md +5 -14
  354. package/docs/rules/class-methods-use-this.md +96 -0
  355. package/docs/rules/comma-dangle.md +0 -2
  356. package/docs/rules/comma-spacing.md +0 -2
  357. package/docs/rules/consistent-generic-constructors.md +7 -4
  358. package/docs/rules/consistent-indexed-object-style.md +12 -12
  359. package/docs/rules/consistent-type-assertions.md +27 -22
  360. package/docs/rules/consistent-type-definitions.md +12 -13
  361. package/docs/rules/consistent-type-exports.md +9 -4
  362. package/docs/rules/consistent-type-imports.md +9 -6
  363. package/docs/rules/default-param-last.md +16 -6
  364. package/docs/rules/dot-notation.md +10 -5
  365. package/docs/rules/explicit-function-return-type.md +31 -30
  366. package/docs/rules/explicit-member-accessibility.md +49 -36
  367. package/docs/rules/explicit-module-boundary-types.md +30 -31
  368. package/docs/rules/func-call-spacing.md +0 -2
  369. package/docs/rules/indent.md +0 -2
  370. package/docs/rules/init-declarations.md +0 -2
  371. package/docs/rules/key-spacing.md +1 -3
  372. package/docs/rules/keyword-spacing.md +1 -3
  373. package/docs/rules/lines-around-comment.md +0 -2
  374. package/docs/rules/lines-between-class-members.md +2 -10
  375. package/docs/rules/max-params.md +10 -0
  376. package/docs/rules/member-delimiter-style.md +4 -1
  377. package/docs/rules/member-ordering.md +278 -200
  378. package/docs/rules/method-signature-style.md +7 -4
  379. package/docs/rules/naming-convention.md +31 -16
  380. package/docs/rules/no-array-constructor.md +0 -6
  381. package/docs/rules/no-array-delete.md +40 -0
  382. package/docs/rules/no-base-to-string.md +2 -2
  383. package/docs/rules/no-confusing-void-expression.md +3 -3
  384. package/docs/rules/no-dupe-class-members.md +3 -1
  385. package/docs/rules/no-duplicate-enum-values.md +8 -0
  386. package/docs/rules/no-duplicate-imports.md +5 -2
  387. package/docs/rules/no-duplicate-type-constituents.md +7 -2
  388. package/docs/rules/no-dynamic-delete.md +1 -1
  389. package/docs/rules/no-empty-function.md +13 -9
  390. package/docs/rules/no-empty-interface.md +2 -13
  391. package/docs/rules/no-explicit-any.md +28 -34
  392. package/docs/rules/no-extra-non-null-assertion.md +2 -0
  393. package/docs/rules/no-extra-parens.md +0 -2
  394. package/docs/rules/no-extra-semi.md +2 -2
  395. package/docs/rules/no-extraneous-class.md +10 -9
  396. package/docs/rules/no-floating-promises.md +24 -6
  397. package/docs/rules/no-for-in-array.md +13 -8
  398. package/docs/rules/no-implied-eval.md +2 -1
  399. package/docs/rules/no-import-type-side-effects.md +1 -2
  400. package/docs/rules/no-inferrable-types.md +4 -4
  401. package/docs/rules/no-invalid-this.md +3 -1
  402. package/docs/rules/no-invalid-void-type.md +5 -6
  403. package/docs/rules/no-loop-func.md +0 -2
  404. package/docs/rules/no-loss-of-precision.md +0 -2
  405. package/docs/rules/no-magic-numbers.md +14 -26
  406. package/docs/rules/no-meaningless-void-operator.md +6 -0
  407. package/docs/rules/no-misused-new.md +2 -1
  408. package/docs/rules/no-misused-promises.md +14 -13
  409. package/docs/rules/no-namespace.md +9 -7
  410. package/docs/rules/no-non-null-asserted-nullish-coalescing.md +5 -0
  411. package/docs/rules/no-non-null-asserted-optional-chain.md +5 -0
  412. package/docs/rules/no-non-null-assertion.md +2 -2
  413. package/docs/rules/no-parameter-properties.md +12 -0
  414. package/docs/rules/no-redeclare.md +5 -3
  415. package/docs/rules/no-redundant-type-constituents.md +14 -0
  416. package/docs/rules/no-require-imports.md +24 -1
  417. package/docs/rules/no-restricted-imports.md +24 -16
  418. package/docs/rules/no-shadow.md +15 -11
  419. package/docs/rules/no-this-alias.md +73 -3
  420. package/docs/rules/no-throw-literal.md +9 -11
  421. package/docs/rules/no-type-alias.md +55 -48
  422. package/docs/rules/no-unnecessary-boolean-literal-compare.md +5 -5
  423. package/docs/rules/no-unnecessary-condition.md +18 -2
  424. package/docs/rules/no-unnecessary-qualifier.md +1 -1
  425. package/docs/rules/no-unnecessary-type-arguments.md +7 -1
  426. package/docs/rules/no-unnecessary-type-assertion.md +2 -2
  427. package/docs/rules/no-unnecessary-type-constraint.md +1 -1
  428. package/docs/rules/no-unsafe-argument.md +12 -2
  429. package/docs/rules/no-unsafe-assignment.md +11 -1
  430. package/docs/rules/no-unsafe-call.md +10 -0
  431. package/docs/rules/no-unsafe-declaration-merging.md +5 -0
  432. package/docs/rules/no-unsafe-enum-comparison.md +15 -10
  433. package/docs/rules/no-unsafe-member-access.md +11 -1
  434. package/docs/rules/no-unsafe-return.md +11 -1
  435. package/docs/rules/no-unsafe-unary-minus.md +52 -0
  436. package/docs/rules/no-unused-expressions.md +0 -2
  437. package/docs/rules/no-unused-vars.md +17 -2
  438. package/docs/rules/no-use-before-define.md +4 -14
  439. package/docs/rules/no-useless-constructor.md +0 -2
  440. package/docs/rules/no-useless-empty-export.md +4 -0
  441. package/docs/rules/no-useless-template-literals.md +57 -0
  442. package/docs/rules/no-var-requires.md +24 -1
  443. package/docs/rules/non-nullable-type-assertion-style.md +1 -1
  444. package/docs/rules/object-curly-spacing.md +0 -2
  445. package/docs/rules/padding-line-between-statements.md +3 -5
  446. package/docs/rules/parameter-properties.md +22 -19
  447. package/docs/rules/prefer-as-const.md +4 -1
  448. package/docs/rules/prefer-destructuring.md +91 -0
  449. package/docs/rules/prefer-enum-initializers.md +1 -1
  450. package/docs/rules/prefer-find.md +39 -0
  451. package/docs/rules/prefer-for-of.md +3 -5
  452. package/docs/rules/prefer-function-type.md +1 -1
  453. package/docs/rules/prefer-includes.md +1 -3
  454. package/docs/rules/prefer-literal-enum-member.md +6 -4
  455. package/docs/rules/prefer-namespace-keyword.md +1 -1
  456. package/docs/rules/prefer-nullish-coalescing.md +27 -15
  457. package/docs/rules/prefer-optional-chain.md +18 -17
  458. package/docs/rules/prefer-promise-reject-errors.md +50 -0
  459. package/docs/rules/prefer-readonly-parameter-types.md +58 -32
  460. package/docs/rules/prefer-readonly.md +19 -4
  461. package/docs/rules/prefer-reduce-type-parameter.md +3 -1
  462. package/docs/rules/prefer-string-starts-ends-with.md +2 -1
  463. package/docs/rules/prefer-ts-expect-error.md +1 -0
  464. package/docs/rules/promise-function-async.md +73 -0
  465. package/docs/rules/quotes.md +0 -2
  466. package/docs/rules/require-array-sort-compare.md +7 -7
  467. package/docs/rules/require-await.md +2 -2
  468. package/docs/rules/restrict-plus-operands.md +16 -16
  469. package/docs/rules/restrict-template-expressions.md +11 -7
  470. package/docs/rules/return-await.md +8 -8
  471. package/docs/rules/semi.md +0 -4
  472. package/docs/rules/sort-type-constituents.md +62 -0
  473. package/docs/rules/space-before-blocks.md +5 -4
  474. package/docs/rules/space-before-function-paren.md +0 -2
  475. package/docs/rules/strict-boolean-expressions.md +7 -0
  476. package/docs/rules/switch-exhaustiveness-check.md +127 -8
  477. package/docs/rules/triple-slash-reference.md +76 -25
  478. package/docs/rules/type-annotation-spacing.md +8 -8
  479. package/docs/rules/typedef.md +19 -19
  480. package/docs/rules/unbound-method.md +4 -2
  481. package/docs/rules/unified-signatures.md +11 -2
  482. package/index.d.ts +6 -2
  483. package/package.json +31 -23
  484. package/rules.d.ts +46 -0
@@ -0,0 +1,50 @@
1
+ ---
2
+ description: 'Require using Error objects as Promise rejection reasons.'
3
+ ---
4
+
5
+ > 🛑 This file is source code, not the primary documentation location! 🛑
6
+ >
7
+ > See **https://typescript-eslint.io/rules/prefer-promise-reject-errors** for documentation.
8
+
9
+ This rule extends the base [`eslint/prefer-promise-reject-errors`](https://eslint.org/docs/rules/prefer-promise-reject-errors) rule.
10
+ It uses type information to enforce that `Promise`s are only rejected with `Error` objects.
11
+
12
+ ## Examples
13
+
14
+ <!--tabs-->
15
+
16
+ ### ❌ Incorrect
17
+
18
+ ```ts
19
+ Promise.reject('error');
20
+
21
+ const err = new Error();
22
+ Promise.reject('an ' + err);
23
+
24
+ new Promise((resolve, reject) => reject('error'));
25
+
26
+ new Promise((resolve, reject) => {
27
+ const err = new Error();
28
+ reject('an ' + err);
29
+ });
30
+ ```
31
+
32
+ ### ✅ Correct
33
+
34
+ ```ts
35
+ Promise.reject(new Error());
36
+
37
+ class CustomError extends Error {
38
+ // ...
39
+ }
40
+ Promise.reject(new CustomError());
41
+
42
+ new Promise((resolve, reject) => reject(new Error()));
43
+
44
+ new Promise((resolve, reject) => {
45
+ class CustomError extends Error {
46
+ // ...
47
+ }
48
+ return reject(new CustomError());
49
+ });
50
+ ```
@@ -57,7 +57,7 @@ interface Foo {
57
57
  interface Foo {
58
58
  new (arg: string[]): void;
59
59
  }
60
- const x = { foo(arg: string[]): void; };
60
+ const x = { foo(arg: string[]): void {} };
61
61
  function foo(arg: string[]);
62
62
  type Foo = (arg: string[]) => void;
63
63
  interface Foo {
@@ -91,7 +91,7 @@ interface CustomFunction {
91
91
  }
92
92
  function custom2(arg: CustomFunction) {}
93
93
 
94
- function union(arg: readonly string[] | ReadonlyArray<number[]>) {}
94
+ function union(arg: readonly string[] | ReadonlyArray<number>) {}
95
95
 
96
96
  function primitive1(arg: string) {}
97
97
  function primitive2(arg: number) {}
@@ -105,8 +105,11 @@ function primitive9(arg: string | number | undefined) {}
105
105
 
106
106
  function fnSig(arg: () => void) {}
107
107
 
108
- enum Foo { a, b }
109
- function enum(arg: Foo) {}
108
+ enum Foo {
109
+ a,
110
+ b,
111
+ }
112
+ function enumArg(arg: Foo) {}
110
113
 
111
114
  function symb1(arg: symbol) {}
112
115
  const customSymbol = Symbol('a');
@@ -119,7 +122,7 @@ interface Foo {
119
122
  interface Foo {
120
123
  new (arg: readonly string[]): void;
121
124
  }
122
- const x = { foo(arg: readonly string[]): void; };
125
+ const x = { foo(arg: readonly string[]): void {} };
123
126
  function foo(arg: readonly string[]);
124
127
  type Foo = (arg: readonly string[]) => void;
125
128
  interface Foo {
@@ -158,7 +161,7 @@ Examples of code for this rule with:
158
161
 
159
162
  #### ❌ Incorrect
160
163
 
161
- ```ts
164
+ ```ts option='{"allow":["$",{"source":"file","name":"Foo"},{"source":"lib","name":"HTMLElement"},{"from":"package","name":"Bar","package":"bar-lib"}]}'
162
165
  interface ThisIsMutable {
163
166
  prop: string;
164
167
  }
@@ -172,12 +175,17 @@ interface WrapperWithOther {
172
175
  otherProp: string;
173
176
  }
174
177
 
175
- function fn1(arg: ThisIsMutable) {} // Incorrect because ThisIsMutable is not readonly
176
- function fn2(arg: Wrapper) {} // Incorrect because Wrapper.sub is not readonly
177
- function fn3(arg: WrapperWithOther) {} // Incorrect because WrapperWithOther.otherProp is not readonly and not in the allowlist
178
+ // Incorrect because ThisIsMutable is not readonly
179
+ function fn1(arg: ThisIsMutable) {}
180
+
181
+ // Incorrect because Wrapper.sub is not readonly
182
+ function fn2(arg: Wrapper) {}
183
+
184
+ // Incorrect because WrapperWithOther.otherProp is not readonly and not in the allowlist
185
+ function fn3(arg: WrapperWithOther) {}
178
186
  ```
179
187
 
180
- ```ts
188
+ ```ts option='{"allow":["$",{"source":"file","name":"Foo"},{"source":"lib","name":"HTMLElement"},{"from":"package","name":"Bar","package":"bar-lib"}]}'
181
189
  import { Foo } from 'some-lib';
182
190
  import { Bar } from 'incorrect-lib';
183
191
 
@@ -185,14 +193,19 @@ interface HTMLElement {
185
193
  prop: string;
186
194
  }
187
195
 
188
- function fn1(arg: Foo) {} // Incorrect because Foo is not a local type
189
- function fn2(arg: HTMLElement) {} // Incorrect because HTMLElement is not from the default library
190
- function fn3(arg: Bar) {} // Incorrect because Bar is not from "bar-lib"
196
+ // Incorrect because Foo is not a local type
197
+ function fn1(arg: Foo) {}
198
+
199
+ // Incorrect because HTMLElement is not from the default library
200
+ function fn2(arg: HTMLElement) {}
201
+
202
+ // Incorrect because Bar is not from "bar-lib"
203
+ function fn3(arg: Bar) {}
191
204
  ```
192
205
 
193
206
  #### ✅ Correct
194
207
 
195
- ```ts
208
+ ```ts option='{"allow":["$",{"source":"file","name":"Foo"},{"source":"lib","name":"HTMLElement"},{"from":"package","name":"Bar","package":"bar-lib"}]}'
196
209
  interface Foo {
197
210
  prop: string;
198
211
  }
@@ -202,26 +215,35 @@ interface Wrapper {
202
215
  readonly otherProp: string;
203
216
  }
204
217
 
205
- function fn1(arg: Foo) {} // Works because Foo is allowed
206
- function fn2(arg: Wrapper) {} // Works even when Foo is nested somewhere in the type, with other properties still being checked
218
+ // Works because Foo is allowed
219
+ function fn1(arg: Foo) {}
220
+
221
+ // Works even when Foo is nested somewhere in the type, with other properties still being checked
222
+ function fn2(arg: Wrapper) {}
207
223
  ```
208
224
 
209
- ```ts
225
+ ```ts option='{"allow":["$",{"source":"file","name":"Foo"},{"source":"lib","name":"HTMLElement"},{"from":"package","name":"Bar","package":"bar-lib"}]}'
210
226
  import { Bar } from 'bar-lib';
211
227
 
212
228
  interface Foo {
213
229
  prop: string;
214
230
  }
215
231
 
216
- function fn1(arg: Foo) {} // Works because Foo is a local type
217
- function fn2(arg: HTMLElement) {} // Works because HTMLElement is from the default library
218
- function fn3(arg: Bar) {} // Works because Bar is from "bar-lib"
232
+ // Works because Foo is a local type
233
+ function fn1(arg: Foo) {}
234
+
235
+ // Works because HTMLElement is from the default library
236
+ function fn2(arg: HTMLElement) {}
237
+
238
+ // Works because Bar is from "bar-lib"
239
+ function fn3(arg: Bar) {}
219
240
  ```
220
241
 
221
- ```ts
242
+ ```ts option='{"allow":["$",{"source":"file","name":"Foo"},{"source":"lib","name":"HTMLElement"},{"from":"package","name":"Bar","package":"bar-lib"}]}'
222
243
  import { Foo } from './foo';
223
244
 
224
- function fn(arg: Foo) {} // Works because Foo is still a local type - it has to be in the same package
245
+ // Works because Foo is still a local type - it has to be in the same package
246
+ function fn(arg: Foo) {}
225
247
  ```
226
248
 
227
249
  ### `checkParameterProperties`
@@ -235,7 +257,7 @@ Examples of code for this rule with `{checkParameterProperties: true}`:
235
257
 
236
258
  #### ❌ Incorrect
237
259
 
238
- ```ts
260
+ ```ts option='{ "checkParameterProperties": true }'
239
261
  class Foo {
240
262
  constructor(private paramProp: string[]) {}
241
263
  }
@@ -243,7 +265,7 @@ class Foo {
243
265
 
244
266
  #### ✅ Correct
245
267
 
246
- ```ts
268
+ ```ts option='{ "checkParameterProperties": true }'
247
269
  class Foo {
248
270
  constructor(private paramProp: readonly string[]) {}
249
271
  }
@@ -253,7 +275,7 @@ class Foo {
253
275
 
254
276
  Examples of **correct** code for this rule with `{checkParameterProperties: false}`:
255
277
 
256
- ```ts
278
+ ```ts option='{ "checkParameterProperties": false }' showPlaygroundButton
257
279
  class Foo {
258
280
  constructor(
259
281
  private paramProp1: string[],
@@ -272,7 +294,7 @@ Examples of code for this rule with `{ignoreInferredTypes: true}`:
272
294
 
273
295
  #### ❌ Incorrect
274
296
 
275
- ```ts
297
+ ```ts option='{ "ignoreInferredTypes": true }'
276
298
  import { acceptsCallback, CallbackOptions } from 'external-dependency';
277
299
 
278
300
  acceptsCallback((options: CallbackOptions) => {});
@@ -281,7 +303,7 @@ acceptsCallback((options: CallbackOptions) => {});
281
303
  <details>
282
304
  <summary>external-dependency.d.ts</summary>
283
305
 
284
- ```ts
306
+ ```ts option='{ "ignoreInferredTypes": true }'
285
307
  export interface CallbackOptions {
286
308
  prop: string;
287
309
  }
@@ -295,7 +317,7 @@ export const acceptsCallback: AcceptsCallback;
295
317
 
296
318
  #### ✅ Correct
297
319
 
298
- ```ts
320
+ ```ts option='{ "ignoreInferredTypes": true }'
299
321
  import { acceptsCallback } from 'external-dependency';
300
322
 
301
323
  acceptsCallback(options => {});
@@ -304,7 +326,7 @@ acceptsCallback(options => {});
304
326
  <details>
305
327
  <summary>external-dependency.d.ts</summary>
306
328
 
307
- ```ts
329
+ ```ts option='{ "ignoreInferredTypes": true }'
308
330
  export interface CallbackOptions {
309
331
  prop: string;
310
332
  }
@@ -326,7 +348,7 @@ Examples of code for this rule with `{treatMethodsAsReadonly: false}`:
326
348
 
327
349
  #### ❌ Incorrect
328
350
 
329
- ```ts
351
+ ```ts option='{ "treatMethodsAsReadonly": false }'
330
352
  type MyType = {
331
353
  readonly prop: string;
332
354
  method(): string; // note: this method is mutable
@@ -336,7 +358,7 @@ function foo(arg: MyType) {}
336
358
 
337
359
  #### ✅ Correct
338
360
 
339
- ```ts
361
+ ```ts option='{ "treatMethodsAsReadonly": false }'
340
362
  type MyType = Readonly<{
341
363
  prop: string;
342
364
  method(): string;
@@ -354,10 +376,14 @@ function bar(arg: MyOtherType) {}
354
376
 
355
377
  Examples of **correct** code for this rule with `{treatMethodsAsReadonly: true}`:
356
378
 
357
- ```ts
379
+ ```ts option='{ "treatMethodsAsReadonly": true }' showPlaygroundButton
358
380
  type MyType = {
359
381
  readonly prop: string;
360
382
  method(): string; // note: this method is mutable
361
383
  };
362
384
  function foo(arg: MyType) {}
363
385
  ```
386
+
387
+ ## When Not To Use It
388
+
389
+ If your project does not attempt to enforce strong immutability guarantees of parameters, you can avoid this rule.
@@ -6,7 +6,7 @@ description: "Require private members to be marked as `readonly` if they're neve
6
6
  >
7
7
  > See **https://typescript-eslint.io/rules/prefer-readonly** for documentation.
8
8
 
9
- Member variables with the privacy `private` are never permitted to be modified outside of their declaring class.
9
+ Private member variables (whether using the `private` modifier or private `#` fields) are never permitted to be modified outside of their declaring class.
10
10
  If that class never modifies their value, they may safely be marked as `readonly`.
11
11
 
12
12
  This rule reports on private members are marked as `readonly` if they're never modified outside of the constructor.
@@ -22,6 +22,7 @@ class Container {
22
22
  // These member variables could be marked as readonly
23
23
  private neverModifiedMember = true;
24
24
  private onlyModifiedInConstructor: number;
25
+ #neverModifiedPrivateField = 3;
25
26
 
26
27
  public constructor(
27
28
  onlyModifiedInConstructor: number,
@@ -49,6 +50,13 @@ class Container {
49
50
  public mutate() {
50
51
  this.modifiedLater = 'mutated';
51
52
  }
53
+
54
+ // This is modified later on by the class
55
+ #modifiedLaterPrivateField = 'unchanged';
56
+
57
+ public mutatePrivateField() {
58
+ this.#modifiedLaterPrivateField = 'mutated';
59
+ }
52
60
  }
53
61
  ```
54
62
 
@@ -60,7 +68,10 @@ You may pass `"onlyInlineLambdas": true` as a rule option within an object to re
60
68
 
61
69
  ```jsonc
62
70
  {
63
- "@typescript-eslint/prefer-readonly": ["error", { "onlyInlineLambdas": true }]
71
+ "@typescript-eslint/prefer-readonly": [
72
+ "error",
73
+ { "onlyInlineLambdas": true },
74
+ ],
64
75
  }
65
76
  ```
66
77
 
@@ -70,7 +81,7 @@ Example of code for the `{ "onlyInlineLambdas": true }` options:
70
81
 
71
82
  #### ❌ Incorrect
72
83
 
73
- ```ts
84
+ ```ts option='{ "onlyInlineLambdas": true }'
74
85
  class Container {
75
86
  private onClick = () => {
76
87
  /* ... */
@@ -80,8 +91,12 @@ class Container {
80
91
 
81
92
  #### ✅ Correct
82
93
 
83
- ```ts
94
+ ```ts option='{ "onlyInlineLambdas": true }'
84
95
  class Container {
85
96
  private neverModifiedPrivate = 'unchanged';
86
97
  }
87
98
  ```
99
+
100
+ ## When Not To Use It
101
+
102
+ If you aren't trying to enforce strong immutability guarantees, this rule may be too restrictive for your project.
@@ -55,4 +55,6 @@ It will suggest instead pass the asserted type to `Array#reduce` as a generic ty
55
55
 
56
56
  ## When Not To Use It
57
57
 
58
- If you don't want to use typechecking in your linting, you can't use this rule.
58
+ This rule can sometimes be difficult to work around when creating objects using a `.reduce`.
59
+ See [[prefer-reduce-type-parameter] unfixable reporting #3440](https://github.com/typescript-eslint/typescript-eslint/issues/3440) for more details.
60
+ 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.
@@ -54,4 +54,5 @@ foo.endsWith('bar');
54
54
 
55
55
  ## When Not To Use It
56
56
 
57
- If you don't mind that style, you can turn this rule off safely.
57
+ If you don't mind which style of string checking is used, you can turn this rule off safely.
58
+ However, keep in mind that inconsistent style can harm readability in a project.
@@ -63,6 +63,7 @@ const isOptionEnabled = (key: string): boolean => {
63
63
  ## When Not To Use It
64
64
 
65
65
  If you are compiling against multiple versions of TypeScript and using `@ts-ignore` to ignore version-specific type errors, this rule might get in your way.
66
+ 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.
66
67
 
67
68
  ## Further Reading
68
69
 
@@ -57,3 +57,76 @@ async function functionReturnsUnionWithPromiseImplicitly(p: boolean) {
57
57
  return p ? 'value' : Promise.resolve('value');
58
58
  }
59
59
  ```
60
+
61
+ ## Options
62
+
63
+ ### `allowAny`
64
+
65
+ Whether to ignore functions that return `any` and `unknown`.
66
+ If you want additional safety, consider turning this option off, as it makes the rule less able to catch incorrect Promise behaviors.
67
+
68
+ Examples of code with `{ "allowAny": false }`:
69
+
70
+ <!--tabs-->
71
+
72
+ #### ❌ Incorrect
73
+
74
+ ```ts option='{ "allowAny": false }'
75
+ const returnsAny = () => ({}) as any;
76
+ ```
77
+
78
+ #### ✅ Correct
79
+
80
+ ```ts option='{ "allowAny": false }'
81
+ const returnsAny = async () => ({}) as any;
82
+ ```
83
+
84
+ ### `allowedPromiseNames`
85
+
86
+ For projects that use constructs other than the global built-in `Promise` for asynchronous code.
87
+ This option allows specifying string names of classes or interfaces that cause a function to be checked as well.
88
+
89
+ Examples of code with `{ "allowedPromiseNames": ["Bluebird"] }`:
90
+
91
+ <!--tabs-->
92
+
93
+ #### ❌ Incorrect
94
+
95
+ ```ts option='{ "allowedPromiseNames": ["Bluebird"] }'
96
+ import { Bluebird } from 'bluebird';
97
+
98
+ const returnsBluebird = () => new Bluebird(() => {});
99
+ ```
100
+
101
+ #### ✅ Correct
102
+
103
+ ```ts option='{ "allowedPromiseNames": ["Bluebird"] }'
104
+ import { Bluebird } from 'bluebird';
105
+
106
+ const returnsBluebird = async () => new Bluebird(() => {});
107
+ ```
108
+
109
+ ### `checkArrowFunctions`
110
+
111
+ Whether to check arrow functions.
112
+ `true` by default, but can be set to `false` to ignore them.
113
+
114
+ ### `checkFunctionDeclarations`
115
+
116
+ Whether to check standalone function declarations.
117
+ `true` by default, but can be set to `false` to ignore them.
118
+
119
+ ### `checkFunctionExpressions`
120
+
121
+ Whether to check inline function expressions.
122
+ `true` by default, but can be set to `false` to ignore them.
123
+
124
+ ### `checkMethodDeclarations`
125
+
126
+ Whether to check methods on classes and object literals
127
+ `true` by default, but can be set to `false` to ignore them.
128
+
129
+ ## When Not To Use It
130
+
131
+ This rule can be difficult to enable on projects that use APIs which require functions to always be `async`.
132
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) along with filing issues on your dependencies for those specific situations instead of completely disabling this rule.
@@ -6,7 +6,5 @@ description: 'Enforce the consistent use of either backticks, double, or single
6
6
  >
7
7
  > See **https://typescript-eslint.io/rules/quotes** for documentation.
8
8
 
9
- ## Examples
10
-
11
9
  This rule extends the base [`eslint/quotes`](https://eslint.org/docs/rules/quotes) rule.
12
10
  It adds support for TypeScript features which allow quoted names, but not backtick quoted names.
@@ -1,12 +1,12 @@
1
1
  ---
2
- description: 'Require `Array#sort` calls to always provide a `compareFunction`.'
2
+ description: 'Require `Array#sort` and `Array#toSorted` calls to always provide a `compareFunction`.'
3
3
  ---
4
4
 
5
5
  > 🛑 This file is source code, not the primary documentation location! 🛑
6
6
  >
7
7
  > See **https://typescript-eslint.io/rules/require-array-sort-compare** for documentation.
8
8
 
9
- When called without a compare function, `Array#sort()` converts all non-undefined array elements into strings and then compares said strings based off their UTF-16 code units [[ECMA specification](https://www.ecma-international.org/ecma-262/9.0/#sec-sortcompare)].
9
+ When called without a compare function, `Array#sort()` and `Array#toSorted()` converts all non-undefined array elements into strings and then compares said strings based off their UTF-16 code units [[ECMA specification](https://www.ecma-international.org/ecma-262/9.0/#sec-sortcompare)].
10
10
 
11
11
  The result is that elements are sorted alphabetically, regardless of their type.
12
12
  For example, when sorting numbers, this results in a "10 before 2" order:
@@ -15,11 +15,11 @@ For example, when sorting numbers, this results in a "10 before 2" order:
15
15
  [1, 2, 3, 10, 20, 30].sort(); //→ [1, 10, 2, 20, 3, 30]
16
16
  ```
17
17
 
18
- This rule reports on any call to the `Array#sort()` method that doesn't provide a `compare` argument.
18
+ This rule reports on any call to the sort methods that do not provide a `compare` argument.
19
19
 
20
20
  ## Examples
21
21
 
22
- This rule aims to ensure all calls of the native `Array#sort` method provide a `compareFunction`, while ignoring calls to user-defined `sort` methods.
22
+ This rule aims to ensure all calls of the native sort methods provide a `compareFunction`, while ignoring calls to user-defined methods.
23
23
 
24
24
  <!--tabs-->
25
25
 
@@ -57,7 +57,7 @@ Examples of code for this rule with `{ ignoreStringArrays: true }`:
57
57
 
58
58
  #### ❌ Incorrect
59
59
 
60
- ```ts
60
+ ```ts option='{ "ignoreStringArrays": true }'
61
61
  const one = 1;
62
62
  const two = 2;
63
63
  const three = 3;
@@ -66,7 +66,7 @@ const three = 3;
66
66
 
67
67
  #### ✅ Correct
68
68
 
69
- ```ts
69
+ ```ts option='{ "ignoreStringArrays": true }'
70
70
  const one = '1';
71
71
  const two = '2';
72
72
  const three = '3';
@@ -75,4 +75,4 @@ const three = '3';
75
75
 
76
76
  ## When Not To Use It
77
77
 
78
- If you understand the language specification enough, and/or only ever sort arrays in a string-like manner, you can turn this rule off safely.
78
+ If you intentionally want your arrays to be always sorted in a string-like manner, you can turn this rule off safely.
@@ -6,11 +6,11 @@ description: 'Disallow async functions which have no `await` expression.'
6
6
  >
7
7
  > See **https://typescript-eslint.io/rules/require-await** for documentation.
8
8
 
9
- ## Examples
10
-
11
9
  This rule extends the base [`eslint/require-await`](https://eslint.org/docs/rules/require-await) rule.
12
10
  It uses type information to add support for `async` functions that return a `Promise`.
13
11
 
12
+ ## Examples
13
+
14
14
  Examples of **correct** code for this rule:
15
15
 
16
16
  ```ts
@@ -18,15 +18,15 @@ This rule reports when a `+` operation combines two values of different types, o
18
18
  ### ❌ Incorrect
19
19
 
20
20
  ```ts
21
- let foo = '5.5' + 5;
22
21
  let foo = 1n + 1;
22
+ let fn = (a: string, b: never) => a + b;
23
23
  ```
24
24
 
25
25
  ### ✅ Correct
26
26
 
27
27
  ```ts
28
- let foo = parseInt('5.5', 10) + 10;
29
28
  let foo = 1n + 1n;
29
+ let fn = (a: string, b: string) => a + b;
30
30
  ```
31
31
 
32
32
  ## Options
@@ -74,14 +74,14 @@ Examples of code for this rule with `{ allowAny: true }`:
74
74
 
75
75
  #### ❌ Incorrect
76
76
 
77
- ```ts
77
+ ```ts option='{ "allowAny": true }'
78
78
  let fn = (a: number, b: []) => a + b;
79
79
  let fn = (a: string, b: []) => a + b;
80
80
  ```
81
81
 
82
82
  #### ✅ Correct
83
83
 
84
- ```ts
84
+ ```ts option='{ "allowAny": true }'
85
85
  let fn = (a: number, b: any) => a + b;
86
86
  let fn = (a: string, b: any) => a + b;
87
87
  ```
@@ -94,14 +94,14 @@ Examples of code for this rule with `{ allowBoolean: true }`:
94
94
 
95
95
  #### ❌ Incorrect
96
96
 
97
- ```ts
97
+ ```ts option='{ "allowBoolean": true }'
98
98
  let fn = (a: number, b: unknown) => a + b;
99
99
  let fn = (a: string, b: unknown) => a + b;
100
100
  ```
101
101
 
102
102
  #### ✅ Correct
103
103
 
104
- ```ts
104
+ ```ts option='{ "allowBoolean": true }'
105
105
  let fn = (a: number, b: boolean) => a + b;
106
106
  let fn = (a: string, b: boolean) => a + b;
107
107
  ```
@@ -114,7 +114,7 @@ Examples of code for this rule with `{ allowNullish: true }`:
114
114
 
115
115
  #### ❌ Incorrect
116
116
 
117
- ```ts
117
+ ```ts option='{ "allowNullish": true }'
118
118
  let fn = (a: number, b: unknown) => a + b;
119
119
  let fn = (a: number, b: never) => a + b;
120
120
  let fn = (a: string, b: unknown) => a + b;
@@ -123,7 +123,7 @@ let fn = (a: string, b: never) => a + b;
123
123
 
124
124
  #### ✅ Correct
125
125
 
126
- ```ts
126
+ ```ts option='{ "allowNullish": true }'
127
127
  let fn = (a: number, b: undefined) => a + b;
128
128
  let fn = (a: number, b: null) => a + b;
129
129
  let fn = (a: string, b: undefined) => a + b;
@@ -138,14 +138,14 @@ Examples of code for this rule with `{ allowNumberAndString: true }`:
138
138
 
139
139
  #### ❌ Incorrect
140
140
 
141
- ```ts
141
+ ```ts option='{ "allowNumberAndString": true }'
142
142
  let fn = (a: number, b: unknown) => a + b;
143
143
  let fn = (a: number, b: never) => a + b;
144
144
  ```
145
145
 
146
146
  #### ✅ Correct
147
147
 
148
- ```ts
148
+ ```ts option='{ "allowNumberAndString": true }'
149
149
  let fn = (a: number, b: string) => a + b;
150
150
  let fn = (a: number, b: number | string) => a + b;
151
151
  ```
@@ -158,25 +158,25 @@ Examples of code for this rule with `{ allowRegExp: true }`:
158
158
 
159
159
  #### ❌ Incorrect
160
160
 
161
- ```ts
161
+ ```ts option='{ "allowRegExp": true }'
162
162
  let fn = (a: number, b: RegExp) => a + b;
163
163
  ```
164
164
 
165
165
  #### ✅ Correct
166
166
 
167
- ```ts
167
+ ```ts option='{ "allowRegExp": true }'
168
168
  let fn = (a: string, b: RegExp) => a + b;
169
169
  ```
170
170
 
171
171
  ### `skipCompoundAssignments`
172
172
 
173
- Examples of code for this rule with `{ skipCompoundAssignments: true }`:
173
+ Examples of code for this rule with `{ skipCompoundAssignments: false }`:
174
174
 
175
175
  <!--tabs-->
176
176
 
177
177
  #### ❌ Incorrect
178
178
 
179
- ```ts
179
+ ```ts option='{ "skipCompoundAssignments": true }'
180
180
  let foo: string | undefined;
181
181
  foo += 'some data';
182
182
 
@@ -186,7 +186,7 @@ bar += 0;
186
186
 
187
187
  #### ✅ Correct
188
188
 
189
- ```ts
189
+ ```ts option='{ "skipCompoundAssignments": true }'
190
190
  let foo: number = 0;
191
191
  foo += 1;
192
192
 
@@ -196,7 +196,7 @@ bar += 'test';
196
196
 
197
197
  ## When Not To Use It
198
198
 
199
- If you don't mind `"[object Object]"` in your strings, then you will not need this rule.
199
+ If you don't mind a risk of `"[object Object]"` or incorrect type coercions in your values, then you will not need this rule.
200
200
 
201
201
  ## Related To
202
202