@typescript-eslint/eslint-plugin 8.67.1-alpha.9 → 8.68.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 (242) hide show
  1. package/CHANGELOG.md +5906 -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.d.ts +1 -1
  30. package/dist/index.js +1 -0
  31. package/dist/raw-plugin.d.ts +1 -1
  32. package/dist/raw-plugin.js +1 -0
  33. package/dist/rules/adjacent-overload-signatures.js +1 -0
  34. package/dist/rules/array-type.js +1 -0
  35. package/dist/rules/await-thenable.js +1 -0
  36. package/dist/rules/ban-ts-comment.js +1 -0
  37. package/dist/rules/ban-tslint-comment.js +1 -0
  38. package/dist/rules/class-literal-property-style.js +1 -0
  39. package/dist/rules/class-methods-use-this.js +1 -0
  40. package/dist/rules/consistent-generic-constructors.js +1 -0
  41. package/dist/rules/consistent-indexed-object-style.js +1 -0
  42. package/dist/rules/consistent-return.js +1 -0
  43. package/dist/rules/consistent-type-assertions.js +1 -0
  44. package/dist/rules/consistent-type-definitions.js +1 -0
  45. package/dist/rules/consistent-type-exports.js +1 -0
  46. package/dist/rules/consistent-type-imports.js +1 -0
  47. package/dist/rules/default-param-last.js +1 -0
  48. package/dist/rules/dot-notation.js +1 -0
  49. package/dist/rules/enum-utils/shared.d.ts +5 -0
  50. package/dist/rules/enum-utils/shared.js +68 -0
  51. package/dist/rules/explicit-function-return-type.js +1 -0
  52. package/dist/rules/explicit-member-accessibility.js +1 -0
  53. package/dist/rules/explicit-module-boundary-types.js +1 -0
  54. package/dist/rules/index.d.ts +1 -1
  55. package/dist/rules/index.js +1 -0
  56. package/dist/rules/init-declarations.js +1 -0
  57. package/dist/rules/max-params.js +1 -0
  58. package/dist/rules/member-ordering.js +1 -0
  59. package/dist/rules/method-signature-style.js +1 -0
  60. package/dist/rules/naming-convention-utils/enums.js +1 -0
  61. package/dist/rules/naming-convention-utils/format.js +1 -0
  62. package/dist/rules/naming-convention-utils/index.js +1 -0
  63. package/dist/rules/naming-convention-utils/parse-options.js +1 -0
  64. package/dist/rules/naming-convention-utils/schema.js +1 -0
  65. package/dist/rules/naming-convention-utils/shared.js +1 -0
  66. package/dist/rules/naming-convention-utils/types.js +1 -0
  67. package/dist/rules/naming-convention-utils/validator.js +1 -0
  68. package/dist/rules/naming-convention.js +1 -0
  69. package/dist/rules/no-array-constructor.js +1 -0
  70. package/dist/rules/no-array-delete.js +1 -0
  71. package/dist/rules/no-base-to-string.js +1 -0
  72. package/dist/rules/no-confusing-non-null-assertion.js +1 -0
  73. package/dist/rules/no-confusing-void-expression.js +8 -9
  74. package/dist/rules/no-deprecated.js +1 -0
  75. package/dist/rules/no-dupe-class-members.js +1 -0
  76. package/dist/rules/no-duplicate-enum-values.js +1 -0
  77. package/dist/rules/no-duplicate-type-constituents.js +1 -0
  78. package/dist/rules/no-dynamic-delete.js +1 -0
  79. package/dist/rules/no-empty-function.js +1 -0
  80. package/dist/rules/no-empty-interface.js +1 -0
  81. package/dist/rules/no-empty-object-type.js +9 -4
  82. package/dist/rules/no-explicit-any.js +1 -0
  83. package/dist/rules/no-extra-non-null-assertion.js +1 -0
  84. package/dist/rules/no-extraneous-class.js +1 -0
  85. package/dist/rules/no-floating-promises.js +64 -55
  86. package/dist/rules/no-for-in-array.js +1 -0
  87. package/dist/rules/no-implied-eval.js +1 -0
  88. package/dist/rules/no-import-type-side-effects.js +1 -0
  89. package/dist/rules/no-inferrable-types.js +1 -0
  90. package/dist/rules/no-invalid-this.js +1 -0
  91. package/dist/rules/no-invalid-void-type.js +1 -0
  92. package/dist/rules/no-loop-func.js +1 -0
  93. package/dist/rules/no-loss-of-precision.js +1 -0
  94. package/dist/rules/no-magic-numbers.js +1 -0
  95. package/dist/rules/no-meaningless-void-operator.js +1 -0
  96. package/dist/rules/no-misused-new.js +1 -0
  97. package/dist/rules/no-misused-promises.js +1 -0
  98. package/dist/rules/no-misused-spread.js +1 -0
  99. package/dist/rules/no-mixed-enums.js +1 -0
  100. package/dist/rules/no-namespace.js +1 -0
  101. package/dist/rules/no-non-null-asserted-nullish-coalescing.js +1 -0
  102. package/dist/rules/no-non-null-asserted-optional-chain.js +1 -0
  103. package/dist/rules/no-non-null-assertion.js +1 -0
  104. package/dist/rules/no-redeclare.js +1 -0
  105. package/dist/rules/no-redundant-type-constituents.js +1 -0
  106. package/dist/rules/no-require-imports.js +1 -0
  107. package/dist/rules/no-restricted-imports.js +1 -0
  108. package/dist/rules/no-restricted-types.js +1 -0
  109. package/dist/rules/no-shadow.js +1 -0
  110. package/dist/rules/no-this-alias.js +1 -0
  111. package/dist/rules/no-type-alias.js +1 -0
  112. package/dist/rules/no-unnecessary-boolean-literal-compare.js +1 -0
  113. package/dist/rules/no-unnecessary-condition.js +1 -0
  114. package/dist/rules/no-unnecessary-parameter-property-assignment.js +1 -0
  115. package/dist/rules/no-unnecessary-qualifier.js +1 -0
  116. package/dist/rules/no-unnecessary-template-expression.js +3 -14
  117. package/dist/rules/no-unnecessary-type-arguments.js +1 -0
  118. package/dist/rules/no-unnecessary-type-assertion.js +12 -1
  119. package/dist/rules/no-unnecessary-type-constraint.js +1 -0
  120. package/dist/rules/no-unnecessary-type-conversion.js +1 -0
  121. package/dist/rules/no-unnecessary-type-parameters.js +1 -0
  122. package/dist/rules/no-unsafe-argument.js +2 -91
  123. package/dist/rules/no-unsafe-assignment.js +1 -0
  124. package/dist/rules/no-unsafe-call.js +1 -0
  125. package/dist/rules/no-unsafe-declaration-merging.js +1 -0
  126. package/dist/rules/no-unsafe-enum-comparison.js +3 -113
  127. package/dist/rules/no-unsafe-function-type.js +1 -0
  128. package/dist/rules/no-unsafe-member-access.js +1 -0
  129. package/dist/rules/no-unsafe-return.js +1 -0
  130. package/dist/rules/no-unsafe-type-assertion.js +1 -0
  131. package/dist/rules/no-unsafe-unary-minus.js +1 -0
  132. package/dist/rules/no-unused-expressions.js +1 -0
  133. package/dist/rules/no-unused-private-class-members.js +1 -0
  134. package/dist/rules/no-unused-vars.js +1 -0
  135. package/dist/rules/no-use-before-define.js +1 -0
  136. package/dist/rules/no-useless-constructor.js +1 -0
  137. package/dist/rules/no-useless-default-assignment.js +1 -0
  138. package/dist/rules/no-useless-empty-export.js +1 -0
  139. package/dist/rules/no-var-requires.js +1 -0
  140. package/dist/rules/no-wrapper-object-types.js +1 -0
  141. package/dist/rules/non-nullable-type-assertion-style.js +1 -0
  142. package/dist/rules/only-throw-error.js +1 -0
  143. package/dist/rules/parameter-properties.js +1 -0
  144. package/dist/rules/prefer-as-const.js +1 -0
  145. package/dist/rules/prefer-destructuring.js +1 -0
  146. package/dist/rules/prefer-enum-initializers.js +1 -0
  147. package/dist/rules/prefer-find.js +1 -0
  148. package/dist/rules/prefer-for-of.js +1 -0
  149. package/dist/rules/prefer-function-type.js +1 -0
  150. package/dist/rules/prefer-includes.js +1 -0
  151. package/dist/rules/prefer-literal-enum-member.js +1 -0
  152. package/dist/rules/prefer-namespace-keyword.js +1 -0
  153. package/dist/rules/prefer-nullish-coalescing.js +1 -0
  154. package/dist/rules/prefer-optional-chain-utils/PreferOptionalChainOptions.js +1 -0
  155. package/dist/rules/prefer-optional-chain-utils/analyzeChain.js +1 -0
  156. package/dist/rules/prefer-optional-chain-utils/checkNullishAndReport.js +1 -0
  157. package/dist/rules/prefer-optional-chain-utils/compareNodes.js +1 -0
  158. package/dist/rules/prefer-optional-chain-utils/gatherLogicalOperands.js +1 -0
  159. package/dist/rules/prefer-optional-chain.js +1 -0
  160. package/dist/rules/prefer-promise-reject-errors.js +1 -0
  161. package/dist/rules/prefer-readonly-parameter-types.js +1 -0
  162. package/dist/rules/prefer-readonly.js +1 -0
  163. package/dist/rules/prefer-reduce-type-parameter.js +1 -0
  164. package/dist/rules/prefer-regexp-exec.js +1 -0
  165. package/dist/rules/prefer-return-this-type.js +1 -0
  166. package/dist/rules/prefer-string-starts-ends-with.js +1 -0
  167. package/dist/rules/prefer-ts-expect-error.js +1 -0
  168. package/dist/rules/promise-function-async.js +1 -0
  169. package/dist/rules/related-getter-setter-pairs.js +1 -0
  170. package/dist/rules/require-array-sort-compare.js +1 -0
  171. package/dist/rules/require-await.js +1 -0
  172. package/dist/rules/restrict-plus-operands.js +1 -0
  173. package/dist/rules/restrict-template-expressions.js +1 -0
  174. package/dist/rules/return-await.js +1 -0
  175. package/dist/rules/sort-type-constituents.js +1 -0
  176. package/dist/rules/strict-boolean-expressions.js +1 -0
  177. package/dist/rules/strict-void-return.d.ts +3 -2
  178. package/dist/rules/strict-void-return.js +97 -5
  179. package/dist/rules/switch-exhaustiveness-check.js +1 -0
  180. package/dist/rules/triple-slash-reference.js +1 -0
  181. package/dist/rules/typedef.js +1 -0
  182. package/dist/rules/unbound-method.js +1 -0
  183. package/dist/rules/unified-signatures.d.ts +1 -1
  184. package/dist/rules/unified-signatures.js +30 -4
  185. package/dist/rules/use-unknown-in-catch-callback-variable.js +1 -0
  186. package/dist/util/FunctionSignature.d.ts +15 -0
  187. package/dist/util/FunctionSignature.js +123 -0
  188. package/dist/util/assertionFunctionUtils.js +1 -0
  189. package/dist/util/astUtils.js +1 -0
  190. package/dist/util/baseTypeUtils.d.ts +2 -0
  191. package/dist/util/baseTypeUtils.js +17 -0
  192. package/dist/util/class-scope-analyzer/classScopeAnalyzer.js +1 -0
  193. package/dist/util/class-scope-analyzer/extractComputedName.js +1 -0
  194. package/dist/util/class-scope-analyzer/types.js +1 -0
  195. package/dist/util/collectUnusedVariables.js +1 -0
  196. package/dist/util/createRule.js +1 -0
  197. package/dist/util/escapeRegExp.js +1 -0
  198. package/dist/util/explicitReturnTypeUtils.js +1 -0
  199. package/dist/util/getBaseTypesOfClassMember.js +1 -0
  200. package/dist/util/getConstraintInfo.js +1 -0
  201. package/dist/util/getESLintCoreRule.js +1 -0
  202. package/dist/util/getFixOrSuggest.js +1 -0
  203. package/dist/util/getForStatementHeadLoc.js +1 -0
  204. package/dist/util/getFunctionHeadLoc.js +1 -0
  205. package/dist/util/getMemberHeadLoc.js +1 -0
  206. package/dist/util/getOperatorPrecedence.js +1 -0
  207. package/dist/util/getParentFunctionNode.js +1 -0
  208. package/dist/util/getStaticStringValue.js +1 -0
  209. package/dist/util/getStringLength.js +1 -0
  210. package/dist/util/getTextWithParentheses.js +1 -0
  211. package/dist/util/getThisExpression.js +1 -0
  212. package/dist/util/getValueOfLiteralType.js +1 -0
  213. package/dist/util/getWrappedCode.js +1 -0
  214. package/dist/util/getWrappingFixer.js +1 -0
  215. package/dist/util/hasOverloadSignatures.js +1 -0
  216. package/dist/util/index.d.ts +1 -0
  217. package/dist/util/index.js +2 -0
  218. package/dist/util/isArrayMethodCallWithPredicate.js +1 -0
  219. package/dist/util/isAssignee.js +1 -0
  220. package/dist/util/isConditionalTest.js +1 -0
  221. package/dist/util/isHigherPrecedenceThanAwait.js +1 -0
  222. package/dist/util/isNodeEqual.js +1 -0
  223. package/dist/util/isNullLiteral.js +1 -0
  224. package/dist/util/isPromiseAggregatorMethod.js +1 -0
  225. package/dist/util/isStartOfArrowFunctionBody.js +1 -0
  226. package/dist/util/isStartOfExpressionStatement.js +1 -0
  227. package/dist/util/isTypeImport.js +1 -0
  228. package/dist/util/isUndefinedIdentifier.js +1 -0
  229. package/dist/util/misc.js +1 -0
  230. package/dist/util/needsPrecedingSemiColon.js +1 -0
  231. package/dist/util/needsToBeAwaited.js +1 -0
  232. package/dist/util/objectIterators.js +1 -0
  233. package/dist/util/promiseUtils.js +1 -0
  234. package/dist/util/rangeToLoc.js +1 -0
  235. package/dist/util/referenceContainsTypePredicate.js +1 -0
  236. package/dist/util/referenceContainsTypeQuery.js +1 -0
  237. package/dist/util/scopeUtils.js +1 -0
  238. package/dist/util/skipChainExpression.js +1 -0
  239. package/dist/util/truthinessUtils.js +1 -0
  240. package/dist/util/types.js +1 -0
  241. package/dist/util/walkStatements.js +1 -0
  242. package/package.json +12 -11
@@ -1,74 +1,7 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
- const tsutils = __importStar(require("ts-api-utils"));
37
- const ts = __importStar(require("typescript"));
38
3
  const util_1 = require("../util");
39
4
  const shared_1 = require("./enum-utils/shared");
40
- /**
41
- * @returns Whether the right type is an unsafe comparison against any left type.
42
- */
43
- function typeViolates(leftTypeParts, rightType) {
44
- const leftEnumValueTypes = new Set(leftTypeParts.map(getEnumValueType));
45
- return ((leftEnumValueTypes.has(ts.TypeFlags.Number) && isNumberLike(rightType)) ||
46
- (leftEnumValueTypes.has(ts.TypeFlags.String) && isStringLike(rightType)));
47
- }
48
- function isNumberLike(type) {
49
- return tsutils
50
- .unionConstituents(type)
51
- .every(unionPart => tsutils
52
- .intersectionConstituents(unionPart)
53
- .some(intersectionPart => tsutils.isTypeFlagSet(intersectionPart, ts.TypeFlags.Number | ts.TypeFlags.NumberLike)));
54
- }
55
- function isStringLike(type) {
56
- return tsutils
57
- .unionConstituents(type)
58
- .every(unionPart => tsutils
59
- .intersectionConstituents(unionPart)
60
- .some(intersectionPart => tsutils.isTypeFlagSet(intersectionPart, ts.TypeFlags.String | ts.TypeFlags.StringLike)));
61
- }
62
- /**
63
- * @returns What type a type's enum value is (number or string), if either.
64
- */
65
- function getEnumValueType(type) {
66
- return tsutils.isTypeFlagSet(type, ts.TypeFlags.EnumLike)
67
- ? tsutils.isTypeFlagSet(type, ts.TypeFlags.NumberLiteral)
68
- ? ts.TypeFlags.Number
69
- : ts.TypeFlags.String
70
- : undefined;
71
- }
72
5
  exports.default = (0, util_1.createRule)({
73
6
  name: 'no-unsafe-enum-comparison',
74
7
  meta: {
@@ -90,55 +23,11 @@ exports.default = (0, util_1.createRule)({
90
23
  create(context) {
91
24
  const parserServices = (0, util_1.getParserServices)(context);
92
25
  const typeChecker = parserServices.program.getTypeChecker();
93
- function isMismatchedComparison(leftType, rightType) {
94
- // Allow comparisons that don't have anything to do with enums:
95
- //
96
- // ```ts
97
- // 1 === 2;
98
- // ```
99
- const leftEnumTypes = (0, shared_1.getEnumTypes)(typeChecker, leftType);
100
- const rightEnumTypes = new Set((0, shared_1.getEnumTypes)(typeChecker, rightType));
101
- if (leftEnumTypes.length === 0 && rightEnumTypes.size === 0) {
102
- return false;
103
- }
104
- // Allow comparisons that share an enum type:
105
- //
106
- // ```ts
107
- // Fruit.Apple === Fruit.Banana;
108
- // ```
109
- for (const leftEnumType of leftEnumTypes) {
110
- if (rightEnumTypes.has(leftEnumType)) {
111
- return false;
112
- }
113
- }
114
- // We need to split the type into the union type parts in order to find
115
- // valid enum comparisons like:
116
- //
117
- // ```ts
118
- // declare const something: Fruit | Vegetable;
119
- // something === Fruit.Apple;
120
- // ```
121
- const leftTypeParts = tsutils.unionConstituents(leftType);
122
- const rightTypeParts = tsutils.unionConstituents(rightType);
123
- // If a type exists in both sides, we consider this comparison safe:
124
- //
125
- // ```ts
126
- // declare const fruit: Fruit.Apple | 0;
127
- // fruit === 0;
128
- // ```
129
- for (const leftTypePart of leftTypeParts) {
130
- if (rightTypeParts.includes(leftTypePart)) {
131
- return false;
132
- }
133
- }
134
- return (typeViolates(leftTypeParts, rightType) ||
135
- typeViolates(rightTypeParts, leftType));
136
- }
137
26
  return {
138
27
  'BinaryExpression[operator=/^[<>!=]?={0,2}$/]'(node) {
139
28
  const leftType = parserServices.getTypeAtLocation(node.left);
140
29
  const rightType = parserServices.getTypeAtLocation(node.right);
141
- if (isMismatchedComparison(leftType, rightType)) {
30
+ if ((0, shared_1.isMismatchedEnumComparisonTypes)(typeChecker, leftType, rightType)) {
142
31
  context.report({
143
32
  node,
144
33
  messageId: 'mismatchedCondition',
@@ -180,7 +69,7 @@ exports.default = (0, util_1.createRule)({
180
69
  const { parent } = node;
181
70
  const leftType = parserServices.getTypeAtLocation(parent.discriminant);
182
71
  const rightType = parserServices.getTypeAtLocation(node.test);
183
- if (isMismatchedComparison(leftType, rightType)) {
72
+ if ((0, shared_1.isMismatchedEnumComparisonTypes)(typeChecker, leftType, rightType)) {
184
73
  context.report({
185
74
  node,
186
75
  messageId: 'mismatchedCase',
@@ -190,3 +79,4 @@ exports.default = (0, util_1.createRule)({
190
79
  };
191
80
  },
192
81
  });
82
+ //# sourceMappingURL=no-unsafe-enum-comparison.js.map
@@ -43,3 +43,4 @@ exports.default = (0, util_1.createRule)({
43
43
  };
44
44
  },
45
45
  });
46
+ //# sourceMappingURL=no-unsafe-function-type.js.map
@@ -181,3 +181,4 @@ exports.default = (0, util_1.createRule)({
181
181
  };
182
182
  },
183
183
  });
184
+ //# sourceMappingURL=no-unsafe-member-access.js.map
@@ -182,3 +182,4 @@ exports.default = (0, util_1.createRule)({
182
182
  };
183
183
  },
184
184
  });
185
+ //# sourceMappingURL=no-unsafe-return.js.map
@@ -163,3 +163,4 @@ exports.default = (0, util_1.createRule)({
163
163
  };
164
164
  },
165
165
  });
166
+ //# sourceMappingURL=no-unsafe-type-assertion.js.map
@@ -76,3 +76,4 @@ exports.default = util.createRule({
76
76
  };
77
77
  },
78
78
  });
79
+ //# sourceMappingURL=no-unsafe-unary-minus.js.map
@@ -62,3 +62,4 @@ exports.default = (0, util_1.createRule)({
62
62
  };
63
63
  },
64
64
  });
65
+ //# sourceMappingURL=no-unused-expressions.js.map
@@ -42,3 +42,4 @@ exports.default = (0, util_1.createRule)({
42
42
  };
43
43
  },
44
44
  });
45
+ //# sourceMappingURL=no-unused-private-class-members.js.map
@@ -1033,3 +1033,4 @@ interface Bar {} // this Bar should be unused
1033
1033
  export const Bar = 1;
1034
1034
 
1035
1035
  */
1036
+ //# sourceMappingURL=no-unused-vars.js.map
@@ -301,3 +301,4 @@ exports.default = (0, util_1.createRule)({
301
301
  };
302
302
  },
303
303
  });
304
+ //# sourceMappingURL=no-use-before-define.js.map
@@ -55,3 +55,4 @@ exports.default = (0, util_1.createRule)({
55
55
  };
56
56
  },
57
57
  });
58
+ //# sourceMappingURL=no-useless-constructor.js.map
@@ -322,3 +322,4 @@ exports.default = (0, util_1.createRule)({
322
322
  };
323
323
  },
324
324
  });
325
+ //# sourceMappingURL=no-useless-default-assignment.js.map
@@ -68,3 +68,4 @@ exports.default = (0, util_1.createRule)({
68
68
  };
69
69
  },
70
70
  });
71
+ //# sourceMappingURL=no-useless-empty-export.js.map
@@ -81,3 +81,4 @@ exports.default = (0, util_1.createRule)({
81
81
  };
82
82
  },
83
83
  });
84
+ //# sourceMappingURL=no-var-requires.js.map
@@ -58,3 +58,4 @@ exports.default = (0, util_1.createRule)({
58
58
  };
59
59
  },
60
60
  });
61
+ //# sourceMappingURL=no-wrapper-object-types.js.map
@@ -130,3 +130,4 @@ exports.default = (0, util_1.createRule)({
130
130
  };
131
131
  },
132
132
  });
133
+ //# sourceMappingURL=non-nullable-type-assertion-style.js.map
@@ -156,3 +156,4 @@ exports.default = (0, util_1.createRule)({
156
156
  };
157
157
  },
158
158
  });
159
+ //# sourceMappingURL=only-throw-error.js.map
@@ -162,3 +162,4 @@ exports.default = (0, util_1.createRule)({
162
162
  };
163
163
  },
164
164
  });
165
+ //# sourceMappingURL=parameter-properties.js.map
@@ -70,3 +70,4 @@ exports.default = (0, util_1.createRule)({
70
70
  };
71
71
  },
72
72
  });
73
+ //# sourceMappingURL=prefer-as-const.js.map
@@ -214,3 +214,4 @@ function isArrayLiteralIntegerIndexAccess(node) {
214
214
  }
215
215
  return Number.isInteger(node.property.value);
216
216
  }
217
+ //# sourceMappingURL=prefer-destructuring.js.map
@@ -60,3 +60,4 @@ exports.default = (0, util_1.createRule)({
60
60
  };
61
61
  },
62
62
  });
63
+ //# sourceMappingURL=prefer-enum-initializers.js.map
@@ -245,3 +245,4 @@ exports.default = (0, util_1.createRule)({
245
245
  };
246
246
  },
247
247
  });
248
+ //# sourceMappingURL=prefer-find.js.map
@@ -113,3 +113,4 @@ exports.default = (0, util_1.createRule)({
113
113
  };
114
114
  },
115
115
  });
116
+ //# sourceMappingURL=prefer-for-of.js.map
@@ -184,3 +184,4 @@ exports.default = (0, util_1.createRule)({
184
184
  };
185
185
  },
186
186
  });
187
+ //# sourceMappingURL=prefer-function-type.js.map
@@ -240,3 +240,4 @@ exports.default = (0, util_1.createRule)({
240
240
  };
241
241
  },
242
242
  });
243
+ //# sourceMappingURL=prefer-includes.js.map
@@ -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
@@ -372,3 +372,4 @@ function getConfiguration(option) {
372
372
  };
373
373
  }
374
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
@@ -1,10 +1,11 @@
1
+ import type { TSESLint } from '@typescript-eslint/utils';
1
2
  type Options = [
2
3
  {
3
4
  allowReturnAny?: boolean;
4
5
  }
5
6
  ];
6
- type MessageId = `asyncFunc` | `nonVoidFunc` | `nonVoidReturn`;
7
- declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageId, Options, import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
7
+ type MessageId = `asyncFunc` | `nonVoidFunc` | `nonVoidReturn` | `suggestAddVoidOp` | `suggestWrapInAsyncIIFE`;
8
+ declare const _default: TSESLint.RuleModule<MessageId, Options, import("../../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
8
9
  name: string;
9
10
  };
