Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect props destructure rename in vue/no-dupe-keys #2713

Closed
ByScripts opened this issue Mar 11, 2025 · 0 comments · Fixed by #2731
Closed

Detect props destructure rename in vue/no-dupe-keys #2713

ByScripts opened this issue Mar 11, 2025 · 0 comments · Fixed by #2731
Labels

Comments

@ByScripts
Copy link

What rule do you want to change?

vue/no-dupe-keys

Does this change cause the rule to produce more or fewer warnings?

Fewer

How will the change be implemented? (New option, new default behavior, etc.)?

I think it should be the default behavior.

Please provide some example code that this change will affect:

Here is a simple example (BTW, removing the intermediate withPrefix computed makes the error to disappear on const messages = ...).

<template>
  <div v-for="message of messages" :key="message">{{ message }}</div>
</template>

<script lang="ts" setup>
import { computed } from 'vue';

const { messages: _messages } = defineProps<{ messages: string[] }>()

const withPrefix = computed(() => _messages.map(message => `→ ${message}`))

const messages = computed(() => withPrefix.value.map(message => `${message} ←`))
</script>

What does the rule currently do for this code?

ESLint: Duplicate key 'messages'. May cause name collision in script or template tag. (vue/no-dupe-keys)

What will the rule do after it's changed?

No warning nor error since the destructured prop is intentionally renamed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants