eslint-plugin-vue icon indicating copy to clipboard operation
eslint-plugin-vue copied to clipboard

`no-undef-properties` does not take into account second `<script>` section

Open andreww2012 opened this issue 1 year ago • 1 comments

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.

andreww2012 avatar Jul 26 '24 11:07 andreww2012

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

fabruex avatar Dec 01 '24 11:12 fabruex