10
11
  export default _default;
@@ -45,10 +45,13 @@ exports.default = util.createRule({
45
45
  description: 'Disallow passing a value-returning function in a position accepting a void function',
46
46
  requiresTypeChecking: true,
47
47
  },
48
+ hasSuggestions: true,
48
49
  messages: {
49
50
  asyncFunc: 'Async function used in a context where a void function is expected.',
50
51
  nonVoidFunc: 'Value-returning function used in a context where a void function is expected.',
51
52
  nonVoidReturn: 'Value returned in a context where a void return is expected.',
53
+ suggestAddVoidOp: 'Add a void operator to discard the return value.',
54
+ suggestWrapInAsyncIIFE: 'Wrap the function body in an async IIFE.',
52
55
  },
53
56
  schema: [
54
57
  {
@@ -324,20 +327,55 @@ exports.default = util.createRule({
324
327
  }
325
328
  if (funcNode.async) {
326
329
  // The provided function is an async function.
327
- // Async functions aren't allowed.
330
+ if (funcNode.body.type !== utils_1.AST_NODE_TYPES.BlockStatement) {
331
+ // This async function is an arrow function shorthand without braces.
332
+ return context.report({
333
+ loc: util.getFunctionHeadLoc(funcNode, sourceCode),
334
+ messageId: 'asyncFunc',
335
+ suggest: utils_1.ASTUtils.hasSideEffect(funcNode.body, sourceCode)
336
+ ? // This function has side effects, e.g. `async () => doSomething()`.
337
+ // Suggest removing the async keyword and adding a void operator.
338
+ [
339
+ {
340
+ messageId: 'suggestAddVoidOp',
341
+ fix: fixer => addVoidToArrowFix(fixer, funcNode),
342
+ },
343
+ ]
344
+ : [],
345
+ });
346
+ }
347
+ // This async function has a block body.
348
+ // Suggest wrapping its body in an async IIFE.
328
349
  return context.report({
329
350
  loc: util.getFunctionHeadLoc(funcNode, sourceCode),
330
- messageId: `asyncFunc`,
351
+ messageId: 'asyncFunc',
352
+ suggest: [
353
+ {
354
+ messageId: 'suggestWrapInAsyncIIFE',
355
+ fix: fixer => wrapInAsyncIIFEFix(fixer, funcNode),
356
+ },
357
+ ],
331
358
  });
332
359
  }
360
+ // This function is a regular or arrow sync function.
333
361
  if (funcNode.body.type !== utils_1.AST_NODE_TYPES.BlockStatement) {
334
- // The provided function is an arrow function shorthand without braces.
362
+ // This function is an arrow function shorthand without braces.
335
363
  return context.report({
336
364
  node: funcNode.body,
337
- messageId: `nonVoidReturn`,
365
+ messageId: 'nonVoidReturn',
366
+ suggest: utils_1.ASTUtils.hasSideEffect(funcNode.body, sourceCode)
367
+ ? // This function has side effects, e.g. `() => doSomething()`.
368
+ // Suggest adding a void operator.
369
+ [
370
+ {
371
+ messageId: 'suggestAddVoidOp',
372
+ fix: fixer => addVoidToArrowFix(fixer, funcNode),
373
+ },
374
+ ]
375
+ : [],
338
376
  });
339
377
  }
340
- // The function is a regular or arrow function with a block body.
378
+ // This function is a regular or arrow sync function with a block body.
341
379
  // Check return type annotation.
342
380
  if (funcNode.returnType != null) {
343
381
  // The provided function has an explicit return type annotation.
@@ -373,5 +411,59 @@ exports.default = util.createRule({
373
411
  }
374
412
  // No invalid returns found. The function is allowed.
375
413
  }
414
+ /**
415
+ * Removes the async keyword and replaces the return type with void.
416
+ */
417
+ function* makeSyncFuncFix(fixer, funcNode) {
418
+ if (funcNode.async) {
419
+ // Remove async keyword
420
+ const funcHeadNode = funcNode.parent.type === utils_1.AST_NODE_TYPES.Property ||
421
+ funcNode.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition
422
+ ? funcNode.parent
423
+ : funcNode;
424
+ const asyncToken = util.nullThrows(sourceCode.getFirstToken(funcHeadNode, {
425
+ filter: token => token.value === 'async',
426
+ }), util.NullThrowsReasons.MissingToken('async keyword', funcNode.type));
427
+ yield fixer.remove(asyncToken);
428
+ }
429
+ // Replace return type with void
430
+ if (funcNode.returnType != null) {
431
+ yield fixer.replaceText(funcNode.returnType.typeAnnotation, 'void');
432
+ }
433
+ }
434
+ /**
435
+ * Makes the function sync and adds a void operator to the arrow shorthand body.
436
+ */
437
+ function* addVoidToArrowFix(fixer, funcNode) {
438
+ yield* makeSyncFuncFix(fixer, funcNode);
439
+ // Add void operator
440
+ yield util.getWrappingFixer({
441
+ node: funcNode.body,
442
+ sourceCode,
443
+ wrap: code => `void ${code}`,
444
+ })(fixer);
445
+ }
446
+ /**
447
+ * Makes the function sync and wraps the body in an inner async IIFE.
448
+ */
449
+ function* wrapInAsyncIIFEFix(fixer, funcNode) {
450
+ yield* makeSyncFuncFix(fixer, funcNode);
451
+ // Wrap body in async IIFE.
452
+ // This preserves the node kind (normal/arrow) for the _outer_ function
453
+ // and uses an arrow function for the _inner_ function,
454
+ // so that `this` will always refer to the same value as before.
455
+ if (funcNode.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression) {
456
+ const arrowToken = util.nullThrows(sourceCode.getTokenBefore(funcNode.body, {
457
+ filter: token => token.value === '=>',
458
+ }), util.NullThrowsReasons.MissingToken('arrow token', 'before arrow function body'));
459
+ yield fixer.insertTextAfter(arrowToken, ' void (async () =>');
460
+ yield fixer.insertTextAfter(funcNode, ')()');
461
+ }
462
+ else {
463
+ yield fixer.insertTextBefore(funcNode.body, '{ (async () => ');
464
+ yield fixer.insertTextAfter(funcNode.body, ')(); }');
465
+ }
466
+ }
376
467
  },
377
468
  });
469
+ //# 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;