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

False positives when destructuring with rename toRef props in vue/no-dupe-keys rule #2197

Closed
2 tasks done
N-Silbernagel opened this issue May 30, 2023 · 2 comments
Closed
2 tasks done

Comments

@N-Silbernagel
Copy link

Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version: 8.41.0
  • eslint-plugin-vue version: 9.14.0
  • Node version: 16.14.2
  • Operating System: MacOs / StackBlitz

Please show your full configuration:

module.exports = {
  extends: [
    '@vue/typescript/recommended',
    'eslint:recommended',
    'plugin:vue/vue3-recommended',
  ],
  rules: {
    // override/add rules settings here, such as:
    // 'vue/no-unused-vars': 'error'
  },
};

What did you do?

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

const props = defineProps<{ msg: string }>();

const { msg: msgProp } = toRefs(props);

const msg = computed(() => msgProp.value || 'hello');
</script>

This is similar to #2189 but with a renamed prop in destructuring assignment.

What did you expect to happen?
No errors.

What actually happened?

/src/components/HelloWorld.vue
8:7 error Duplicated key 'msg' vue/no-dupe-keys

✖ 1 problem (1 error, 0 warnings)

Repository to reproduce this issue

https://stackblitz.com/edit/vitejs-vite-49r5se?file=src%2Fcomponents%2FHelloWorld.vue

@FloEdelmann
Copy link
Member

This is actually a valid warning of the no-dupe-keys rule: You have both a prop and a computed variable with the same name.

@FloEdelmann FloEdelmann closed this as not planned Won't fix, can't repro, duplicate, stale May 30, 2023
@N-Silbernagel
Copy link
Author

I see, the problem is both could be referred to with the same name in template. Thanks

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

No branches or pull requests

2 participants