Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork698
fix(define-macros-order): improve report messages#2953
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…dering errors (vuejs#2940)Separate error messages for two distinct cases:- macrosNotAtTop: when a macro comes after non-macro statements- macrosUnordered: when macros are not in the correct order relative to each otherThis provides clearer feedback to users about what needs to be fixed.
changeset-botbot commentedNov 11, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
🦋 Changeset detectedLatest commit:41323da The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means?Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
FloEdelmann left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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! I only have one code style improvement suggestion.
Is this PR deliberately still in draft status?
Uh oh!
There was an error while loading.Please reload this page.
kzhrk commentedNov 11, 2025
No, I was just waiting for the CI 😴 |
Use array.find() instead of a for loop with break statement for a moreidiomatic and readable approach to finding the macro name.Co-authored-by: Flo Edelmann <git@flo-edelmann.de>
FloEdelmann left a comment
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.
Looks good to me now, thank you! 🙂
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.
Pull Request Overview
This PR improves error messages for thevue/define-macros-order ESLint rule by introducing two distinct message types to better communicate the specific issue to users.
Key Changes:
- Added two message types:
macrosNotAtTop(when a macro comes after non-macro statements) andmacrosUnordered(when macros are in the wrong order relative to each other) - Updated the
reportNotOnTop()function to detect whether the target statement is a macro and select the appropriate message - Updated all 42 test cases to use the new message helper functions
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
lib/rules/define-macros-order.js | EnhancedreportNotOnTop() function to detect whether the blocking statement is a macro and select appropriate error message; addedmacrosUnordered message definition |
tests/lib/rules/define-macros-order.js | Renamed message helper function frommessage() tonotAtTopMessage(), addedunorderedMessage() helper, and updated all test expectations to use the appropriate message for each scenario |
.changeset/improve-define-macros-order-messages.md | Added changeset documenting the improvement as a patch-level change |
💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.
Closes#2940
Summary
Improves error messages for the
vue/define-macros-orderrule to distinguish between two distinct cases:console.log())Motivation
Previously, the rule always reported: "X should be the first statement in
<script setup>", which was confusing when multiple macros were out of order.Users couldn't easily understand whether they needed to move a macro to the top or reorder it relative to other macros.
With this improvement, users get more specific feedback:
<script setup>" - when it's after a non-macroThis makes it much clearer what action is needed to fix the issue.
Changes
macrosNotAtTopandmacrosUnorderedreportNotOnTop()function to detect whether the target statement is a macro from the order listmacrosUnorderedwhen the target is a macro,macrosNotAtTopotherwise