Description
Please describe what the rule should do:
Similar to ESLint's no-shadow
rule, it would be great to have something similar, like vue/no-prop-shadow
where it would warn on local variable declaration that has the same name as a prop, which can lead to issues when referencing it in the template because props can be directly accessed from the template.
What category should the rule belong to?
[ ] Enforces code style (layout)
[x] Warns about a potential error (problem)
[ ] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)
Provide 2-3 code examples that this rule should warn about:
WARN
<script setup lang="ts">
defineProps<{
msg: string;
}>()
const msg = "override props"; // WARN: there's already a prop named `msg`
</script>
<template>
<div>{{ msg }}</div> <!-- vague reference. Is this from props or local variable? -->
</template>
WARN
<script lang="ts">
import { defineComponent, computed } from "vue";
export default defineComponent({
props: {
msg: String
},
setup: (props) => {
const msg = computed(() => `Message: ${props.msg}`);
return {
msg, // WARN: there's already a prop named `msg`
};
}
})
</script>
<template>
<div>{{ msg }}</div> <!-- vague reference. Is this from props or local variable? -->
</template>
Additional context
More context from the original issue: