@typescript-eslint/eslint-plugin 8.67.1-alpha.2 → 8.67.1-alpha.20

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 (236) hide show
  1. package/CHANGELOG.md +5880 -0
  2. package/dist/configs/eslint-recommended-raw.js +1 -0
  3. package/dist/configs/eslintrc/all.js +1 -0
  4. package/dist/configs/eslintrc/base.js +1 -0
  5. package/dist/configs/eslintrc/disable-type-checked.js +1 -0
  6. package/dist/configs/eslintrc/eslint-recommended.js +1 -0
  7. package/dist/configs/eslintrc/recommended-type-checked-only.js +1 -0
  8. package/dist/configs/eslintrc/recommended-type-checked.js +1 -0
  9. package/dist/configs/eslintrc/recommended.js +1 -0
  10. package/dist/configs/eslintrc/strict-type-checked-only.js +1 -0
  11. package/dist/configs/eslintrc/strict-type-checked.js +1 -0
  12. package/dist/configs/eslintrc/strict.js +1 -0
  13. package/dist/configs/eslintrc/stylistic-type-checked-only.js +1 -0
  14. package/dist/configs/eslintrc/stylistic-type-checked.js +1 -0
  15. package/dist/configs/eslintrc/stylistic.js +1 -0
  16. package/dist/configs/flat/all.js +1 -0
  17. package/dist/configs/flat/base.js +1 -0
  18. package/dist/configs/flat/disable-type-checked.js +1 -0
  19. package/dist/configs/flat/eslint-recommended.js +1 -0
  20. package/dist/configs/flat/recommended-type-checked-only.js +1 -0
  21. package/dist/configs/flat/recommended-type-checked.js +1 -0
  22. package/dist/configs/flat/recommended.js +1 -0
  23. package/dist/configs/flat/strict-type-checked-only.js +1 -0
  24. package/dist/configs/flat/strict-type-checked.js +1 -0
  25. package/dist/configs/flat/strict.js +1 -0
  26. package/dist/configs/flat/stylistic-type-checked-only.js +1 -0
  27. package/dist/configs/flat/stylistic-type-checked.js +1 -0
  28. package/dist/configs/flat/stylistic.js +1 -0
  29. package/dist/index.js +1 -0
  30. package/dist/raw-plugin.js +1 -0
  31. package/dist/rules/adjacent-overload-signatures.js +1 -0
  32. package/dist/rules/array-type.js +1 -0
  33. package/dist/rules/await-thenable.js +1 -0
  34. package/dist/rules/ban-ts-comment.js +1 -0
  35. package/dist/rules/ban-tslint-comment.js +1 -0
  36. package/dist/rules/class-literal-property-style.js +1 -0
  37. package/dist/rules/class-methods-use-this.js +1 -0
  38. package/dist/rules/consistent-generic-constructors.js +1 -0
  39. package/dist/rules/consistent-indexed-object-style.js +1 -0
  40. package/dist/rules/consistent-return.js +1 -0
  41. package/dist/rules/consistent-type-assertions.js +1 -0
  42. package/dist/rules/consistent-type-definitions.js +1 -0
  43. package/dist/rules/consistent-type-exports.js +1 -0
  44. package/dist/rules/consistent-type-imports.js +1 -0
  45. package/dist/rules/default-param-last.js +1 -0
  46. package/dist/rules/dot-notation.js +1 -0
  47. package/dist/rules/enum-utils/shared.js +1 -0
  48. package/dist/rules/explicit-function-return-type.js +1 -0
  49. package/dist/rules/explicit-member-accessibility.js +1 -0
  50. package/dist/rules/explicit-module-boundary-types.js +1 -0
  51. package/dist/rules/index.js +1 -0
  52. package/dist/rules/init-declarations.js +1 -0
  53. package/dist/rules/max-params.js +1 -0
  54. package/dist/rules/member-ordering.js +1 -0
  55. package/dist/rules/method-signature-style.js +1 -0
  56. package/dist/rules/naming-convention-utils/enums.js +1 -0
  57. package/dist/rules/naming-convention-utils/format.js +1 -0
  58. package/dist/rules/naming-convention-utils/index.js +1 -0
  59. package/dist/rules/naming-convention-utils/parse-options.js +1 -0
  60. package/dist/rules/naming-convention-utils/schema.js +1 -0
  61. package/dist/rules/naming-convention-utils/shared.js +1 -0
  62. package/dist/rules/naming-convention-utils/types.js +1 -0
  63. package/dist/rules/naming-convention-utils/validator.js +1 -0
  64. package/dist/rules/naming-convention.js +1 -0
  65. package/dist/rules/no-array-constructor.js +1 -0
  66. package/dist/rules/no-array-delete.js +1 -0
  67. package/dist/rules/no-base-to-string.js +1 -0
  68. package/dist/rules/no-confusing-non-null-assertion.js +1 -0
  69. package/dist/rules/no-confusing-void-expression.js +1 -0
  70. package/dist/rules/no-deprecated.js +1 -0
  71. package/dist/rules/no-dupe-class-members.js +1 -0
  72. package/dist/rules/no-duplicate-enum-values.js +1 -0
  73. package/dist/rules/no-duplicate-type-constituents.js +1 -0
  74. package/dist/rules/no-dynamic-delete.js +1 -0
  75. package/dist/rules/no-empty-function.js +1 -0
  76. package/dist/rules/no-empty-interface.js +1 -0
  77. package/dist/rules/no-empty-object-type.js +1 -0
  78. package/dist/rules/no-explicit-any.js +1 -0
  79. package/dist/rules/no-extra-non-null-assertion.js +1 -0
  80. package/dist/rules/no-extraneous-class.js +1 -0
  81. package/dist/rules/no-floating-promises.js +64 -55
  82. package/dist/rules/no-for-in-array.js +1 -0
  83. package/dist/rules/no-implied-eval.js +1 -0
  84. package/dist/rules/no-import-type-side-effects.js +1 -0
  85. package/dist/rules/no-inferrable-types.js +1 -0
  86. package/dist/rules/no-invalid-this.js +1 -0
  87. package/dist/rules/no-invalid-void-type.js +1 -0
  88. package/dist/rules/no-loop-func.js +1 -0
  89. package/dist/rules/no-loss-of-precision.js +1 -0
  90. package/dist/rules/no-magic-numbers.js +1 -0
  91. package/dist/rules/no-meaningless-void-operator.js +1 -0
  92. package/dist/rules/no-misused-new.js +1 -0
  93. package/dist/rules/no-misused-promises.js +1 -0
  94. package/dist/rules/no-misused-spread.js +1 -0
  95. package/dist/rules/no-mixed-enums.js +1 -0
  96. package/dist/rules/no-namespace.js +1 -0
  97. package/dist/rules/no-non-null-asserted-nullish-coalescing.js +1 -0
  98. package/dist/rules/no-non-null-asserted-optional-chain.js +1 -0
  99. package/dist/rules/no-non-null-assertion.js +1 -0
  100. package/dist/rules/no-redeclare.js +1 -0
  101. package/dist/rules/no-redundant-type-constituents.js +1 -0
  102. package/dist/rules/no-require-imports.js +1 -0
  103. package/dist/rules/no-restricted-imports.js +1 -0
  104. package/dist/rules/no-restricted-types.js +1 -0
  105. package/dist/rules/no-shadow.js +1 -0
  106. package/dist/rules/no-this-alias.js +1 -0
  107. package/dist/rules/no-type-alias.js +1 -0
  108. package/dist/rules/no-unnecessary-boolean-literal-compare.js +1 -0
  109. package/dist/rules/no-unnecessary-condition.js +1 -0
  110. package/dist/rules/no-unnecessary-parameter-property-assignment.js +1 -0
  111. package/dist/rules/no-unnecessary-qualifier.js +1 -0
  112. package/dist/rules/no-unnecessary-template-expression.js +1 -0
  113. package/dist/rules/no-unnecessary-type-arguments.js +1 -0
  114. package/dist/rules/no-unnecessary-type-assertion.d.ts +1 -2
  115. package/dist/rules/no-unnecessary-type-assertion.js +14 -39
  116. package/dist/rules/no-unnecessary-type-constraint.js +1 -0
  117. package/dist/rules/no-unnecessary-type-conversion.js +1 -0
  118. package/dist/rules/no-unnecessary-type-parameters.js +1 -0
  119. package/dist/rules/no-unsafe-argument.js +1 -0
  120. package/dist/rules/no-unsafe-assignment.js +1 -0
  121. package/dist/rules/no-unsafe-call.js +1 -0
  122. package/dist/rules/no-unsafe-declaration-merging.js +1 -0
  123. package/dist/rules/no-unsafe-enum-comparison.js +1 -0
  124. package/dist/rules/no-unsafe-function-type.js +1 -0
  125. package/dist/rules/no-unsafe-member-access.js +1 -0
  126. package/dist/rules/no-unsafe-return.js +1 -0
  127. package/dist/rules/no-unsafe-type-assertion.js +1 -0
  128. package/dist/rules/no-unsafe-unary-minus.js +1 -0
  129. package/dist/rules/no-unused-expressions.js +1 -0
  130. package/dist/rules/no-unused-private-class-members.js +1 -0
  131. package/dist/rules/no-unused-vars.js +1 -0
  132. package/dist/rules/no-use-before-define.js +1 -0
  133. package/dist/rules/no-useless-constructor.js +1 -0
  134. package/dist/rules/no-useless-default-assignment.js +1 -0
  135. package/dist/rules/no-useless-empty-export.js +1 -0
  136. package/dist/rules/no-var-requires.js +1 -0
  137. package/dist/rules/no-wrapper-object-types.js +1 -0
  138. package/dist/rules/non-nullable-type-assertion-style.js +1 -0
  139. package/dist/rules/only-throw-error.js +1 -0
  140. package/dist/rules/parameter-properties.js +1 -0
  141. package/dist/rules/prefer-as-const.js +1 -0
  142. package/dist/rules/prefer-destructuring.js +1 -0
  143. package/dist/rules/prefer-enum-initializers.js +1 -0
  144. package/dist/rules/prefer-find.js +1 -0
  145. package/dist/rules/prefer-for-of.js +1 -0
  146. package/dist/rules/prefer-function-type.js +1 -0
  147. package/dist/rules/prefer-includes.js +1 -0
  148. package/dist/rules/prefer-literal-enum-member.js +1 -0
  149. package/dist/rules/prefer-namespace-keyword.js +1 -0
  150. package/dist/rules/prefer-nullish-coalescing.js +1 -0
  151. package/dist/rules/prefer-optional-chain-utils/PreferOptionalChainOptions.js +1 -0
  152. package/dist/rules/prefer-optional-chain-utils/analyzeChain.js +1 -0
  153. package/dist/rules/prefer-optional-chain-utils/checkNullishAndReport.js +1 -0
  154. package/dist/rules/prefer-optional-chain-utils/compareNodes.js +1 -0
  155. package/dist/rules/prefer-optional-chain-utils/gatherLogicalOperands.js +1 -0
  156. package/dist/rules/prefer-optional-chain.js +1 -0
  157. package/dist/rules/prefer-promise-reject-errors.js +1 -0
  158. package/dist/rules/prefer-readonly-parameter-types.js +1 -0
  159. package/dist/rules/prefer-readonly.js +1 -0
  160. package/dist/rules/prefer-reduce-type-parameter.js +1 -0
  161. package/dist/rules/prefer-regexp-exec.js +1 -0
  162. package/dist/rules/prefer-return-this-type.js +1 -0
  163. package/dist/rules/prefer-string-starts-ends-with.js +1 -0
  164. package/dist/rules/prefer-ts-expect-error.js +1 -0
  165. package/dist/rules/promise-function-async.js +1 -0
  166. package/dist/rules/related-getter-setter-pairs.js +1 -0
  167. package/dist/rules/require-array-sort-compare.js +1 -0
  168. package/dist/rules/require-await.js +1 -0
  169. package/dist/rules/restrict-plus-operands.js +1 -0
  170. package/dist/rules/restrict-template-expressions.js +1 -0
  171. package/dist/rules/return-await.js +13 -1
  172. package/dist/rules/sort-type-constituents.js +1 -0
  173. package/dist/rules/strict-boolean-expressions.js +1 -0
  174. package/dist/rules/strict-void-return.js +1 -0
  175. package/dist/rules/switch-exhaustiveness-check.js +1 -0
  176. package/dist/rules/triple-slash-reference.js +1 -0
  177. package/dist/rules/typedef.js +1 -0
  178. package/dist/rules/unbound-method.js +1 -0
  179. package/dist/rules/unified-signatures.d.ts +1 -1
  180. package/dist/rules/unified-signatures.js +73 -32
  181. package/dist/rules/use-unknown-in-catch-callback-variable.js +1 -0
  182. package/dist/util/assertionFunctionUtils.js +1 -0
  183. package/dist/util/astUtils.js +1 -0
  184. package/dist/util/baseTypeUtils.js +1 -0
  185. package/dist/util/class-scope-analyzer/classScopeAnalyzer.js +1 -0
  186. package/dist/util/class-scope-analyzer/extractComputedName.js +1 -0
  187. package/dist/util/class-scope-analyzer/types.js +1 -0
  188. package/dist/util/collectUnusedVariables.js +1 -0
  189. package/dist/util/createRule.js +1 -0
  190. package/dist/util/escapeRegExp.js +1 -0
  191. package/dist/util/explicitReturnTypeUtils.js +1 -0
  192. package/dist/util/getBaseTypesOfClassMember.js +1 -0
  193. package/dist/util/getConstraintInfo.js +1 -0
  194. package/dist/util/getESLintCoreRule.js +1 -0
  195. package/dist/util/getFixOrSuggest.js +1 -0
  196. package/dist/util/getForStatementHeadLoc.js +1 -0
  197. package/dist/util/getFunctionHeadLoc.js +1 -0
  198. package/dist/util/getMemberHeadLoc.js +1 -0
  199. package/dist/util/getOperatorPrecedence.js +1 -0
  200. package/dist/util/getParentFunctionNode.js +1 -0
  201. package/dist/util/getStaticStringValue.js +1 -0
  202. package/dist/util/getStringLength.js +1 -0
  203. package/dist/util/getTextWithParentheses.js +1 -0
  204. package/dist/util/getThisExpression.js +1 -0
  205. package/dist/util/getValueOfLiteralType.js +1 -0
  206. package/dist/util/getWrappedCode.js +1 -0
  207. package/dist/util/getWrappingFixer.js +1 -0
  208. package/dist/util/hasOverloadSignatures.js +1 -0
  209. package/dist/util/index.d.ts +1 -0
  210. package/dist/util/index.js +2 -0
  211. package/dist/util/isArrayMethodCallWithPredicate.js +1 -0
  212. package/dist/util/isAssignee.js +1 -0
  213. package/dist/util/isConditionalTest.js +1 -0
  214. package/dist/util/isHigherPrecedenceThanAwait.js +1 -0
  215. package/dist/util/isNodeEqual.js +1 -0
  216. package/dist/util/isNullLiteral.js +1 -0
  217. package/dist/util/isPromiseAggregatorMethod.js +1 -0
  218. package/dist/util/isStartOfArrowFunctionBody.d.ts +2 -0
  219. package/dist/util/isStartOfArrowFunctionBody.js +26 -0
  220. package/dist/util/isStartOfExpressionStatement.js +1 -0
  221. package/dist/util/isTypeImport.js +1 -0
  222. package/dist/util/isUndefinedIdentifier.js +1 -0
  223. package/dist/util/misc.js +1 -0
  224. package/dist/util/needsPrecedingSemiColon.js +1 -0
  225. package/dist/util/needsToBeAwaited.js +1 -0
  226. package/dist/util/objectIterators.js +1 -0
  227. package/dist/util/promiseUtils.js +1 -0
  228. package/dist/util/rangeToLoc.js +1 -0
  229. package/dist/util/referenceContainsTypePredicate.js +1 -0
  230. package/dist/util/referenceContainsTypeQuery.js +1 -0
  231. package/dist/util/scopeUtils.js +1 -0
  232. package/dist/util/skipChainExpression.js +1 -0
  233. package/dist/util/truthinessUtils.js +1 -0
  234. package/dist/util/types.js +1 -0
  235. package/dist/util/walkStatements.js +1 -0
  236. package/package.json +12 -11
@@ -114,3 +114,4 @@ exports.default = (0, util_1.createRule)({
114
114
  };
115
115
  },
116
116
  });
117
+ //# sourceMappingURL=prefer-literal-enum-member.js.map
@@ -40,3 +40,4 @@ exports.default = (0, util_1.createRule)({
40
40
  };
41
41
  },
42
42
  });
43
+ //# sourceMappingURL=prefer-namespace-keyword.js.map
@@ -615,3 +615,4 @@ function formatComments(comments, separator) {
615
615
  : `/*${value}*/${separator}`)
616
616
  .join('');
617
617
  }
618
+ //# sourceMappingURL=prefer-nullish-coalescing.js.map
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=PreferOptionalChainOptions.js.map
@@ -612,3 +612,4 @@ function analyzeChain(context, parserServices, options, node, operator, chain, l
612
612
  // check the leftovers
613
613
  maybeReportThenReset();
614
614
  }
615
+ //# sourceMappingURL=analyzeChain.js.map
@@ -43,3 +43,4 @@ function checkNullishAndReport(context, parserServices, { requireNullish }, mayb
43
43
  context.report(descriptor);
44
44
  }
45
45
  }
46
+ //# sourceMappingURL=checkNullishAndReport.js.map
@@ -324,3 +324,4 @@ function compareNodes(nodeA, nodeB) {
324
324
  mapA.set(nodeB, result);
325
325
  return result;
326
326
  }
327
+ //# sourceMappingURL=compareNodes.js.map
@@ -409,3 +409,4 @@ function gatherLogicalOperands(node, parserServices, sourceCode, options) {
409
409
  return null;
410
410
  }
411
411
  }
412
+ //# sourceMappingURL=gatherLogicalOperands.js.map
@@ -148,3 +148,4 @@ exports.default = (0, util_1.createRule)({
148
148
  };
149
149
  },
150
150
  });
151
+ //# sourceMappingURL=prefer-optional-chain.js.map
@@ -122,3 +122,4 @@ exports.default = (0, util_1.createRule)({
122
122
  };
123
123
  },
124
124
  });
125
+ //# sourceMappingURL=prefer-promise-reject-errors.js.map
@@ -96,3 +96,4 @@ exports.default = (0, util_1.createRule)({
96
96
  };
97
97
  },
98
98
  });
99
+ //# sourceMappingURL=prefer-readonly-parameter-types.js.map
@@ -437,3 +437,4 @@ function getMemberName(name) {
437
437
  }
438
438
  return undefined;
439
439
  }
440
+ //# sourceMappingURL=prefer-readonly.js.map
@@ -112,3 +112,4 @@ exports.default = (0, util_1.createRule)({
112
112
  };
113
113
  },
114
114
  });
