pageClass | sidebarDepth | title | description | since |
---|---|---|---|---|
rule-details |
0 |
vue/define-macros-order |
enforce order of `defineEmits` and `defineProps` compiler macros |
v8.7.0 |
enforce order of
defineEmits
anddefineProps
compiler macros
- 🔧 The
--fix
option on the command line can automatically fix some of the problems reported by this rule.
This rule reports the defineProps
and defineEmits
compiler macros when they are not the first statements in <script setup>
(after any potential import statements or type definitions) or when they are not in the correct order.
{
"vue/define-macros-order": ["error", {
"order": ["defineProps", "defineEmits"]
}]
}
order
(string[]
) ... The order of defineEmits and defineProps macros. You can also add"defineOptions"
and"defineSlots"
.
<!-- ✓ GOOD -->
<script setup>
defineProps(/* ... */)
defineEmits(/* ... */)
</script>
<!-- ✗ BAD -->
<script setup>
defineEmits(/* ... */)
defineProps(/* ... */)
</script>
<!-- ✗ BAD -->
<script setup>
const bar = ref()
defineProps(/* ... */)
defineEmits(/* ... */)
</script>
<!-- ✓ GOOD -->
<script setup>
defineOptions({/* ... */})
defineProps(/* ... */)
defineEmits(/* ... */)
const slots = defineSlots()
</script>
<!-- ✗ BAD -->
<script setup>
defineEmits(/* ... */)
const slots = defineSlots()
defineProps(/* ... */)
defineOptions({/* ... */})
</script>
<!-- ✗ BAD -->
<script setup>
const bar = ref()
defineOptions({/* ... */})
defineProps(/* ... */)
defineEmits(/* ... */)
const slots = defineSlots()
</script>
This rule was introduced in eslint-plugin-vue v8.7.0