eslint-plugin-vue
eslint-plugin-vue copied to clipboard
`no-undef-properties` does not take into account second `<script>` section
Checklist
- [x] I have tried restarting my IDE and the issue persists.
- [x] I have read the FAQ and my problem is not listed.
Tell us about your environment
- eslint-plugin-vue version: 9.27.0
What did you do?
If both <script setup> and regular <script> sections are present, the latter will be ignored by no-undef-properties rule. To reproduce, go the rule's page on the website and paste the following snippet in the editor:
<template>
<!-- ✓ GOOD -->
<div>{{ name }}: {{ count }}</div>
<!-- ✗ BAD -->
<div>{{ label }}: {{ cnt }}</div>
<!-- From <script>: -->
{{ myComputed }}
</template>
<script>
export default {
computed: {
myComputed() {
return 'any';
},
},
};
</script>
<script setup>
const prop = defineProps(['name', 'def'])
let count = 0
/* ✓ GOOD */
watch(() => prop.def, () => console.log('Updated!'))
/* ✗ BAD */
watch(() => prop.undef, () => console.log('Updated!'))
</script>
If you then remove <script setup> section, myComputed will be recognized.
What did you expect to happen?
Properties from both <script setup> and <script> sections are recognized by this rule.
Hi, is there a solution for this? We're migrating our codebase to composition API and we have many cases like this. It would be really useful to keep the rule on during migration. Thanks