Skip to content
← Back to rules

unicorn/require-module-attributes 스타일

An auto-fix is available for this rule.

동작 방식

이 규칙은 임포트/엑스포트 문 및 import() 표현식에서 비어 있지 않은 속성 목록을 강제 적용합니다.

왜 문제가 되는가?

임포트 속성은 모듈이 어떻게 로드되어야 하는지를 설명하는 메타데이터를 제공하기 위해 사용됩니다 (예: with { type: "json" }). 비어 있는 속성 객체는 정보를 제공하지 않으며, 제거되어야 합니다.

예시

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

js
import foo from "foo" with {};

export { foo } from "foo" with {};

const foo = await import("foo", {});

const foo = await import("foo", { with: {} });

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

js
import foo from "foo";

export { foo } from "foo";

const foo = await import("foo");

const foo = await import("foo");

사용 방법

설정 파일 또는 명령줄 인터페이스에서 이 규칙을 활성화하려면 다음을 사용할 수 있습니다:

json
{
  "rules": {
    "unicorn/require-module-attributes": "error"
  }
}
bash
oxlint --deny unicorn/require-module-attributes

참고 자료