vue/no-import-compiler-macros Restriction
What it does
Disallow importing Vue compiler macros.
Why is this bad?
Compiler Macros like:
definePropsdefineEmitsdefineExposewithDefaultsdefineModeldefineOptionsdefineSlots
are globally available in Vue 3's <script setup> and do not require explicit imports.
Examples
Examples of incorrect code for this rule:
vue
<script setup>
import { defineProps, withDefaults } from "vue";
</script>Examples of correct code for this rule:
vue
<script setup>
import { ref } from "vue";
</script>How to use
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny vue/no-import-compiler-macros --vue-pluginjson
{
"plugins": ["vue"],
"rules": {
"vue/no-import-compiler-macros": "error"
}
}