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

Allow specifying custom macros in vue/define-macros-order #2499

Closed
Ericlm opened this issue Jul 7, 2024 · 1 comment · Fixed by #2501
Closed

Allow specifying custom macros in vue/define-macros-order #2499

Ericlm opened this issue Jul 7, 2024 · 1 comment · Fixed by #2501

Comments

@Ericlm
Copy link
Contributor

Ericlm commented Jul 7, 2024

What rule do you want to change?
I would like to update the define-macros-order rule.

Does this change cause the rule to produce more or fewer warnings?
More.

How will the change be implemented? (New option, new default behavior, etc.)?
With the unplugging-vue-router which allows routes to be typesafe, there is now a new definePage macro that allows to customize the generated route.

I think this macro should be ordered just like defineProps, emits, slots etc. I think it could be at the top of the component, even before defineModel.

Please provide some example code that this change will affect:

<script setup lang="ts">
import { useRouter } from 'vue-router'

const router = useRouter()

definePage({}) // Can be placed anywhere

function hello(): void {
  router.push({ name: '/' })
}
</script>

What does the rule currently do for this code?
The rule does not enforce a location for definePage, so it can be placed anywhere in the script.

What will the rule do after it's changed?
It will enforce the definePage macro to be at the top of the script (or elsewhere).

@FloEdelmann
Copy link
Member

FloEdelmann commented Jul 8, 2024

Unplugin Vue Router will not be officially supported in eslint-plugin-vue, so this feature request is out of scope.

But you can already adjust the order manually. I think it should be possible to allow custom values there, so that you could add definePage there manually. Pull request welcome for that change!

@FloEdelmann FloEdelmann changed the title define-macros-order - Adding definePage Allow specifying custom macros in vue/define-macros-order Jul 8, 2024
@FloEdelmann FloEdelmann linked a pull request Jul 9, 2024 that will close this issue
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