Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
kzhrk wants to merge2 commits intovuejs:master
base:master
Choose a base branch
Loading
fromkzhrk:issue-2940

Conversation

@kzhrk
Copy link
Contributor

Closes#2940

Summary

Improves error messages for thevue/define-macros-order rule to distinguish between two distinct cases:

  1. macrosNotAtTop: When a macro comes after non-macro statements (e.g.,console.log())
  2. macrosUnordered: When macros are not in the correct order relative to each other

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:

  • "defineModel should be placed at the top of<script setup>" - when it's after a non-macro
  • "defineModel should be above defineEmits" - when it's in the wrong order with other macros

This makes it much clearer what action is needed to fix the issue.

Changes

  • Updated messages object with two new message types:macrosNotAtTop andmacrosUnordered
  • ModifiedreportNotOnTop() function to detect whether the target statement is a macro from the order list
  • UsesmacrosUnordered when the target is a macro,macrosNotAtTop otherwise
  • Updated all test expectations to match the new behavior (42 tests passing)

…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-bot
Copy link

changeset-botbot commentedNov 11, 2025
edited
Loading

🦋 Changeset detected

Latest commit:41323da

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
NameType
eslint-plugin-vuePatch

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

Copy link
Member

@FloEdelmannFloEdelmann left a comment
edited
Loading

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?

@FloEdelmannFloEdelmann changed the titlefix(define-macros-order): distinguish between macros placement and ordering errors (#2940)fix(define-macros-order): improve report messagesNov 11, 2025
@kzhrk
Copy link
ContributorAuthor

@FloEdelmann

Is this PR deliberately still in draft status?

No, I was just waiting for the CI 😴
I'll check your suggestion.

@kzhrkkzhrk marked this pull request as ready for reviewNovember 11, 2025 15:16
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>
Copy link
Member

@FloEdelmannFloEdelmann left a 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! 🙂

kzhrk reacted with heart emoji
Copy link
Contributor

CopilotAI left a 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 thereportNotOnTop() 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.

FileDescription
lib/rules/define-macros-order.jsEnhancedreportNotOnTop() function to detect whether the blocking statement is a macro and select appropriate error message; addedmacrosUnordered message definition
tests/lib/rules/define-macros-order.jsRenamed 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.mdAdded changeset documenting the improvement as a patch-level change

💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

Copilot code reviewCopilotCopilot left review comments

@FloEdelmannFloEdelmannFloEdelmann approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

vue/define-macros-order confusing error message

2 participants

@kzhrk@FloEdelmann

[8]ページ先頭

©2009-2025 Movatter.jp