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

> Disallow `await` on the elements of the array passed to `Promise.all()` and similar methods

`Promise.all([await loadUser(), await loadPosts()])` waits for the user before it starts loading the posts. The requests run one after the other, and `Promise.all()` only gets finished values, so it has nothing left to do. With `Promise.race()` and `Promise.any()`, there's no race either.

The rule checks `Promise.all()`, `Promise.allSettled()`, `Promise.any()`, and `Promise.race()`.

`--fix-suggestions` removes the `await`.

{/* 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-await-in-promise-methods" = "error" # or "warn"
```

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

## Examples

Reported:

{/* bad {"count": 2} */}
```js
async function loadPage(id) {
  const [user, posts] = await Promise.all([await loadUser(id), await loadPosts(id)]);
  render(user, posts);
}
```

Not reported:

{/* good */}
```js
async function loadPage(id) {
  const [user, posts] = await Promise.all([loadUser(id), loadPosts(id)]);
  render(user, posts);
}
```
