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(prefer-template-ref): support auto-fix#2983

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

Draft
9romise wants to merge9 commits intovuejs:master
base:master
Choose a base branch
Loading
from9romise:prefer-template-ref/auto-fix

Conversation

@9romise
Copy link
Contributor

@9romise9romise commentedNov 27, 2025
edited by FloEdelmann
Loading

Re-implement of#2632 (closes#2632). (I really love this feature!)
But this PR doesn't insertimport { useTemplateRef } from 'vue' automatically.
Because I think that falls outside the scope of this rule. Additionally, some users rely onunplugin-auto-import and would have to remove the unnecessary import to maintain clean imports.

Please merge#2982 first.

FloEdelmann reacted with thumbs up emoji
@changeset-bot
Copy link

changeset-botbot commentedNov 27, 2025
edited
Loading

⚠️ No Changeset found

Latest commit:c0ebec0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go.If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@9romise9romise marked this pull request as ready for reviewNovember 28, 2025 01:27
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, thank you 🙂

9romise 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 implements auto-fix functionality for theprefer-use-template-ref rule, which automatically convertsref() andshallowRef() calls touseTemplateRef('name') when they are used as template refs. The implementation intentionally does not auto-importuseTemplateRef to avoid conflicts with users who rely onunplugin-auto-import.

  • Addsfixable: 'code' metadata to enable auto-fixing
  • Implements fixer logic that correctly handles TypeScript type arguments/parameters
  • Updates all test cases with expected outputs and enhanced error location information

Reviewed changes

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

FileDescription
lib/rules/prefer-use-template-ref.jsAdds fixable metadata and implements the fix function that replaces ref/shallowRef calls with useTemplateRef, preserving type arguments
tests/lib/rules/prefer-use-template-ref.jsAdds output expectations for all invalid test cases and includes endLine/endColumn in error assertions; adds TypeScript test case
docs/rules/prefer-use-template-ref.mdAdds wrench icon notation andfix attribute to code blocks to indicate auto-fix capability
docs/rules/index.mdUpdates the rules table to show the wrench icon for this rule

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

Copy link
Member

@ota-meshiota-meshi left a comment

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!

</template>
<script setup>
import { ref } from 'vue';
const root = useTemplateRef('root');
Copy link
Member

@ota-meshiota-meshiDec 5, 2025
edited
Loading

Choose a reason for hiding this comment

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

I think autofixes shouldn't break source code.
I think addingimport { useTemplateRef } from 'vue' will inconvenience users who useunplugin-auto-import, but I think not addingimport { useTemplateRef } from 'vue' will break it for users who don't useunplugin-auto-import.
Could you change it to addimport { useTemplateRef } from 'vue'?
Or could you change it to a suggestion instead of autofix?

9romise and waynzh reacted with thumbs up emoji
Copy link
ContributorAuthor

@9romise9romiseDec 5, 2025
edited
Loading

Choose a reason for hiding this comment

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

That makes sense. I'll have a try.

ota-meshi reacted with thumbs up emoji
@9romise9romise marked this pull request as draftDecember 5, 2025 03:44
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

Copilot code reviewCopilotCopilot left review comments

@ota-meshiota-meshiota-meshi requested changes

@FloEdelmannFloEdelmannFloEdelmann approved these changes

@waynzhwaynzhAwaiting requested review from waynzh

Requested changes must be addressed to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@9romise@FloEdelmann@ota-meshi

[8]ページ先頭

©2009-2025 Movatter.jp