Skip to content

vue/define-macros-order #1855

Closed
Closed
@edikdeisling

Description

@edikdeisling

Please describe what the rule should do:

There are defineEmits and defineProps macros in script setup.
It would be nice to have a rule that moves these macros on top of the file.

What category should the rule belong to?

[x] Enforces code style (layout)
[ ] Warns about a potential error (problem)
[ ] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

<!-- ✓ GOOD -->
<script setup>
defineEmits(/* ... */)
defineProps(/* ... */)
/* some code here */
</script>
<!-- ✗ BAD -->
<script setup>
/* some code here */
const bar = ref()
/* some code here */
defineEmits(/* ... */)
/* some code here */
defineProps(/* ... */)
</script>

Additional context

We write code this way in my company. Maybe it's a convenient way to define props/emits on the top.
If it would be helpful I'd like to create this eslint rule.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions