@typescript-eslint/eslint-plugin 8.71.3-alpha.15 → 8.71.3-alpha.17

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.
@@ -1,6 +1,11 @@
1
1
  import type { TSESLint } from '@typescript-eslint/utils';
2
2
  export type MessageId = 'await' | 'awaitUsingOfNonAsyncDisposable' | 'convertToOrdinaryFor' | 'forAwaitOfNonAsyncIterable' | 'invalidPromiseAggregatorInput' | 'removeAwait';
3
- declare const _default: TSESLint.RuleModule<MessageId, [], import("../../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
3
+ export type Options = [
4
+ {
5
+ allowMixedPromiseArrays?: boolean;
6
+ }
7
+ ];
8
+ declare const _default: TSESLint.RuleModule<MessageId, Options, import("../../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
4
9
  name: string;
5
10
  };
6
11
  export default _default;
@@ -56,11 +56,22 @@ exports.default = (0, util_1.createRule)({
56
56
  invalidPromiseAggregatorInput: 'Unexpected iterable of non-Promise (non-"Thenable") values passed to promise aggregator.',
57
57
  removeAwait: 'Remove unnecessary `await`.',
58
58
  },
59
- schema: [],
59
+ schema: [
60
+ {
61
+ type: 'object',
62
+ additionalProperties: false,
63
+ properties: {
64
+ allowMixedPromiseArrays: {
65
+ type: 'boolean',
66
+ description: 'Whether to allow promise aggregators to receive iterables mixing Promise and non-Promise values, as long as at least one value may be a Promise.',
67
+ },
68
+ },
69
+ },
70
+ ],
60
71
  },
61
72
  // eslint-disable-next-line @typescript-eslint/no-deprecated -- For compatibility with ESLint 8, see #12842
62
- defaultOptions: [],
63
- create(context) {
73
+ defaultOptions: [{ allowMixedPromiseArrays: false }],
74
+ create(context, [{ allowMixedPromiseArrays = false }]) {
64
75
  const services = (0, util_1.getParserServices)(context);
65
76
  const checker = services.program.getTypeChecker();
66
77
  return {
@@ -104,6 +115,10 @@ exports.default = (0, util_1.createRule)({
104
115
  if (argument == null) {
105
116
  return;
106
117
  }
118
+ if (allowMixedPromiseArrays &&
119
+ hasMaybeAwaitableValue(services, argument)) {
120
+ return;
121
+ }
107
122
  if (argument.type === utils_1.TSESTree.AST_NODE_TYPES.ArrayExpression) {
108
123
  for (const element of argument.elements) {
109
124
  if (element == null) {
@@ -208,6 +223,13 @@ function isInvalidPromiseAggregatorInput(checker, node, type) {
208
223
  }
209
224
  return false;
210
225
  }
226
+ function hasMaybeAwaitableValue(services, node) {
227
+ const checker = services.program.getTypeChecker();
228
+ const tsNode = services.esTreeNodeToTSNodeMap.get(node);
229
+ return tsutils
230
+ .unionConstituents((0, util_1.getConstrainedTypeAtLocation)(services, node))
231
+ .some(part => getValueTypesOfArrayLike(part, checker)?.some(valueType => !isAlwaysNonAwaitableType(valueType, tsNode, checker)));
232
+ }
211
233
  function getValueTypesOfArrayLike(type, checker) {
212
234
  if (checker.isTupleType(type)) {
213
235
  return checker.getTypeArguments(type);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/eslint-plugin",
3
- "version": "8.71.3-alpha.15",
3
+ "version": "8.71.3-alpha.17",
4
4
  "description": "TypeScript plugin for ESLint",
5
5
  "files": [
6
6
  "dist",
@@ -47,10 +47,10 @@
47
47
  ],
48
48
  "dependencies": {
49
49
  "@eslint-community/regexpp": "^4.12.2",
50
- "@typescript-eslint/scope-manager": "8.71.3-alpha.15",
51
- "@typescript-eslint/type-utils": "8.71.3-alpha.15",
52
- "@typescript-eslint/utils": "8.71.3-alpha.15",
53
- "@typescript-eslint/visitor-keys": "8.71.3-alpha.15",
50
+ "@typescript-eslint/scope-manager": "8.71.3-alpha.17",
51
+ "@typescript-eslint/type-utils": "8.71.3-alpha.17",
52
+ "@typescript-eslint/utils": "8.71.3-alpha.17",
53
+ "@typescript-eslint/visitor-keys": "8.71.3-alpha.17",
54
54
  "ignore": "^7.0.5",
55
55
  "natural-compare": "^1.4.0",
56
56
  "ts-api-utils": "^2.5.0"
@@ -60,10 +60,10 @@
60
60
  "@types/mdast": "^4.0.4",
61
61
  "@types/natural-compare": "^1.4.3",
62
62
  "@types/react": "^18.3.21",
63
- "@typescript-eslint/rule-schema-to-typescript-types": "8.71.3-alpha.15",
64
- "@typescript-eslint/rule-tester": "8.71.3-alpha.15",
63
+ "@typescript-eslint/rule-schema-to-typescript-types": "8.71.3-alpha.17",
64
+ "@typescript-eslint/rule-tester": "8.71.3-alpha.17",
65
65
  "@typescript/native": "npm:typescript@^7.0.2",
66
- "@vitest/coverage-v8": "^4.0.18",
66
+ "@vitest/coverage-v8": "^5.0.3",
67
67
  "ajv": "^6.12.6",
68
68
  "eslint": "^10.0.0",
69
69
  "json-schema": "^0.4.0",
@@ -78,10 +78,10 @@
78
78
  "tsx": "^4.7.2",
79
79
  "typescript": ">=4.8.4 <6.1.0",
80
80
  "unist-util-visit": "^5.0.0",
81
- "vitest": "^4.0.18"
81
+ "vitest": "^5.0.3"
82
82
  },
83
83
  "peerDependencies": {
84
- "@typescript-eslint/parser": "^8.71.3-alpha.15",
84
+ "@typescript-eslint/parser": "^8.71.3-alpha.17",
85
85
  "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
86
86
  "typescript": ">=4.8.4 <6.1.0"
87
87
  },