Skip to content

vue/valid-define-emits treats validator payload as local variable and fails #1651

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
larvanitis opened this issue Oct 6, 2021 · 0 comments · Fixed by #1652
Closed
2 tasks done

vue/valid-define-emits treats validator payload as local variable and fails #1651

larvanitis opened this issue Oct 6, 2021 · 0 comments · Fixed by #1652
Labels

Comments

@larvanitis
Copy link

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: 7.32.0
  • eslint-plugin-vue version: 7.19.0
  • Node version: 14.17.4
  • *Operating System: Arch Linux

Please show your full configuration:

module.exports = {
  root: true,

  parserOptions: {
    parser: '@babel/eslint-parser',
    ecmaVersion: 2018,
    sourceType: 'module',
  },

  env: {
    browser: true,
  },

  extends: ['plugin:vue/vue3-recommended', 'prettier'],

  plugins: ['vue'],

  globals: {
    ga: 'readonly',
    cordova: 'readonly',
    __statics: 'readonly',
    __QUASAR_SSR__: 'readonly',
    __QUASAR_SSR_SERVER__: 'readonly',
    __QUASAR_SSR_CLIENT__: 'readonly',
    __QUASAR_SSR_PWA__: 'readonly',
    process: 'readonly',
    Capacitor: 'readonly',
    chrome: 'readonly',
  },

  rules: {
    'prefer-promise-reject-errors': 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'vue/component-name-in-template-casing': [
      'warn',
      'PascalCase',
      { registeredComponentsOnly: false },
    ],
    'vue/html-button-has-type': 'error',
    'vue/match-component-file-name': 'error',
    'vue/no-boolean-default': ['error', 'default-false'],
    'vue/no-reserved-component-names': [
      'error',
      {
        disallowVueBuiltInComponents: true,
        disallowVue3BuiltInComponents: true,
      },
    ],
    'vue/valid-define-emits': 'error',
    'vue/valid-define-props': 'error',
    'vue/valid-next-tick': 'error',
    'vue/valid-v-memo': 'error',
  },
};

What did you do?
Example from https://v3.vuejs.org/guide/component-custom-events.html#validate-emitted-events

<script setup>
const emits = defineEmits({
  submit: ({ email, password }) => {
    if (email && password) {
      return true;
    } else {
      return false;
    }
  },
});
</script>

What did you expect to happen?
This should work since the docs say:

[...] defineEmits accepts the same value as the emits option.

What actually happened?
I get the following error (cli, IntelliJ, VSCode).

/path/to/TestComponent.vue
  15:14  error  `defineEmits` are referencing locally declared variables  vue/valid-define-emits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants