This rule raises an issue when Promise.all(), Promise.any(), or Promise.race() is called with an array
containing exactly one element.
Passing single-element arrays to Promise methods like Promise.all(), Promise.any(), or Promise.race() is
usually a mistake that adds unnecessary complexity.
These methods are designed to handle multiple asynchronous operations concurrently. When you pass a single-element array, you’re not taking advantage of their core functionality - coordinating multiple promises.
For example, Promise.all([singlePromise]) does the same thing as just awaiting singlePromise directly, but with extra
overhead and less readable code. The array wrapper serves no purpose and can confuse other developers about your intentions.
This pattern often appears when:
Using the promise directly makes your code cleaner, more performant, and clearer about your actual intent.
This issue reduces code readability and adds unnecessary complexity. While it doesn’t cause runtime errors, it can confuse other developers and indicates a misunderstanding of Promise APIs. The extra array allocation and method call also create minor performance overhead.
Remove the array wrapper and await the promise directly. This is cleaner and more efficient than using Promise methods with single elements.
const result = await Promise.all([promise]); // Noncompliant
const result = await promise;