Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue/define-macros-order #1855

Closed
edikdeisling opened this issue Apr 19, 2022 · 0 comments · Fixed by #1856
Closed

vue/define-macros-order #1855

edikdeisling opened this issue Apr 19, 2022 · 0 comments · Fixed by #1856

Comments

@edikdeisling
Copy link
Contributor

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.

edikdeisling added a commit to edikdeisling/eslint-plugin-vue that referenced this issue Apr 19, 2022
@FloEdelmann FloEdelmann linked a pull request Apr 19, 2022 that will close this issue
edikdeisling added a commit to edikdeisling/eslint-plugin-vue that referenced this issue Apr 19, 2022
ota-meshi pushed a commit that referenced this issue Apr 21, 2022
* Add new rule: vue/define-macros-order (#1855)

* Fix review comments

* Add review case

* Fix review comments

* Fix review comments

* Add semicolons

* Add some newline heuristics

* Fix slice review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants