unicorn/no-await-in-promise-methods 정확성
작동 방식
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]);
}사용 방법
구성 파일이나 명령줄 인터페이스를 통해 이 규칙을 활성화하려면 다음을 사용하세요:
json
{
"rules": {
"unicorn/no-await-in-promise-methods": "error"
}
}bash
oxlint --deny unicorn/no-await-in-promise-methods