Skip to content

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

Closed
@ByScripts

Description

@ByScripts

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions