From 8d28b6e99d856828354d1a97babbbb35880e4638 Mon Sep 17 00:00:00 2001 From: Clement398 <90264924+Clement398@users.noreply.github.com> Date: Sat, 22 Jun 2024 19:39:32 +0200 Subject: [PATCH] `no-single-promise-in-promise-methods`: Remove broken autofix for `Promise.all()` (#2386) Co-authored-by: fisker --- rules/no-single-promise-in-promise-methods.js | 31 +- test/no-single-promise-in-promise-methods.mjs | 153 +++-- ...o-single-promise-in-promise-methods.mjs.md | 595 ++++++++++++------ ...single-promise-in-promise-methods.mjs.snap | Bin 2274 -> 2653 bytes 4 files changed, 510 insertions(+), 269 deletions(-) diff --git a/rules/no-single-promise-in-promise-methods.js b/rules/no-single-promise-in-promise-methods.js index 94e30744a7..83bf9faacd 100644 --- a/rules/no-single-promise-in-promise-methods.js +++ b/rules/no-single-promise-in-promise-methods.js @@ -2,7 +2,10 @@ const { isCommaToken, } = require('@eslint-community/eslint-utils'); -const {isMethodCall} = require('./ast/index.js'); +const { + isMethodCall, + isExpressionStatement, +} = require('./ast/index.js'); const { getParenthesizedText, isParenthesized, @@ -77,8 +80,8 @@ const unwrapNonAwaitedCallExpression = (callExpression, sourceCode) => fixer => const switchToPromiseResolve = (callExpression, sourceCode) => function * (fixer) { /* ``` - Promise.all([promise,]) - // ^^^ methodNameNode + Promise.race([promise,]) + // ^^^^ methodNameNode ``` */ const methodNameNode = callExpression.callee.property; @@ -87,16 +90,16 @@ const switchToPromiseResolve = (callExpression, sourceCode) => function * (fixer const [arrayExpression] = callExpression.arguments; /* ``` - Promise.all([promise,]) - // ^ openingBracketToken + Promise.race([promise,]) + // ^ openingBracketToken ``` */ const openingBracketToken = sourceCode.getFirstToken(arrayExpression); /* ``` - Promise.all([promise,]) - // ^ penultimateToken - // ^ closingBracketToken + Promise.race([promise,]) + // ^ penultimateToken + // ^ closingBracketToken ``` */ const [ @@ -119,11 +122,13 @@ const create = context => ({ return; } + const methodName = callExpression.callee.property.name; + const problem = { node: callExpression.arguments[0], messageId: MESSAGE_ID_ERROR, data: { - method: callExpression.callee.property.name, + method: methodName, }, }; @@ -132,11 +137,19 @@ const create = context => ({ if ( callExpression.parent.type === 'AwaitExpression' && callExpression.parent.argument === callExpression + && ( + methodName !== 'all' + || isExpressionStatement(callExpression.parent.parent) + ) ) { problem.fix = unwrapAwaitedCallExpression(callExpression, sourceCode); return problem; } + if (methodName === 'all') { + return problem; + } + problem.suggest = [ { messageId: MESSAGE_ID_SUGGESTION_UNWRAP, diff --git a/test/no-single-promise-in-promise-methods.mjs b/test/no-single-promise-in-promise-methods.mjs index 4e73df0926..ca65a43aef 100644 --- a/test/no-single-promise-in-promise-methods.mjs +++ b/test/no-single-promise-in-promise-methods.mjs @@ -8,41 +8,41 @@ test.snapshot({ valid: [ ], invalid: [ - 'await Promise.all([(0, promise)])', - 'async function * foo() {await Promise.all([yield promise])}', - 'async function * foo() {await Promise.all([yield* promise])}', - 'await Promise.all([() => promise,],)', - 'await Promise.all([a ? b : c,],)', - 'await Promise.all([x ??= y,],)', - 'await Promise.all([x ||= y,],)', - 'await Promise.all([x &&= y,],)', - 'await Promise.all([x |= y,],)', - 'await Promise.all([x ^= y,],)', - 'await Promise.all([x ??= y,],)', - 'await Promise.all([x ||= y,],)', - 'await Promise.all([x &&= y,],)', - 'await Promise.all([x | y,],)', - 'await Promise.all([x ^ y,],)', - 'await Promise.all([x & y,],)', - 'await Promise.all([x !== y,],)', - 'await Promise.all([x == y,],)', - 'await Promise.all([x in y,],)', - 'await Promise.all([x >>> y,],)', - 'await Promise.all([x + y,],)', - 'await Promise.all([x / y,],)', - 'await Promise.all([x ** y,],)', - 'await Promise.all([promise,],)', - 'await Promise.all([getPromise(),],)', - 'await Promise.all([promises[0],],)', - 'await Promise.all([await promise])', + 'await Promise.race([(0, promise)])', + 'async function * foo() {await Promise.race([yield promise])}', + 'async function * foo() {await Promise.race([yield* promise])}', + 'await Promise.race([() => promise,],)', + 'await Promise.race([a ? b : c,],)', + 'await Promise.race([x ??= y,],)', + 'await Promise.race([x ||= y,],)', + 'await Promise.race([x &&= y,],)', + 'await Promise.race([x |= y,],)', + 'await Promise.race([x ^= y,],)', + 'await Promise.race([x ??= y,],)', + 'await Promise.race([x ||= y,],)', + 'await Promise.race([x &&= y,],)', + 'await Promise.race([x | y,],)', + 'await Promise.race([x ^ y,],)', + 'await Promise.race([x & y,],)', + 'await Promise.race([x !== y,],)', + 'await Promise.race([x == y,],)', + 'await Promise.race([x in y,],)', + 'await Promise.race([x >>> y,],)', + 'await Promise.race([x + y,],)', + 'await Promise.race([x / y,],)', + 'await Promise.race([x ** y,],)', + 'await Promise.race([promise,],)', + 'await Promise.race([getPromise(),],)', + 'await Promise.race([promises[0],],)', + 'await Promise.race([await promise])', 'await Promise.any([promise])', 'await Promise.race([promise])', - 'await Promise.all([new Promise(() => {})])', - '+await Promise.all([+1])', + 'await Promise.race([new Promise(() => {})])', + '+await Promise.race([+1])', - // ASI, `Promise.all()` is not really `await`ed + // ASI, `Promise.race()` is not really `await`ed outdent` - await Promise.all([(x,y)]) + await Promise.race([(x,y)]) [0].toString() `, ], @@ -51,54 +51,79 @@ test.snapshot({ // Not `await`ed test.snapshot({ valid: [ - 'Promise.all([promise, anotherPromise])', - 'Promise.all(notArrayLiteral)', - 'Promise.all([...promises])', + 'Promise.race([promise, anotherPromise])', + 'Promise.race(notArrayLiteral)', + 'Promise.race([...promises])', 'Promise.any([promise, anotherPromise])', 'Promise.race([promise, anotherPromise])', 'Promise.notListedMethod([promise])', - 'Promise[all]([promise])', - 'Promise.all([,])', - 'NotPromise.all([promise])', - 'Promise?.all([promise])', - 'Promise.all?.([promise])', - 'Promise.all(...[promise])', - 'Promise.all([promise], extraArguments)', - 'Promise.all()', - 'new Promise.all([promise])', + 'Promise[race]([promise])', + 'Promise.race([,])', + 'NotPromise.race([promise])', + 'Promise?.race([promise])', + 'Promise.race?.([promise])', + 'Promise.race(...[promise])', + 'Promise.race([promise], extraArguments)', + 'Promise.race()', + 'new Promise.race([promise])', // We are not checking these cases - 'globalThis.Promise.all([promise])', - 'Promise["all"]([promise])', + 'globalThis.Promise.race([promise])', + 'Promise["race"]([promise])', // This can't be checked 'Promise.allSettled([promise])', ], invalid: [ - 'Promise.all([promise,],)', + 'Promise.race([promise,],)', outdent` foo - Promise.all([(0, promise),],) + Promise.race([(0, promise),],) `, outdent` foo - Promise.all([[array][0],],) + Promise.race([[array][0],],) `, - 'Promise.all([promise]).then()', - 'Promise.all([1]).then()', - 'Promise.all([1.]).then()', - 'Promise.all([.1]).then()', - 'Promise.all([(0, promise)]).then()', - 'const _ = () => Promise.all([ a ?? b ,],)', - 'Promise.all([ {a} = 1 ,],)', - 'Promise.all([ function () {} ,],)', - 'Promise.all([ class {} ,],)', - 'Promise.all([ new Foo ,],).then()', - 'Promise.all([ new Foo ,],).toString', - 'foo(Promise.all([promise]))', - 'Promise.all([promise]).foo = 1', - 'Promise.all([promise])[0] ||= 1', - 'Promise.all([undefined]).then()', - 'Promise.all([null]).then()', + 'Promise.race([promise]).then()', + 'Promise.race([1]).then()', + 'Promise.race([1.]).then()', + 'Promise.race([.1]).then()', + 'Promise.race([(0, promise)]).then()', + 'const _ = () => Promise.race([ a ?? b ,],)', + 'Promise.race([ {a} = 1 ,],)', + 'Promise.race([ function () {} ,],)', + 'Promise.race([ class {} ,],)', + 'Promise.race([ new Foo ,],).then()', + 'Promise.race([ new Foo ,],).toString', + 'foo(Promise.race([promise]))', + 'Promise.race([promise]).foo = 1', + 'Promise.race([promise])[0] ||= 1', + 'Promise.race([undefined]).then()', + 'Promise.race([null]).then()', + ], +}); + +// `Promise.all` +test.snapshot({ + valid: [], + invalid: [ + // Only fixable if it's in `ExpressionStatement` + 'Promise.all([promise])', + 'await Promise.all([promise])', + + 'const foo = () => Promise.all([promise])', + 'const foo = await Promise.all([promise])', + 'foo = await Promise.all([promise])', + + // `Promise.{all, race}()` should not care if the result is used + 'const foo = await Promise.race([promise])', + 'const foo = () => Promise.race([promise])', + 'foo = await Promise.race([promise])', + 'const results = await Promise.any([promise])', + 'const results = await Promise.race([promise])', + + // Fixable, but not provide at this point + // https://github.com/sindresorhus/eslint-plugin-unicorn/issues/2388 + 'const [foo] = await Promise.all([promise])', ], }); diff --git a/test/snapshots/no-single-promise-in-promise-methods.mjs.md b/test/snapshots/no-single-promise-in-promise-methods.mjs.md index 4433570d96..0f2208626e 100644 --- a/test/snapshots/no-single-promise-in-promise-methods.mjs.md +++ b/test/snapshots/no-single-promise-in-promise-methods.mjs.md @@ -4,12 +4,12 @@ The actual snapshot is saved in `no-single-promise-in-promise-methods.mjs.snap`. Generated by [AVA](https://avajs.dev). -## invalid(1): await Promise.all([(0, promise)]) +## invalid(1): await Promise.race([(0, promise)]) > Input `␊ - 1 | await Promise.all([(0, promise)])␊ + 1 | await Promise.race([(0, promise)])␊ ` > Output @@ -21,16 +21,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([(0, promise)])␊ - | ^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([(0, promise)])␊ + | ^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(2): async function * foo() {await Promise.all([yield promise])} +## invalid(2): async function * foo() {await Promise.race([yield promise])} > Input `␊ - 1 | async function * foo() {await Promise.all([yield promise])}␊ + 1 | async function * foo() {await Promise.race([yield promise])}␊ ` > Output @@ -42,16 +42,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | async function * foo() {await Promise.all([yield promise])}␊ - | ^^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | async function * foo() {await Promise.race([yield promise])}␊ + | ^^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(3): async function * foo() {await Promise.all([yield* promise])} +## invalid(3): async function * foo() {await Promise.race([yield* promise])} > Input `␊ - 1 | async function * foo() {await Promise.all([yield* promise])}␊ + 1 | async function * foo() {await Promise.race([yield* promise])}␊ ` > Output @@ -63,16 +63,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | async function * foo() {await Promise.all([yield* promise])}␊ - | ^^^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | async function * foo() {await Promise.race([yield* promise])}␊ + | ^^^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(4): await Promise.all([() => promise,],) +## invalid(4): await Promise.race([() => promise,],) > Input `␊ - 1 | await Promise.all([() => promise,],)␊ + 1 | await Promise.race([() => promise,],)␊ ` > Output @@ -84,16 +84,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([() => promise,],)␊ - | ^^^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([() => promise,],)␊ + | ^^^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(5): await Promise.all([a ? b : c,],) +## invalid(5): await Promise.race([a ? b : c,],) > Input `␊ - 1 | await Promise.all([a ? b : c,],)␊ + 1 | await Promise.race([a ? b : c,],)␊ ` > Output @@ -105,16 +105,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([a ? b : c,],)␊ - | ^^^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([a ? b : c,],)␊ + | ^^^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(6): await Promise.all([x ??= y,],) +## invalid(6): await Promise.race([x ??= y,],) > Input `␊ - 1 | await Promise.all([x ??= y,],)␊ + 1 | await Promise.race([x ??= y,],)␊ ` > Output @@ -126,16 +126,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([x ??= y,],)␊ - | ^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([x ??= y,],)␊ + | ^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(7): await Promise.all([x ||= y,],) +## invalid(7): await Promise.race([x ||= y,],) > Input `␊ - 1 | await Promise.all([x ||= y,],)␊ + 1 | await Promise.race([x ||= y,],)␊ ` > Output @@ -147,16 +147,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([x ||= y,],)␊ - | ^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([x ||= y,],)␊ + | ^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(8): await Promise.all([x &&= y,],) +## invalid(8): await Promise.race([x &&= y,],) > Input `␊ - 1 | await Promise.all([x &&= y,],)␊ + 1 | await Promise.race([x &&= y,],)␊ ` > Output @@ -168,16 +168,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([x &&= y,],)␊ - | ^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([x &&= y,],)␊ + | ^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(9): await Promise.all([x |= y,],) +## invalid(9): await Promise.race([x |= y,],) > Input `␊ - 1 | await Promise.all([x |= y,],)␊ + 1 | await Promise.race([x |= y,],)␊ ` > Output @@ -189,16 +189,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([x |= y,],)␊ - | ^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([x |= y,],)␊ + | ^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(10): await Promise.all([x ^= y,],) +## invalid(10): await Promise.race([x ^= y,],) > Input `␊ - 1 | await Promise.all([x ^= y,],)␊ + 1 | await Promise.race([x ^= y,],)␊ ` > Output @@ -210,16 +210,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([x ^= y,],)␊ - | ^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([x ^= y,],)␊ + | ^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(11): await Promise.all([x ??= y,],) +## invalid(11): await Promise.race([x ??= y,],) > Input `␊ - 1 | await Promise.all([x ??= y,],)␊ + 1 | await Promise.race([x ??= y,],)␊ ` > Output @@ -231,16 +231,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([x ??= y,],)␊ - | ^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([x ??= y,],)␊ + | ^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(12): await Promise.all([x ||= y,],) +## invalid(12): await Promise.race([x ||= y,],) > Input `␊ - 1 | await Promise.all([x ||= y,],)␊ + 1 | await Promise.race([x ||= y,],)␊ ` > Output @@ -252,16 +252,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([x ||= y,],)␊ - | ^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([x ||= y,],)␊ + | ^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(13): await Promise.all([x &&= y,],) +## invalid(13): await Promise.race([x &&= y,],) > Input `␊ - 1 | await Promise.all([x &&= y,],)␊ + 1 | await Promise.race([x &&= y,],)␊ ` > Output @@ -273,16 +273,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([x &&= y,],)␊ - | ^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([x &&= y,],)␊ + | ^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(14): await Promise.all([x | y,],) +## invalid(14): await Promise.race([x | y,],) > Input `␊ - 1 | await Promise.all([x | y,],)␊ + 1 | await Promise.race([x | y,],)␊ ` > Output @@ -294,16 +294,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([x | y,],)␊ - | ^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([x | y,],)␊ + | ^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(15): await Promise.all([x ^ y,],) +## invalid(15): await Promise.race([x ^ y,],) > Input `␊ - 1 | await Promise.all([x ^ y,],)␊ + 1 | await Promise.race([x ^ y,],)␊ ` > Output @@ -315,16 +315,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([x ^ y,],)␊ - | ^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([x ^ y,],)␊ + | ^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(16): await Promise.all([x & y,],) +## invalid(16): await Promise.race([x & y,],) > Input `␊ - 1 | await Promise.all([x & y,],)␊ + 1 | await Promise.race([x & y,],)␊ ` > Output @@ -336,16 +336,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([x & y,],)␊ - | ^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([x & y,],)␊ + | ^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(17): await Promise.all([x !== y,],) +## invalid(17): await Promise.race([x !== y,],) > Input `␊ - 1 | await Promise.all([x !== y,],)␊ + 1 | await Promise.race([x !== y,],)␊ ` > Output @@ -357,16 +357,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([x !== y,],)␊ - | ^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([x !== y,],)␊ + | ^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(18): await Promise.all([x == y,],) +## invalid(18): await Promise.race([x == y,],) > Input `␊ - 1 | await Promise.all([x == y,],)␊ + 1 | await Promise.race([x == y,],)␊ ` > Output @@ -378,16 +378,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([x == y,],)␊ - | ^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([x == y,],)␊ + | ^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(19): await Promise.all([x in y,],) +## invalid(19): await Promise.race([x in y,],) > Input `␊ - 1 | await Promise.all([x in y,],)␊ + 1 | await Promise.race([x in y,],)␊ ` > Output @@ -399,16 +399,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([x in y,],)␊ - | ^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([x in y,],)␊ + | ^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(20): await Promise.all([x >>> y,],) +## invalid(20): await Promise.race([x >>> y,],) > Input `␊ - 1 | await Promise.all([x >>> y,],)␊ + 1 | await Promise.race([x >>> y,],)␊ ` > Output @@ -420,16 +420,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([x >>> y,],)␊ - | ^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([x >>> y,],)␊ + | ^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(21): await Promise.all([x + y,],) +## invalid(21): await Promise.race([x + y,],) > Input `␊ - 1 | await Promise.all([x + y,],)␊ + 1 | await Promise.race([x + y,],)␊ ` > Output @@ -441,16 +441,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([x + y,],)␊ - | ^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([x + y,],)␊ + | ^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(22): await Promise.all([x / y,],) +## invalid(22): await Promise.race([x / y,],) > Input `␊ - 1 | await Promise.all([x / y,],)␊ + 1 | await Promise.race([x / y,],)␊ ` > Output @@ -462,16 +462,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([x / y,],)␊ - | ^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([x / y,],)␊ + | ^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(23): await Promise.all([x ** y,],) +## invalid(23): await Promise.race([x ** y,],) > Input `␊ - 1 | await Promise.all([x ** y,],)␊ + 1 | await Promise.race([x ** y,],)␊ ` > Output @@ -483,16 +483,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([x ** y,],)␊ - | ^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([x ** y,],)␊ + | ^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(24): await Promise.all([promise,],) +## invalid(24): await Promise.race([promise,],) > Input `␊ - 1 | await Promise.all([promise,],)␊ + 1 | await Promise.race([promise,],)␊ ` > Output @@ -504,16 +504,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([promise,],)␊ - | ^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([promise,],)␊ + | ^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(25): await Promise.all([getPromise(),],) +## invalid(25): await Promise.race([getPromise(),],) > Input `␊ - 1 | await Promise.all([getPromise(),],)␊ + 1 | await Promise.race([getPromise(),],)␊ ` > Output @@ -525,16 +525,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([getPromise(),],)␊ - | ^^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([getPromise(),],)␊ + | ^^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(26): await Promise.all([promises[0],],) +## invalid(26): await Promise.race([promises[0],],) > Input `␊ - 1 | await Promise.all([promises[0],],)␊ + 1 | await Promise.race([promises[0],],)␊ ` > Output @@ -546,16 +546,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([promises[0],],)␊ - | ^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([promises[0],],)␊ + | ^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(27): await Promise.all([await promise]) +## invalid(27): await Promise.race([await promise]) > Input `␊ - 1 | await Promise.all([await promise])␊ + 1 | await Promise.race([await promise])␊ ` > Output @@ -567,8 +567,8 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([await promise])␊ - | ^^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([await promise])␊ + | ^^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` ## invalid(28): await Promise.any([promise]) @@ -613,12 +613,12 @@ Generated by [AVA](https://avajs.dev). | ^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(30): await Promise.all([new Promise(() => {})]) +## invalid(30): await Promise.race([new Promise(() => {})]) > Input `␊ - 1 | await Promise.all([new Promise(() => {})])␊ + 1 | await Promise.race([new Promise(() => {})])␊ ` > Output @@ -630,16 +630,16 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | await Promise.all([new Promise(() => {})])␊ - | ^^^^^^^^^^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([new Promise(() => {})])␊ + | ^^^^^^^^^^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(31): +await Promise.all([+1]) +## invalid(31): +await Promise.race([+1]) > Input `␊ - 1 | +await Promise.all([+1])␊ + 1 | +await Promise.race([+1])␊ ` > Output @@ -651,24 +651,24 @@ Generated by [AVA](https://avajs.dev). > Error 1/1 `␊ - > 1 | +await Promise.all([+1])␊ - | ^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | +await Promise.race([+1])␊ + | ^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ` -## invalid(32): await Promise.all([(x,y)]) [0].toString() +## invalid(32): await Promise.race([(x,y)]) [0].toString() > Input `␊ - 1 | await Promise.all([(x,y)])␊ + 1 | await Promise.race([(x,y)])␊ 2 | [0].toString()␊ ` > Error 1/1 `␊ - > 1 | await Promise.all([(x,y)])␊ - | ^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | await Promise.race([(x,y)])␊ + | ^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ 2 | [0].toString()␊ ␊ --------------------------------------------------------------------------------␊ @@ -682,19 +682,19 @@ Generated by [AVA](https://avajs.dev). 2 | [0].toString()␊ ` -## invalid(1): Promise.all([promise,],) +## invalid(1): Promise.race([promise,],) > Input `␊ - 1 | Promise.all([promise,],)␊ + 1 | Promise.race([promise,],)␊ ` > Error 1/1 `␊ - > 1 | Promise.all([promise,],)␊ - | ^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | Promise.race([promise,],)␊ + | ^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Use the value directly.␊ @@ -705,21 +705,21 @@ Generated by [AVA](https://avajs.dev). 1 | Promise.resolve(promise,)␊ ` -## invalid(2): foo Promise.all([(0, promise),],) +## invalid(2): foo Promise.race([(0, promise),],) > Input `␊ 1 | foo␊ - 2 | Promise.all([(0, promise),],)␊ + 2 | Promise.race([(0, promise),],)␊ ` > Error 1/1 `␊ 1 | foo␊ - > 2 | Promise.all([(0, promise),],)␊ - | ^^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 2 | Promise.race([(0, promise),],)␊ + | ^^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Use the value directly.␊ @@ -732,21 +732,21 @@ Generated by [AVA](https://avajs.dev). 2 | Promise.resolve((0, promise),)␊ ` -## invalid(3): foo Promise.all([[array][0],],) +## invalid(3): foo Promise.race([[array][0],],) > Input `␊ 1 | foo␊ - 2 | Promise.all([[array][0],],)␊ + 2 | Promise.race([[array][0],],)␊ ` > Error 1/1 `␊ 1 | foo␊ - > 2 | Promise.all([[array][0],],)␊ - | ^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 2 | Promise.race([[array][0],],)␊ + | ^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Use the value directly.␊ @@ -759,19 +759,19 @@ Generated by [AVA](https://avajs.dev). 2 | Promise.resolve([array][0],)␊ ` -## invalid(4): Promise.all([promise]).then() +## invalid(4): Promise.race([promise]).then() > Input `␊ - 1 | Promise.all([promise]).then()␊ + 1 | Promise.race([promise]).then()␊ ` > Error 1/1 `␊ - > 1 | Promise.all([promise]).then()␊ - | ^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | Promise.race([promise]).then()␊ + | ^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Use the value directly.␊ @@ -782,19 +782,19 @@ Generated by [AVA](https://avajs.dev). 1 | Promise.resolve(promise).then()␊ ` -## invalid(5): Promise.all([1]).then() +## invalid(5): Promise.race([1]).then() > Input `␊ - 1 | Promise.all([1]).then()␊ + 1 | Promise.race([1]).then()␊ ` > Error 1/1 `␊ - > 1 | Promise.all([1]).then()␊ - | ^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | Promise.race([1]).then()␊ + | ^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Use the value directly.␊ @@ -805,19 +805,19 @@ Generated by [AVA](https://avajs.dev). 1 | Promise.resolve(1).then()␊ ` -## invalid(6): Promise.all([1.]).then() +## invalid(6): Promise.race([1.]).then() > Input `␊ - 1 | Promise.all([1.]).then()␊ + 1 | Promise.race([1.]).then()␊ ` > Error 1/1 `␊ - > 1 | Promise.all([1.]).then()␊ - | ^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | Promise.race([1.]).then()␊ + | ^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Use the value directly.␊ @@ -828,19 +828,19 @@ Generated by [AVA](https://avajs.dev). 1 | Promise.resolve(1.).then()␊ ` -## invalid(7): Promise.all([.1]).then() +## invalid(7): Promise.race([.1]).then() > Input `␊ - 1 | Promise.all([.1]).then()␊ + 1 | Promise.race([.1]).then()␊ ` > Error 1/1 `␊ - > 1 | Promise.all([.1]).then()␊ - | ^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | Promise.race([.1]).then()␊ + | ^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Use the value directly.␊ @@ -851,19 +851,19 @@ Generated by [AVA](https://avajs.dev). 1 | Promise.resolve(.1).then()␊ ` -## invalid(8): Promise.all([(0, promise)]).then() +## invalid(8): Promise.race([(0, promise)]).then() > Input `␊ - 1 | Promise.all([(0, promise)]).then()␊ + 1 | Promise.race([(0, promise)]).then()␊ ` > Error 1/1 `␊ - > 1 | Promise.all([(0, promise)]).then()␊ - | ^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | Promise.race([(0, promise)]).then()␊ + | ^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Use the value directly.␊ @@ -874,19 +874,19 @@ Generated by [AVA](https://avajs.dev). 1 | Promise.resolve((0, promise)).then()␊ ` -## invalid(9): const _ = () => Promise.all([ a ?? b ,],) +## invalid(9): const _ = () => Promise.race([ a ?? b ,],) > Input `␊ - 1 | const _ = () => Promise.all([ a ?? b ,],)␊ + 1 | const _ = () => Promise.race([ a ?? b ,],)␊ ` > Error 1/1 `␊ - > 1 | const _ = () => Promise.all([ a ?? b ,],)␊ - | ^^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | const _ = () => Promise.race([ a ?? b ,],)␊ + | ^^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Use the value directly.␊ @@ -897,19 +897,19 @@ Generated by [AVA](https://avajs.dev). 1 | const _ = () => Promise.resolve( a ?? b ,)␊ ` -## invalid(10): Promise.all([ {a} = 1 ,],) +## invalid(10): Promise.race([ {a} = 1 ,],) > Input `␊ - 1 | Promise.all([ {a} = 1 ,],)␊ + 1 | Promise.race([ {a} = 1 ,],)␊ ` > Error 1/1 `␊ - > 1 | Promise.all([ {a} = 1 ,],)␊ - | ^^^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | Promise.race([ {a} = 1 ,],)␊ + | ^^^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Use the value directly.␊ @@ -920,19 +920,19 @@ Generated by [AVA](https://avajs.dev). 1 | Promise.resolve( {a} = 1 ,)␊ ` -## invalid(11): Promise.all([ function () {} ,],) +## invalid(11): Promise.race([ function () {} ,],) > Input `␊ - 1 | Promise.all([ function () {} ,],)␊ + 1 | Promise.race([ function () {} ,],)␊ ` > Error 1/1 `␊ - > 1 | Promise.all([ function () {} ,],)␊ - | ^^^^^^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | Promise.race([ function () {} ,],)␊ + | ^^^^^^^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Use the value directly.␊ @@ -943,19 +943,19 @@ Generated by [AVA](https://avajs.dev). 1 | Promise.resolve( function () {} ,)␊ ` -## invalid(12): Promise.all([ class {} ,],) +## invalid(12): Promise.race([ class {} ,],) > Input `␊ - 1 | Promise.all([ class {} ,],)␊ + 1 | Promise.race([ class {} ,],)␊ ` > Error 1/1 `␊ - > 1 | Promise.all([ class {} ,],)␊ - | ^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | Promise.race([ class {} ,],)␊ + | ^^^^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Use the value directly.␊ @@ -966,19 +966,19 @@ Generated by [AVA](https://avajs.dev). 1 | Promise.resolve( class {} ,)␊ ` -## invalid(13): Promise.all([ new Foo ,],).then() +## invalid(13): Promise.race([ new Foo ,],).then() > Input `␊ - 1 | Promise.all([ new Foo ,],).then()␊ + 1 | Promise.race([ new Foo ,],).then()␊ ` > Error 1/1 `␊ - > 1 | Promise.all([ new Foo ,],).then()␊ - | ^^^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | Promise.race([ new Foo ,],).then()␊ + | ^^^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Use the value directly.␊ @@ -989,19 +989,19 @@ Generated by [AVA](https://avajs.dev). 1 | Promise.resolve( new Foo ,).then()␊ ` -## invalid(14): Promise.all([ new Foo ,],).toString +## invalid(14): Promise.race([ new Foo ,],).toString > Input `␊ - 1 | Promise.all([ new Foo ,],).toString␊ + 1 | Promise.race([ new Foo ,],).toString␊ ` > Error 1/1 `␊ - > 1 | Promise.all([ new Foo ,],).toString␊ - | ^^^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | Promise.race([ new Foo ,],).toString␊ + | ^^^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Use the value directly.␊ @@ -1012,19 +1012,19 @@ Generated by [AVA](https://avajs.dev). 1 | Promise.resolve( new Foo ,).toString␊ ` -## invalid(15): foo(Promise.all([promise])) +## invalid(15): foo(Promise.race([promise])) > Input `␊ - 1 | foo(Promise.all([promise]))␊ + 1 | foo(Promise.race([promise]))␊ ` > Error 1/1 `␊ - > 1 | foo(Promise.all([promise]))␊ - | ^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | foo(Promise.race([promise]))␊ + | ^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Use the value directly.␊ @@ -1035,19 +1035,19 @@ Generated by [AVA](https://avajs.dev). 1 | foo(Promise.resolve(promise))␊ ` -## invalid(16): Promise.all([promise]).foo = 1 +## invalid(16): Promise.race([promise]).foo = 1 > Input `␊ - 1 | Promise.all([promise]).foo = 1␊ + 1 | Promise.race([promise]).foo = 1␊ ` > Error 1/1 `␊ - > 1 | Promise.all([promise]).foo = 1␊ - | ^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | Promise.race([promise]).foo = 1␊ + | ^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Use the value directly.␊ @@ -1058,19 +1058,19 @@ Generated by [AVA](https://avajs.dev). 1 | Promise.resolve(promise).foo = 1␊ ` -## invalid(17): Promise.all([promise])[0] ||= 1 +## invalid(17): Promise.race([promise])[0] ||= 1 > Input `␊ - 1 | Promise.all([promise])[0] ||= 1␊ + 1 | Promise.race([promise])[0] ||= 1␊ ` > Error 1/1 `␊ - > 1 | Promise.all([promise])[0] ||= 1␊ - | ^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | Promise.race([promise])[0] ||= 1␊ + | ^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Use the value directly.␊ @@ -1081,19 +1081,19 @@ Generated by [AVA](https://avajs.dev). 1 | Promise.resolve(promise)[0] ||= 1␊ ` -## invalid(18): Promise.all([undefined]).then() +## invalid(18): Promise.race([undefined]).then() > Input `␊ - 1 | Promise.all([undefined]).then()␊ + 1 | Promise.race([undefined]).then()␊ ` > Error 1/1 `␊ - > 1 | Promise.all([undefined]).then()␊ - | ^^^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | Promise.race([undefined]).then()␊ + | ^^^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Use the value directly.␊ @@ -1104,19 +1104,19 @@ Generated by [AVA](https://avajs.dev). 1 | Promise.resolve(undefined).then()␊ ` -## invalid(19): Promise.all([null]).then() +## invalid(19): Promise.race([null]).then() > Input `␊ - 1 | Promise.all([null]).then()␊ + 1 | Promise.race([null]).then()␊ ` > Error 1/1 `␊ - > 1 | Promise.all([null]).then()␊ - | ^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + > 1 | Promise.race([null]).then()␊ + | ^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Use the value directly.␊ @@ -1126,3 +1126,206 @@ Generated by [AVA](https://avajs.dev). Suggestion 2/2: Switch to \`Promise.resolve(…)\`.␊ 1 | Promise.resolve(null).then()␊ ` + +## invalid(1): Promise.all([promise]) + +> Input + + `␊ + 1 | Promise.all([promise])␊ + ` + +> Error 1/1 + + `␊ + > 1 | Promise.all([promise])␊ + | ^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + ` + +## invalid(2): await Promise.all([promise]) + +> Input + + `␊ + 1 | await Promise.all([promise])␊ + ` + +> Output + + `␊ + 1 | await promise␊ + ` + +> Error 1/1 + + `␊ + > 1 | await Promise.all([promise])␊ + | ^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + ` + +## invalid(3): const foo = () => Promise.all([promise]) + +> Input + + `␊ + 1 | const foo = () => Promise.all([promise])␊ + ` + +> Error 1/1 + + `␊ + > 1 | const foo = () => Promise.all([promise])␊ + | ^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + ` + +## invalid(4): const foo = await Promise.all([promise]) + +> Input + + `␊ + 1 | const foo = await Promise.all([promise])␊ + ` + +> Error 1/1 + + `␊ + > 1 | const foo = await Promise.all([promise])␊ + | ^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + ` + +## invalid(5): foo = await Promise.all([promise]) + +> Input + + `␊ + 1 | foo = await Promise.all([promise])␊ + ` + +> Error 1/1 + + `␊ + > 1 | foo = await Promise.all([promise])␊ + | ^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + ` + +## invalid(6): const foo = await Promise.race([promise]) + +> Input + + `␊ + 1 | const foo = await Promise.race([promise])␊ + ` + +> Output + + `␊ + 1 | const foo = await promise␊ + ` + +> Error 1/1 + + `␊ + > 1 | const foo = await Promise.race([promise])␊ + | ^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ + ` + +## invalid(7): const foo = () => Promise.race([promise]) + +> Input + + `␊ + 1 | const foo = () => Promise.race([promise])␊ + ` + +> Error 1/1 + + `␊ + > 1 | const foo = () => Promise.race([promise])␊ + | ^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ + ␊ + --------------------------------------------------------------------------------␊ + Suggestion 1/2: Use the value directly.␊ + 1 | const foo = () => promise␊ + ␊ + --------------------------------------------------------------------------------␊ + Suggestion 2/2: Switch to \`Promise.resolve(…)\`.␊ + 1 | const foo = () => Promise.resolve(promise)␊ + ` + +## invalid(8): foo = await Promise.race([promise]) + +> Input + + `␊ + 1 | foo = await Promise.race([promise])␊ + ` + +> Output + + `␊ + 1 | foo = await promise␊ + ` + +> Error 1/1 + + `␊ + > 1 | foo = await Promise.race([promise])␊ + | ^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ + ` + +## invalid(9): const results = await Promise.any([promise]) + +> Input + + `␊ + 1 | const results = await Promise.any([promise])␊ + ` + +> Output + + `␊ + 1 | const results = await promise␊ + ` + +> Error 1/1 + + `␊ + > 1 | const results = await Promise.any([promise])␊ + | ^^^^^^^^^ Wrapping single-element array with \`Promise.any()\` is unnecessary.␊ + ` + +## invalid(10): const results = await Promise.race([promise]) + +> Input + + `␊ + 1 | const results = await Promise.race([promise])␊ + ` + +> Output + + `␊ + 1 | const results = await promise␊ + ` + +> Error 1/1 + + `␊ + > 1 | const results = await Promise.race([promise])␊ + | ^^^^^^^^^ Wrapping single-element array with \`Promise.race()\` is unnecessary.␊ + ` + +## invalid(11): const [foo] = await Promise.all([promise]) + +> Input + + `␊ + 1 | const [foo] = await Promise.all([promise])␊ + ` + +> Error 1/1 + + `␊ + > 1 | const [foo] = await Promise.all([promise])␊ + | ^^^^^^^^^ Wrapping single-element array with \`Promise.all()\` is unnecessary.␊ + ` diff --git a/test/snapshots/no-single-promise-in-promise-methods.mjs.snap b/test/snapshots/no-single-promise-in-promise-methods.mjs.snap index 6c58d9ef78bb5ac9b9a3d7df1ff568b36610cb4e..98c46b487a75c592eca011f8ec43623aaf3cebdc 100644 GIT binary patch literal 2653 zcmV-j3ZnHvRzVAGn?3oEupkGD4FbdztvWd(Qhl`^}s==ge#C=PalBefP@pRl_qq%h*;;`@C+M zYl>D{Wcmf&^w?u9=PA=Q)Rx{flvQQA%C`3ZrBpAOuB~smn~vu`eRXY3_w*+gzA$#% zSm!hT#j!ia%M*-gY*#{Q!m#vnhGjfrZ?!#NO95JU0j+pzzwP>?Z7*v4M!fNn=f@_N zWqZOHW4jFbG{A>_ucdEonf3;AO?$&KP8gQ)lwo^JZ?*ItcER*E*;(*KrL)X*S=+Xa zrs2AJYe)5aZk}qjoEFojv>=CvgB)s|9NZnd$=2I;(=#2LmD#%EC?$3g8_SMqSZl#( z>ZQGOLXQJi9}HYQz;|HTJqW(#q|~=4KseNex&9sG`bn7ULHbW7PJJ2!MB$MDg_$fU zl({UN1}UA&%0gKH!zu7J^F6>&7SQlHpyBtKX(;E3Lw|YD0v=|m5?x|T%fWc6^(s=O z?+1aL;8p3Q7?y7Z$bA(SYM_AE>UTkkFLP^ksy~wDy3eVc2vV6NQqkE8JI5AT6HjCw zSXkmD0)((MjsvMXVH#m;Jc+9yiRXApz{a<1h(1A$`aeb{htG-9q0HT zlfm3S286x>-S^w#-oFaGf0pNcyblu2561U-()ZonTzn5@GWgzYn}hFB9}4690_pqY zWG=pkG8ugDw#~u!s1L*Ty&U*{AI&>y`z&y4l8-yb^`k)N%PHDP(_aCm|5yOK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