115
+ //# sourceMappingURL=prefer-reduce-type-parameter.js.map
@@ -180,3 +180,4 @@ exports.default = (0, util_1.createRule)({
180
180
  };
181
181
  },
182
182
  });
183
+ //# sourceMappingURL=prefer-regexp-exec.js.map
@@ -152,3 +152,4 @@ exports.default = (0, util_1.createRule)({
152
152
  };
153
153
  },
154
154
  });
155
+ //# sourceMappingURL=prefer-return-this-type.js.map
@@ -511,3 +511,4 @@ exports.default = (0, util_1.createRule)({
511
511
  };
512
512
  },
513
513
  });
514
+ //# sourceMappingURL=prefer-string-starts-ends-with.js.map
@@ -69,3 +69,4 @@ exports.default = (0, util_1.createRule)({
69
69
  };
70
70
  },
71
71
  });
72
+ //# sourceMappingURL=prefer-ts-expect-error.js.map
@@ -202,3 +202,4 @@ exports.default = (0, util_1.createRule)({
202
202
  };
203
203
  },
204
204
  });
205
+ //# sourceMappingURL=promise-function-async.js.map
@@ -69,3 +69,4 @@ exports.default = (0, util_1.createRule)({
69
69
  function getMethodFromNode(node) {
70
70
  return node.type === utils_1.AST_NODE_TYPES.TSMethodSignature ? node : node.value;
71
71
  }
72
+ //# sourceMappingURL=related-getter-setter-pairs.js.map
@@ -61,3 +61,4 @@ exports.default = (0, util_1.createRule)({
61
61
  };
62
62
  },
63
63
  });
64
+ //# sourceMappingURL=require-array-sort-compare.js.map
@@ -261,3 +261,4 @@ function hasTypeName(typeReference, typeName) {
261
261
  return (typeReference.typeName.type === utils_1.AST_NODE_TYPES.Identifier &&
262
262
  typeReference.typeName.name === typeName);
263
263
  }
264
+ //# sourceMappingURL=require-await.js.map
@@ -229,3 +229,4 @@ function isTypeFlagSetInUnion(type, flag) {
229
229
  .unionConstituents(type)
230
230
  .some(subType => tsutils.isTypeFlagSet(subType, flag));
231
231
  }
232
+ //# sourceMappingURL=restrict-plus-operands.js.map
@@ -117,3 +117,4 @@ exports.default = (0, util_1.createRule)({
117
117
  }
118
118
  },
119
119
  });
120
+ //# sourceMappingURL=restrict-template-expressions.js.map
@@ -220,7 +220,18 @@ exports.default = (0, util_1.createRule)({
220
220
  if (nextToken) {
221
221
  endAt = nextToken.range[0];
222
222
  }
223
- return fixer.removeRange([startAt, endAt]);
223
+ const awaitRemovalFix = fixer.removeRange([startAt, endAt]);
224
+ const firstOperandToken = (0, util_1.nullThrows)(context.sourceCode.getTokenAfter(awaitToken), util_1.NullThrowsReasons.MissingToken('operand', 'await expression'));
225
+ const shouldWrapInParentheses = (0, util_1.isOpeningBraceToken)(firstOperandToken) &&
226
+ (0, util_1.isStartOfArrowFunctionBody)(node, context.sourceCode);
227
+ if (shouldWrapInParentheses) {
228
+ return [
229
+ awaitRemovalFix,
230
+ fixer.insertTextBefore(node.argument, '('),
231
+ fixer.insertTextAfter(node.argument, ')'),
232
+ ];
233
+ }
234
+ return awaitRemovalFix;
224
235
  }
225
236
  function insertAwait(fixer, node, isHighPrecedence) {
226
237
  if (isHighPrecedence) {
@@ -361,3 +372,4 @@ function getConfiguration(option) {
361
372
  };
362
373
  }
363
374
  }
375
+ //# sourceMappingURL=return-await.js.map
@@ -270,3 +270,4 @@ exports.default = (0, util_1.createRule)({
270
270
  };
271
271
  },
272
272
  });
273
+ //# sourceMappingURL=sort-type-constituents.js.map
@@ -880,3 +880,4 @@ function isBrandedBoolean(type) {
880
880
  function isBooleanType(expressionType) {
881
881
  return tsutils.isTypeFlagSet(expressionType, ts.TypeFlags.Boolean | ts.TypeFlags.BooleanLiteral);
882
882
  }
883
+ //# sourceMappingURL=strict-boolean-expressions.js.map
@@ -375,3 +375,4 @@ exports.default = util.createRule({
375
375
  }
376
376
  },
377
377
  });
378
+ //# sourceMappingURL=strict-void-return.js.map
@@ -289,3 +289,4 @@ function doesTypeContainNonLiteralType(type) {
289
289
  .intersectionConstituents(type)
290
290
  .every(subType => !isTypeLiteralLikeType(subType)));
291
291
  }
292
+ //# sourceMappingURL=switch-exhaustiveness-check.js.map
@@ -108,3 +108,4 @@ exports.default = (0, util_1.createRule)({
108
108
  };
109
109
  },
110
110
  });
111
+ //# sourceMappingURL=triple-slash-reference.js.map
@@ -237,3 +237,4 @@ exports.default = (0, util_1.createRule)({
237
237
  };
238
238
  },
239
239
  });
240
+ //# sourceMappingURL=typedef.js.map
@@ -359,3 +359,4 @@ function isSafeUse(node) {
359
359
  }
360
360
  return false;
361
361
  }
