Promise.all or a sibling combines a list of only one promise
What it finds
Promise.all([load()]) combines a single promise, which waits for nothing more than load() alone but wraps the result in an array; Promise.race and Promise.any of one promise are that promise with a detour.
Reported are calls of all, allSettled, race and any on the global Promise with an array literal of exactly one element that is not a spread.
From the rule's source, promise_all_single.rs.
export async function load(a: Promise<number>, b: Promise<number>, list: Promise<number>[]) { const [x] = await Promise.all([a]);tx0 reports: holds a single promise const y = await Promise.all([a, b]); const z = await Promise.all([...list]); return [x, y, z];} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/ts:promise-all-single" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/ts:promise-all-single] reason="..."tx0 explain tx0/ts:promise-all-single shows the same in the terminal. Found a false positive? Report it.