Visitar URL original
fix: recognize `useTemplateRef()` in `no-ref-as-operand` and `no-ref-object-reactivity-loss` by ValentinYoushkevich · Pull Request #3154 · vuejs/eslint-plugin-vue · GitHub
Skip to content

fix: recognize useTemplateRef() in no-ref-as-operand and no-ref-object-reactivity-loss - #3154

Merged
FloEdelmann merged 2 commits into
vuejs:masterfrom
ValentinYoushkevich:fix/no-ref-as-operand-use-template-ref
Oct 26, 2026
Merged

FloEdelmann merged 2 commits into
vuejs:masterfrom
ValentinYoushkevich:fix/no-ref-as-operand-use-template-ref

Conversation

@ValentinYoushkevich

@ValentinYoushkevich ValentinYoushkevich commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

useTemplateRef() returns a ShallowRef, but vue/no-ref-as-operand and vue/no-ref-object-reactivity-loss don't treat it as a ref, so the usual mistakes slip through. In Matb85/components-pack, typeof img == 'undefined' checks the ref object instead of the element, so the guard never fires. In vue-interface, defineExpose({ open: modal.value?.open }) reads the ref during setup, while it's still null, so open ends up undefined. Playground

Both rules get their ref definitions from iterateDefineRefs() in lib/utils/ref-object-references.ts, and that list just didn't include useTemplateRef, so I added it next to shallowRef. Aliased, namespace and #imports imports are picked up the same way as for the other ref functions. Template expressions aren't affected, since these rules only check script code.

@changeset-bot

changeset-bot Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d3ae86b

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

This PR includes changesets to release 1 package
Name Type
eslint-plugin-vue Patch

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 FloEdelmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@FloEdelmann FloEdelmann mentioned this pull request Oct 16, 2026
@FloEdelmann
FloEdelmann merged commit 2a7ad86 into vuejs:master Oct 26, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants