Repository navigation
fix(no-undef-properties): support ...toRefs(reactive({})) in setup() return - #3134
Merged
ota-meshi merged 2 commits intoOct 9, 2026
Merged
Conversation
π¦ Changeset detectedLatest commit: 2fe7c20 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
requested changes
Sep 23, 2026
FloEdelmann
left a comment
Member
There was a problem hiding this comment.
Makes sense to me. I have two small suggestions, see below.
FloEdelmann
approved these changes
Sep 26, 2026
Member
|
Thanks! |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1915
What
vue/no-undef-propertiesreported every template reference as undefined when a component exposes state via...toRefs(data)fromsetup(), wheredatais aconstbound toreactive({ ... })(the exact example from the issue). The rule only collected explicitPropertyentries from thesetup()return object and ignored spreads.Fix
In
onVueObjectEnter, walk thesetup()return object(s) forSpreadElements whose argument is atoRefs(...)call (tracked viaReferenceTracker, same approach asproperty-references.ts) and resolve its argument to areactive({ ... })object literal β either inline (toRefs(reactive({...}))) or through a single-definitionconstinitialized withreactive({...}). The keys of that literal are then registered as defined setup properties. Anything not statically resolvable (non-const, reassigned, non-literalreactivearg, unknown call) is left untouched, so existing reporting is unchanged.Tests
const data = reactive({a, b}); return { ...toRefs(data) }(issue repro) and inlinesetup: () => ({ ...toRefs(reactive({ a })), ...toRefs(reactive({ b, c })) })cwhich is not in the reactive object β still reportedValidation
npx vitest run tests/lib/rules/no-undef-properties.test.tsβ 81 passed (78 before + 3 new)'a' is not defined.,'b' is not defined., and the invalid case reports extraa/b); with it restored, all passnpm run build && npx vitest run tests/libβ 288 files, 11624 tests passednpx eslint lib/rules/no-undef-properties.ts tests/lib/rules/no-undef-properties.test.tsβ clean;prettier --checkcleannpx tscβ 27 pre-existing errors (all../../../../../distmodule resolution in tests beforenpm run build), none in the touched files; identical count on a clean checkoutChangeset added (
patch). Happy to adjust.