Skip to content
← Back to rules

vue/no-import-compiler-macros 제한

⚠️🛠️ A dangerous auto-fix is available for this rule.

작동 방식

Vue 컴파일러 매크로를 가져오는 것을 금지합니다.

왜 나쁜가요?

다음과 같은 컴파일러 매크로는:

  • defineProps
  • defineEmits
  • defineExpose
  • withDefaults
  • defineModel
  • defineOptions
  • defineSlots

Vue 3의 <script setup>에서 전역적으로 사용 가능하며, 명시적인 가져오기가 필요하지 않습니다.

예시

이 규칙에 대한 잘못된 코드 예시:

vue
<script setup>
import { defineProps, withDefaults } from "vue";
</script>

이 규칙에 대한 올바른 코드 예시:

vue
<script setup>
import { ref } from "vue";
</script>

사용 방법

설정 파일이나 명령줄 인터페이스를 통해 이 규칙을 활성화하려면 다음을 사용할 수 있습니다:

json
{
  "plugins": ["vue"],
  "rules": {
    "vue/no-import-compiler-macros": "error"
  }
}
bash
oxlint --deny vue/no-import-compiler-macros --vue-plugin

참고 자료