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

feat(no-import-compiler-macros): clarify that macros are not allowed outside<script setup>#2938

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

Conversation

@Sysix
Copy link
Contributor

@SysixSysix commentedOct 4, 2025
edited
Loading

After reading#2437, I found out that the compiler warnings are only reported at<script setup>:
https://github.com/vuejs/core/blob/c16f8a94c7eda79f51f44b7b3c64c72343df0d38/packages/compiler-sfc/src/compileScript.ts#L321-L355

Changed the rule to report another message when macros are found outside<script setup>.

@changeset-bot
Copy link

changeset-botbot commentedOct 4, 2025
edited
Loading

🦋 Changeset detected

Latest commit:b4e550c

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

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

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

@SysixSysix changed the titlerefactor(no-import-compiler-macros): check only in<script setup>fix(no-import-compiler-macros): check only in<script setup>Oct 4, 2025
@SysixSysix marked this pull request as ready for reviewOctober 4, 2025 15:44
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.

It's true that Vue emits the runtime warning only in<script setup>, but I think that is because the compiler macros are only available in<script setup>. So while it would be more correct for the ESLint rule to only report compiler macro imports in<script setup>, it would not really make sense to import them outside<script setup>, too, would it?

@Sysix
Copy link
ContributorAuthor

it would not really make sense to import them outside <script setup>, too, would it?

That was my guess too. But they can be wrongly imported by the user.
Do not know what the bundler/vue-compiler will do. Maybe a new ESLint rule likeno-compilier-macros-outside-script-setup?

Updated the tests 👍

@FloEdelmann
Copy link
Member

But they can be wrongly imported by the user.

But thevue/no-import-compiler-macros already warns about that case, while this PR removes exactly this warning. So I think the current behavior is better.

Do you agree? If so, feel free to update the PR to only improve test coverage for the non-<script setup> case. Otherwise, I'm open for discussion 🙂

@Sysix
Copy link
ContributorAuthor

I would prefer an own error/diagnostic message for using compiler macros outside Vue files.
Do you think it is okay to include it in this rule?
Something like

'{{name}} is a compiler macro and is only valid inside `<script>`with "setup".
FloEdelmann reacted with thumbs up emoji

@FloEdelmann
Copy link
Member

Changing the message based on whether the import occurs inside<script setup> or not seems like a good improvement to me 🙂 👍

Sysix reacted with heart emoji

@SysixSysix marked this pull request as draftOctober 14, 2025 20:36
@SysixSysix changed the titlefix(no-import-compiler-macros): check only in<script setup>fix(no-import-compiler-macros): make it clear that macros are not allowed outside<script setup>Oct 31, 2025
@SysixSysix marked this pull request as ready for reviewOctober 31, 2025 15:15
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.

Thanks, looks good to me now 🙂

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 updates thevue/no-import-compiler-macros rule to provide a clearer error message when compiler macros are imported outside of<script setup> blocks. Instead of saying macros "don't need to be imported" (which could be confusing when not in<script setup>), the new message clarifies that these macros "can only be used inside<script setup>".

Key changes:

  • Added a new error messageonlyValidInScriptSetup for contexts outside<script setup>
  • Updated the rule logic to useutils.isScriptSetup() to determine which message to display
  • Added test coverage for non-<script setup> scenarios (regular<script> blocks and TypeScript files)

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

FileDescription
lib/rules/no-import-compiler-macros.jsImportsutils module, adds new error message, and conditionally selects the appropriate message based on script context
tests/lib/rules/no-import-compiler-macros.jsAdds test cases for compiler macro imports in non-setup contexts (regular script and .ts file)
.changeset/lemon-socks-follow.mdDocuments the change as a minor version bump with a description of the improvement

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

@FloEdelmannFloEdelmann merged commit5ec36ce intovuejs:masterOct 31, 2025
21 checks passed
@FloEdelmannFloEdelmann changed the titlefix(no-import-compiler-macros): make it clear that macros are not allowed outside<script setup>feat(no-import-compiler-macros): clarify that macros are not allowed outside<script setup>Oct 31, 2025
@github-actionsgithub-actionsbot mentioned this pull requestOct 30, 2025
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.

2 participants

@Sysix@FloEdelmann

[8]ページ先頭

©2009-2025 Movatter.jp