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 6c58d9ef78..98c46b487a 100644 Binary files a/test/snapshots/no-single-promise-in-promise-methods.mjs.snap and b/test/snapshots/no-single-promise-in-promise-methods.mjs.snap differ