Skip to content

defineProps should be able to work with local imported bindings, but reported as error #1734

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

Closed
2 tasks done
wxsms opened this issue Dec 1, 2021 · 0 comments · Fixed by #1736
Closed
2 tasks done
Labels

Comments

@wxsms
Copy link
Member

wxsms commented Dec 1, 2021

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.3.0
  • eslint-plugin-vue version: 8.1.1
  • Node version: v16.11.0
  • Operating System: Windows 10

Please show your full configuration:

// http://eslint.org/docs/user-guide/configuring

module.exports = {
  root: true,
  env: {
    browser: true,
  },
  // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
  extends: ['plugin:vue/vue3-recommended', 'plugin:prettier/recommended'],
  // required to lint *.vue files
  plugins: ['html'],
  parserOptions: {
    ecmaVersion: 2020,
    ecmaFeatures: {
      jsx: true,
    },
  },
  // add your custom rules here
  rules: {
    'prettier/prettier': [
      'error',
      {
        endOfLine: 'auto',
        semi: true,
        singleQuote: true,
        trailingComma: 'es5',
      },
    ],
    // allow paren-less arrow functions
    'arrow-parens': 0,
    // allow async-await
    'generator-star-spacing': 0,
    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
    'vue/multi-word-component-names': 0,
    'vue/no-v-html': 0,
  },
};

What did you do?

<script setup>
import { linkProps } from '../../props/link.props';

defineProps({
  ...linkProps,
  active: { type: Boolean, default: false },
});
</script>

What did you expect to happen?

No error should be reported. as the document https://v3.vuejs.org/api/sfc-script-setup.html#defineprops-and-defineemits said:

However, it can reference imported bindings since they are in the module scope as well.

It does not require the import statement to inside a normal script instead of setup script.

What actually happened?

ESLint: `defineProps` are referencing locally declared variables.(vue/valid-define-props)

Repository to reproduce this issue

https://github.com/uiv-lib/uiv/blob/dev/src/components/button/Btn.vue

just change the import statement from normal script to setup script to see what happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants