-
-
Notifications
You must be signed in to change notification settings - Fork 667
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
feat(define-macros-order): add defineExposeLast
option
#2349
feat(define-macros-order): add defineExposeLast
option
#2349
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks really good to me! 🙂
I couldn't come up with a better option name. I shortly thought about extending it to an array (something like orderLast
), but I'm not sure if that's worth the effort or if defineExpose
is the only macro for which it makes sense to put it at the end.
Introducing a new
In my personal practice, yes. |
If we'd introduce that But if |
Putting
Just curious, are there similar references that need to be restricted in the options? I'm not sure whether to enforce this in the JSON schema or to trigger an error in the code logic.🤔 |
It's not possible in JSON schema. And it looks like we don't already do the same in another rule. But we could either throw an error, or just ignore values in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! 🙂
lib/rules/define-macros-order.js
Outdated
loc: node.loc, | ||
messageId: 'defineExposeNotTheLast', | ||
fix(fixer) { | ||
return moveNodeToLast(fixer, node, lastNode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that probably shouldn't support auto-fix. It may break user's code.
<script setup>
let a = 1
defineExpose({a})
a = 2
</script>
What do you think about supporting suggestions instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late response. It seems reasonable to me not to support auto-fix, thanks for pointing out!
I'll add to suggestion
and refine the test cases.
5fc8bed
to
3c704bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you!
will close #2235
I'll be thankful for any suggestions on these TODOs.
defineExpose
within theorder
schema? There is a potential conflict in the options, like:{ order: ['defineExpose', 'defineProps'], defineExposeLast: true }
.