362
+ //# sourceMappingURL=unbound-method.js.map
@@ -1,4 +1,4 @@
1
- export type MessageIds = 'omittingRestParameter' | 'omittingSingleParameter' | 'singleParameterDifference';
1
+ export type MessageIds = 'allParametersAreSame' | 'omittingRestParameter' | 'omittingSingleParameter' | 'singleParameterDifference';
2
2
  export type Options = [
3
3
  {
4
4
  ignoreDifferentlyNamedParameters?: boolean;
@@ -12,9 +12,10 @@ exports.default = (0, util_1.createRule)({
12
12
  recommended: 'strict',
13
13
  },
14
14
  messages: {
15
+ allParametersAreSame: '{{failureStringStart}} with identical parameters.',
15
16
  omittingRestParameter: '{{failureStringStart}} with a rest parameter.',
16
17
  omittingSingleParameter: '{{failureStringStart}} with an optional parameter.',
17
- singleParameterDifference: '{{failureStringStart}} taking `{{type1}} | {{type2}}`.',
18
+ singleParameterDifference: '{{failureStringStart}} taking `{{types}}`.',
18
19
  },
19
20
  schema: [
20
21
  {
@@ -57,20 +58,15 @@ exports.default = (0, util_1.createRule)({
57
58
  case 'single-parameter-difference': {
58
59
  const { p0, p1 } = unify;
59
60
  const lineOfOtherOverload = only2 ? undefined : p0.loc.start.line;
60
- const typeAnnotation0 = isTSParameterProperty(p0)
61
- ? p0.parameter.typeAnnotation
62
- : p0.typeAnnotation;
63
- const typeAnnotation1 = isTSParameterProperty(p1)
64
- ? p1.parameter.typeAnnotation
65
- : p1.typeAnnotation;
61
+ const typeAnnotation0 = getParameterTypeAnnotation(p0);
62
+ const typeAnnotation1 = getParameterTypeAnnotation(p1);
66
63
  context.report({
67
64
  loc: p1.loc,
68
65
  node: p1,
69
66
  messageId: 'singleParameterDifference',
70
67
  data: {
71
68
  failureStringStart: failureStringStart(lineOfOtherOverload),
72
- type1: context.sourceCode.getText(typeAnnotation0?.typeAnnotation),
73
- type2: context.sourceCode.getText(typeAnnotation1?.typeAnnotation),
69
+ types: getUnifiedTypeText(typeAnnotation0, typeAnnotation1),
74
70
  },
75
71
  });
76
72
  break;
@@ -90,7 +86,24 @@ exports.default = (0, util_1.createRule)({
90
86
  failureStringStart: failureStringStart(lineOfOtherOverload),
91
87
  },
92
88
  });
89
+ break;
90
+ }
91
+ case 'all-parameters-are-same': {
92
+ const { signature0, signature1 } = unify;
93
+ const lineOfOtherOverload = only2
94
+ ? undefined
95
+ : signature0.loc.start.line;
96
+ context.report({
97
+ node: signature1,
98
+ messageId: 'allParametersAreSame',
99
+ data: {
100
+ failureStringStart: failureStringStart(lineOfOtherOverload),
101
+ },
102
+ });
103
+ break;
93
104
  }
105
+ default:
106
+ unify;
94
107
  }
95
108
  }
96
109
  }
@@ -114,7 +127,7 @@ exports.default = (0, util_1.createRule)({
114
127
  return undefined;
115
128
  }
116
129
  return a.params.length === b.params.length
117
- ? signaturesDifferBySingleParameter(a.params, b.params)
130
+ ? signaturesHaveSameAmountOfParameters(a, b)
118
131
  : signaturesDifferByOptionalOrRestParameter(a, b);
119
132
  }
120
133
  function signaturesCanBeUnified(a, b, isTypeParameter) {
@@ -138,15 +151,20 @@ exports.default = (0, util_1.createRule)({
138
151
  return false;
139
152
  }
140
153
  }
141
- return (typesAreEqual(a.returnType, b.returnType) &&
154
+ return (typesAreEqual(a.returnType?.typeAnnotation, b.returnType?.typeAnnotation) &&
142
155
  // Must take the same type parameters.
143
156
  // If one uses a type parameter (from outside) and the other doesn't, they shouldn't be joined.
144
157
  (0, util_1.arraysAreEqual)(aTypeParams, bTypeParams, typeParametersAreEqual) &&
145
158
  signatureUsesTypeParameter(a, isTypeParameter) ===
146
159
  signatureUsesTypeParameter(b, isTypeParameter));
147
160
  }
148
- /** Detect `a(x: number, y: number, z: number)` and `a(x: number, y: string, z: number)`. */
149
- function signaturesDifferBySingleParameter(types1, types2) {
161
+ /**
162
+ * Detect no difference, i.e. `a(x: number, y: string)` and `a(x: number, y: string)`,
163
+ * or one param difference, i.e. `a(x: number, y: number, z: number)` and `a(x: number, y: string, z: number)`.
164
+ */
165
+ function signaturesHaveSameAmountOfParameters(signature0, signature1) {
166
+ const types1 = signature0.params;
167
+ const types2 = signature1.params;
150
168
  const firstParam1 = types1[0];
151
169
  const firstParam2 = types2[0];
152
170
  // exempt signatures with `this: void` from the rule
@@ -155,7 +173,11 @@ exports.default = (0, util_1.createRule)({
155
173
  }
156
174
  const index = getIndexOfFirstDifference(types1, types2, parametersAreEqual);
157
175
  if (index == null) {
158
- return undefined;
176
+ return {
177
+ kind: 'all-parameters-are-same',
178
+ signature0,
179
+ signature1,
180
+ };
159
181
  }
160
182
  // If remaining arrays are equal, the signatures differ by just one parameter type
161
183
  if (!(0, util_1.arraysAreEqual)(types1.slice(index + 1), types2.slice(index + 1), parametersAreEqual)) {
@@ -170,6 +192,39 @@ exports.default = (0, util_1.createRule)({
170
192
  ? { kind: 'single-parameter-difference', p0: a, p1: b }
171
193
  : undefined;
172
194
  }
195
+ function getParameterTypeAnnotation(parameter) {
196
+ return isTSParameterProperty(parameter)
197
+ ? parameter.parameter.typeAnnotation?.typeAnnotation
198
+ : parameter.typeAnnotation?.typeAnnotation;
199
+ }
200
+ function getUnifiedTypeText(type0, type1) {
201
+ // When a signature's parameter has no type annotation
202
+ if (type0 == null || type1 == null) {
203
+ return getUnionMemberText((0, util_1.nullThrows)(type0 ?? type1, 'Expected a type annotation for one of the parameters, but both were undefined'));
204
+ }
205
+ const members = [...getUnionMembers(type0), ...getUnionMembers(type1)];
206
+ const uniqueMembers = [];
207
+ for (const member of members) {
208
+ if (!uniqueMembers.some(other => typesAreEqual(other, member))) {
209
+ uniqueMembers.push(member);
210
+ }
211
+ }
212
+ return uniqueMembers
213
+ .map(member => getUnionMemberText(member))
214
+ .join(' | ');
215
+ }
216
+ function getUnionMembers(type) {
217
+ return type.type === utils_1.AST_NODE_TYPES.TSUnionType
218
+ ? type.types.flatMap(getUnionMembers)
219
+ : [type];
220
+ }
221
+ function getUnionMemberText(type) {
222
+ const text = context.sourceCode.getText(type);
223
+ const needsParentheses = type.type === utils_1.AST_NODE_TYPES.TSConditionalType ||
224
+ type.type === utils_1.AST_NODE_TYPES.TSConstructorType ||
225
+ type.type === utils_1.AST_NODE_TYPES.TSFunctionType;
226
+ return needsParentheses ? `(${text})` : text;
227
+ }
173
228
  function isThisParam(param) {
174
229
  return param?.type === utils_1.AST_NODE_TYPES.Identifier && param.name === 'this';
175
230
  }
@@ -209,15 +264,7 @@ exports.default = (0, util_1.createRule)({
209
264
  }
210
265
  }
211
266
  for (let i = 0; i < minLength; i++) {
212
- const sig1i = sig1[i];
213
- const sig2i = sig2[i];
214
- const typeAnnotation1 = isTSParameterProperty(sig1i)
215
- ? sig1i.parameter.typeAnnotation
216
- : sig1i.typeAnnotation;
217
- const typeAnnotation2 = isTSParameterProperty(sig2i)
218
- ? sig2i.parameter.typeAnnotation
219
- : sig2i.typeAnnotation;
220
- if (!typesAreEqual(typeAnnotation1, typeAnnotation2)) {
267
+ if (!typesAreEqual(getParameterTypeAnnotation(sig1[i]), getParameterTypeAnnotation(sig2[i]))) {
221
268
  return undefined;
222
269
  }
223
270
  }
@@ -265,14 +312,8 @@ exports.default = (0, util_1.createRule)({
265
312
  return node.type === utils_1.AST_NODE_TYPES.TSParameterProperty;
266
313
  }
267
314
  function parametersAreEqual(a, b) {
268
- const typeAnnotationA = isTSParameterProperty(a)
269
- ? a.parameter.typeAnnotation
270
- : a.typeAnnotation;
271
- const typeAnnotationB = isTSParameterProperty(b)
272
- ? b.parameter.typeAnnotation
273
- : b.typeAnnotation;
274
315
  return (parametersHaveEqualSigils(a, b) &&
275
- typesAreEqual(typeAnnotationA, typeAnnotationB));
316
+ typesAreEqual(getParameterTypeAnnotation(a), getParameterTypeAnnotation(b)));
276
317
  }
277
318
  /** True for optional/rest parameters. */
278
319
  function parameterMayBeMissing(p) {
@@ -300,8 +341,7 @@ exports.default = (0, util_1.createRule)({
300
341
  return (a === b ||
301
342
  (a != null &&
302
343
  b != null &&
303
- context.sourceCode.getText(a.typeAnnotation) ===
304
- context.sourceCode.getText(b.typeAnnotation)));
344
+ context.sourceCode.getText(a) === context.sourceCode.getText(b)));
305
345
  }
306
346
  function constraintsAreEqual(a, b) {
307
347
  return a === b || (a != null && a.type === b?.type);
@@ -463,3 +503,4 @@ function isPrivateIdentifier(node) {
463
503
  function isGetterOrSetter(node) {
464
504
  return node.kind === 'get' || node.kind === 'set';
465
505
  }
506
+ //# sourceMappingURL=unified-signatures.js.map
@@ -259,3 +259,4 @@ exports.default = (0, util_1.createRule)({
259
259
  };
260
260
  },
261
261
  });
262
+ //# sourceMappingURL=use-unknown-in-catch-callback-variable.js.map
@@ -114,3 +114,4 @@ function findTypeGuardAssertedArgument(services, node) {
114
114
  type,
115
115
  };
116
116
  }
117
+ //# sourceMappingURL=assertionFunctionUtils.js.map
@@ -141,3 +141,4 @@ function forEachChildESTree(node, callback) {
141
141
  }
142
142
  return visit(node);
143
143
  }
144
+ //# sourceMappingURL=astUtils.js.map
@@ -73,3 +73,4 @@ function matchesTypeOrBaseType(services, matcher, type, seen = new Set()) {
73
73
  const checker = services.program.getTypeChecker();
74
74
  return getBaseTypesForType(checker, type).some(base => matchesTypeOrBaseType(services, matcher, base, seen));
75
75
  }
76
+ //# sourceMappingURL=baseTypeUtils.js.map
@@ -564,3 +564,4 @@ function traverseScopes(currentScope, analysisResults = new Map()) {
564
564
  }
565
565
  return analysisResults;
566
566
  }
567
+ //# sourceMappingURL=classScopeAnalyzer.js.map
@@ -68,3 +68,4 @@ function extractNameForMemberExpression(node) {
68
68
  }
69
69
  return extractNonComputedName(node.property);
70
70
  }
71
+ //# sourceMappingURL=extractComputedName.js.map
@@ -8,3 +8,4 @@ function publicKey(name) {
8
8
  function privateKey(node) {
9
9
  return `#private@@${node.name}`;
10
10
  }
11
+ //# sourceMappingURL=types.js.map
@@ -599,3 +599,4 @@ function isUsedVariable(variable) {
599
599
  function collectVariables(context) {
600
600
  return UnusedVarsVisitor.collectUnusedVariables(context.sourceCode.ast, utils_1.ESLintUtils.nullThrows(context.sourceCode.scopeManager, 'Missing required scope manager'));
601
601
  }
602
+ //# sourceMappingURL=collectUnusedVariables.js.map
@@ -3,3 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createRule = void 0;
4
4
  const utils_1 = require("@typescript-eslint/utils");
5
5
  exports.createRule = utils_1.ESLintUtils.RuleCreator(name => `https://typescript-eslint.io/rules/${name}`);
6
+ //# sourceMappingURL=createRule.js.map
@@ -12,3 +12,4 @@ function escapeRegExp(string = '') {
12
12
  ? string.replaceAll(reRegExpChar, '\\$&')
13
13
  : string;
14
14
  }
15
+ //# sourceMappingURL=escapeRegExp.js.map
@@ -236,3 +236,4 @@ function ancestorHasReturnType(node) {
236
236
  }
237
237
  return false;
238
238
  }
239
+ //# sourceMappingURL=explicitReturnTypeUtils.js.map
@@ -29,3 +29,4 @@ function* getBaseTypesOfClassMember(services, memberNode) {
29
29
  }
30
30
  }
31
31
  }
32
+ //# sourceMappingURL=getBaseTypesOfClassMember.js.map
@@ -68,3 +68,4 @@ function getConstraintInfo(checker, type) {
68
68
  isTypeParameter: false,
69
69
  };
70
70
  }
71
+ //# sourceMappingURL=getConstraintInfo.js.map
@@ -14,3 +14,4 @@ function maybeGetESLintCoreRule(ruleId) {
14
14
  return null;
15
15
  }
16
16
  }
17
+ //# sourceMappingURL=getESLintCoreRule.js.map
@@ -11,3 +11,4 @@ function getFixOrSuggest({ fixOrSuggest, suggestion, }) {
11
11
  return { suggest: [suggestion] };
12
12
  }
13
13
  }
14
+ //# sourceMappingURL=getFixOrSuggest.js.map
@@ -24,3 +24,4 @@ function getForStatementHeadLoc(sourceCode, node) {
24
24
  start: structuredClone(node.loc.start),
25
25
  };
26
26
  }
27
+ //# sourceMappingURL=getForStatementHeadLoc.js.map
@@ -159,3 +159,4 @@ function getFunctionHeadLoc(node, sourceCode) {
159
159
  start: { ...start },
160
160
  };
161
161
  }
162
+ //# sourceMappingURL=getFunctionHeadLoc.js.map
@@ -77,3 +77,4 @@ function getParameterPropertyHeadLoc(sourceCode, node, nodeName) {
77
77
  start,
78
78
  };
79
79
  }
80
+ //# sourceMappingURL=getMemberHeadLoc.js.map
@@ -419,3 +419,4 @@ function getBinaryOperatorPrecedence(kind) {
419
419
  // parsing to stop.
420
420
  return -1;
421
421
  }
422
+ //# sourceMappingURL=getOperatorPrecedence.js.map
@@ -16,3 +16,4 @@ function getParentFunctionNode(node) {
16
16
  // the parser won't error, so we shouldn't throw here
17
17
  /* istanbul ignore next */ return null;
18
18
  }
19
+ //# sourceMappingURL=getParentFunctionNode.js.map
@@ -42,3 +42,4 @@ function getStaticStringValue(node) {
42
42
  }
43
43
  return null;
44
44
  }
45
+ //# sourceMappingURL=getStaticStringValue.js.map
@@ -12,3 +12,4 @@ function getStringLength(value) {
12
12
  segmenter ??= new Intl.Segmenter();
13
13
  return [...segmenter.segment(value)].length;
14
14
  }
15
+ //# sourceMappingURL=getStringLength.js.map
@@ -14,3 +14,4 @@ function getTextWithParentheses(sourceCode, node) {
14
14
  }
15
15
  return sourceCode.getText(node, beforeCount, afterCount);
16
16
  }
17
+ //# sourceMappingURL=getTextWithParentheses.js.map
@@ -22,3 +22,4 @@ function getThisExpression(node) {
22
22
  }
23
23
  return;
24
24
  }
25
+ //# sourceMappingURL=getThisExpression.js.map
@@ -14,3 +14,4 @@ const getValueOfLiteralType = (type) => {
14
14
  return type.value;
15
15
  };
16
16
  exports.getValueOfLiteralType = getValueOfLiteralType;
17
+ //# sourceMappingURL=getValueOfLiteralType.js.map
@@ -4,3 +4,4 @@ exports.getWrappedCode = getWrappedCode;
4
4
  function getWrappedCode(text, nodePrecedence, parentPrecedence) {
5
5
  return nodePrecedence > parentPrecedence ? text : `(${text})`;
6
6
  }
7
+ //# sourceMappingURL=getWrappedCode.js.map
@@ -183,3 +183,4 @@ function isObjectExpressionInOneLineReturn(node, innerNode) {
183
183
  node.parent.body === node &&
184
184
  innerNode.type === utils_1.AST_NODE_TYPES.ObjectExpression);
185
185
  }
186
+ //# sourceMappingURL=getWrappingFixer.js.map
@@ -45,3 +45,4 @@ function getFunctionDeclarationName(node, context) {
45
45
  }
46
46
  return (0, misc_1.getStaticMemberAccessValue)(node, context);
47
47
  }
48
+ //# sourceMappingURL=hasOverloadSignatures.js.map
@@ -18,6 +18,7 @@ export * from './isAssignee';
18
18
  export * from './isConditionalTest';
19
19
  export * from './isNodeEqual';
20
20
  export * from './isNullLiteral';
21
+ export * from './isStartOfArrowFunctionBody';
21
22
  export * from './isStartOfExpressionStatement';
22
23
  export * from './isUndefinedIdentifier';
23
24
  export * from './misc';
@@ -35,6 +35,7 @@ __exportStar(require("./isAssignee"), exports);
35
35
  __exportStar(require("./isConditionalTest"), exports);
36
36
  __exportStar(require("./isNodeEqual"), exports);
37
37
  __exportStar(require("./isNullLiteral"), exports);
38
+ __exportStar(require("./isStartOfArrowFunctionBody"), exports);
38
39
  __exportStar(require("./isStartOfExpressionStatement"), exports);
39
40
  __exportStar(require("./isUndefinedIdentifier"), exports);
40
41
  __exportStar(require("./misc"), exports);
@@ -52,3 +53,4 @@ __exportStar(require("./walkStatements"), exports);
52
53
  // this is done for convenience - saves migrating all of the old rules
53
54
  __exportStar(require("@typescript-eslint/type-utils"), exports);
54
55
  ({ applyDefault: exports.applyDefault, deepMerge: exports.deepMerge, getParserServices: exports.getParserServices, isObjectNotArray: exports.isObjectNotArray, nullThrows: exports.nullThrows, NullThrowsReasons: exports.NullThrowsReasons } = utils_1.ESLintUtils);
56
+ //# sourceMappingURL=index.js.map
@@ -62,3 +62,4 @@ function isArrayMethodCallWithPredicate(context, services, node) {
62
62
  .flatMap(part => tsutils.intersectionConstituents(part))
63
63
  .some(t => checker.isArrayType(t) || checker.isTupleType(t));
64
64
  }
65
+ //# sourceMappingURL=isArrayMethodCallWithPredicate.js.map
@@ -48,3 +48,4 @@ function isAssignee(node) {
48
48
  }
49
49
  return false;
50
50
  }
51
+ //# sourceMappingURL=isAssignee.js.map
@@ -32,3 +32,4 @@ function isConditionalTest(node) {
32
32
  }
33
33
  return false;
34
34
  }
35
+ //# sourceMappingURL=isConditionalTest.js.map