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

fix: support multiple macro calls in vue/define-macros-order #2386

Merged
merged 3 commits into from Feb 1, 2024
Merged

fix: support multiple macro calls in vue/define-macros-order #2386

merged 3 commits into from Feb 1, 2024

Conversation

hendrikheil
Copy link
Contributor

@hendrikheil hendrikheil commented Jan 30, 2024

Not a pro when it comes to AST stuff, but I think this should do it.

Should fix #2371

{
order: ['defineModel', 'defineSlots']
}
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR!
Could you also add invalid test cases with multiple defineModels?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a couple I could think of. Also one that tests that order of occurrence is maintained and not re-ordered like I suggested in the initial issue

Can you think of any other interesting cases to check?

.map((name) => ({ name, node: macrosNodes.get(name) }))
.flatMap((name) => {
const nodes = macrosNodes.get(name) ?? []
return nodes?.map((node) => ({ name, node }))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can't be undefined, since you are using ?? above.

Suggested change
return nodes?.map((node) => ({ name, node }))
return nodes.map((node) => ({ name, node }))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch ;)

Co-authored-by: Flo Edelmann <git@flo-edelmann.de>
Copy link
Member

@FloEdelmann FloEdelmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now :)

Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

@ota-meshi ota-meshi merged commit 7cb78d1 into vuejs:master Feb 1, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vue/define-macros-order does not support multiple defineModel macro calls
3 participants