Skip to content

fix(no-dupe-keys): detect locals aliasing a different prop - #3124

Open
ValentinYoushkevich wants to merge 1 commit into
vuejs:masterfrom
ValentinYoushkevich:fix/no-dupe-keys-prop-alias
Open

fix(no-dupe-keys): detect locals aliasing a different prop#3124
ValentinYoushkevich wants to merge 1 commit into
vuejs:masterfrom
ValentinYoushkevich:fix/no-dupe-keys-prop-alias

Conversation

@ValentinYoushkevich

Copy link
Copy Markdown
Contributor

onDefinePropsEnter skips a local declaration that shadows a prop whenever the initializer mentions the props object anywhere (isInsideInitializer, added in #2189 so const foo = toRef(props, 'foo') stays valid). The check only asks whether props is touched, not which prop is read, so it also hides real collisions:

<script setup>
const props = defineProps(['foo', 'bar'])
const foo = toRef(props, 'bar')
</script>

The template's foo resolves to props.bar and prop foo becomes unreachable — exactly what the rule exists to catch.

The exemption is now skipped when the declaration provably aliases a different prop: props.bar, props['bar'], toRef(props, 'bar'), const { bar: foo } = props and const { bar: foo } = toRefs(props). Same-name aliases keep passing, and declarations whose source prop can't be resolved (toRef(props, key), computed(() => props.bar + 1)) are still left alone, so no new false positives.

The exact snippet from the issue (const foo = toRef(props, 'foo')) stays valid: it is a valid test from #2189, the setup binding wins in the template and unwraps to the same value the prop holds. Only the different-prop variants are reported. The Options API setup() path is untouched.

Refs #3070

The literal snippet from the report stays valid, so this does not close the issue by itself. Making that one error means reverting #2189 and reporting const { foo } = toRefs(props) and const foo = props.foo along with it — happy to redo it that way if that is what you want.

@changeset-bot

changeset-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9279875

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

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.

1 participant