Skip to content
← Back to rules

unicorn/no-thenable 정확성

This rule is turned on by default.

작동 방식

then 속성을 금지합니다.

왜 문제가 될까요?

객체가 "thenable"으로 정의된 경우, 실수로 await 표현식에서 사용되면 문제가 발생할 수 있습니다:

예시

이 규칙에 부적절한 코드 예시:

javascript
async function example() {
  const foo = {
    unicorn: 1,
    then() {},
  };

  const { unicorn } = await foo;

  console.log("after"); //<- 이 코드는 절대 실행되지 않습니다
}

이 규칙에 적절한 코드 예시:

javascript
async function example() {
  const foo = {
    unicorn: 1,
    bar() {},
  };

  const { unicorn } = await foo;

  console.log("after");
}

사용 방법

구성 파일 또는 명령줄 인터페이스를 통해 이 규칙을 활성화하려면 다음을 사용하세요:

json
{
  "rules": {
    "unicorn/no-thenable": "error"
  }
}
bash
oxlint --deny unicorn/no-thenable

참고 자료