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

`vue/no-shadow` false positive in double script block

Open sqal opened this issue 3 years ago • 2 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 version: 8.9.0
  • eslint-plugin-vue version: 8.4.1
  • Node version:
  • Operating System:

Please show your full configuration:

module.exports = {
  extends: [
    'plugin:vue/vue3-recommended',
  ],
  rules: {
    'no-shadow': 'error',
  },
};

What did you do?

<script>
  export function useModal() {
    const close = () => {}

    return { close }
  }
</script>

<script setup>
  function close() {

  }
</script>

<template>
  <Modal @close="close"></Modal>
</template>

What did you expect to happen? No errors reported for the no-shadow rule.

What actually happened?

[3:11]: 'close' is already declared in the upper scope on line 10 column 12. (no-shadow)

Repository to reproduce this issue

Online Playground

sqal avatar Feb 15 '22 10:02 sqal

Another repository to reproduce this issue was provided in #2141: https://github.com/teleskop150750/vue-no-shadow

FloEdelmann avatar May 12 '23 07:05 FloEdelmann

In Vue 3.3, you can now use defineOptions in <script setup> and avoid this issue altogether, see https://blog.vuejs.org/posts/vue-3-3#defineoptions and https://vuejs.org/api/sfc-script-setup.html#defineoptions.

FloEdelmann avatar Jun 22 '23 12:06 FloEdelmann