vue/no-import-compiler-macros Restriction
What it does
Disallow importing Vue compiler macros.
Why is this bad?
Compiler Macros like:
defineProps
defineEmits
defineExpose
withDefaults
defineModel
defineOptions
defineSlots
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-plugin
json
{
"plugins": ["vue"],
"rules": {
"vue/no-import-compiler-macros": "error"
}
}