unicorn/no-await-in-promise-methods 正确性
作用
禁止在 Promise 方法参数中使用 await
为什么这不好?
对作为 Promise.all()、Promise.allSettled()、Promise.any() 或 Promise.race() 参数传递的 Promise 使用 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]);
}