# unicorn/no-single-promise-in-promise-methods

> Disallow an array with one item in `Promise.all()`, `Promise.any()`, and `Promise.race()`

`Promise.all()`, `Promise.any()`, and `Promise.race()` combine several promises. With one promise there's nothing to combine, so you can await it directly. It's often what's left after someone removed the other items from the array.

`--fix` unwraps the promise in simple cases, such as the statement `await Promise.all([promise]);`. It leaves a call alone when its result is stored in a variable, returned, or passed to a function.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"unicorn/no-single-promise-in-promise-methods" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 3} */}
```js
async function refresh() {
  await Promise.all([saveDraft()]);
  const [user] = await Promise.all([loadUser()]);
  const posts = await Promise.race([loadPosts()]);
  return { user, posts };
}
```

Not reported:

{/* good */}
```js
async function refresh() {
  await saveDraft();
  const user = await loadUser();
  const posts = await loadPosts();
  return { user, posts };
}
```

An array with several items, a spread, or a variable is fine:

{/* good */}
```js
async function refresh(tasks) {
  await Promise.all([loadUser(), loadPosts()]);
  await Promise.all([...tasks]);
  await Promise.all(tasks);
}
```
