---
url: /docs/guide/usage/linter/rules/unicorn/no-await-in-promise-methods.md
---

### 它的作用

禁止在 `Promise` 方法参数中使用 `await`。

### 为什么这不好？

在传递给 `Promise.all()`、
`Promise.allSettled()`、`Promise.any()` 或 `Promise.race()` 的参数上使用 `await`
很可能是个错误。

### 示例

以下是此规则的**错误**代码示例：

```javascript
async function foo() {
  Promise.all([await promise, anotherPromise]);
  Promise.allSettled([await promise, anotherPromise]);
  Promise.any([await promise, anotherPromise]);
  Promise.race([await promise, anotherPromise]);
}
```

以下是此规则的**正确**代码示例：

```javascript
async function foo() {
  Promise.all([promise, anotherPromise]);
  Promise.allSettled([promise, anotherPromise]);
  Promise.any([promise, anotherPromise]);
  Promise.race([promise, anotherPromise]);
}
```

## 如何使用

## 版本

此规则已在 v0.2.18 中添加。

## 参考资料
