Skip to content
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

Vue 3.3 - new defineEmits syntax not working properly with vue/require-explicit-emits active #2173

Closed
2 tasks done
Noxdor opened this issue May 15, 2023 · 3 comments
Closed
2 tasks done

Comments

@Noxdor
Copy link

Noxdor commented May 15, 2023

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: v8.12.0
  • eslint-plugin-vue version: v9.12.0
  • Node version: v19.9.0
  • Operating System: Linux - 6.3.1-zen1-1-zen

Please show your full configuration:

module.exports = {
  // https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
  // This option interrupts the configuration hierarchy at this file
  // Remove this if you have an higher level ESLint config file (it usually happens into a monorepos)
  root: true,

  // `parser: 'vue-eslint-parser'` is already included with any 'plugin:vue/**' config and should be omitted
  parserOptions: {
    ecmaVersion: '2022', // Allows for the parsing of modern ECMAScript features - 2022 allows top-level await for async vue setup functions
    extraFileExtensions: ['.vue'],
    parser: require.resolve('@typescript-eslint/parser')
  },

  env: {
    node: true,
    browser: true,
    'vue/setup-compiler-macros': true
  },

  // Rules order is important, please avoid shuffling them
  extends: [
    // Base ESLint recommended rules
    'eslint:recommended',

    'plugin:@typescript-eslint/recommended',

    // Uncomment any of the lines below to choose desired strictness,
    // but leave only one uncommented!
    // See https://eslint.vuejs.org/rules/#available-rules
    // 'plugin:vue/vue3-essential', // Priority A: Essential (Error Prevention)
    // 'plugin:vue/vue3-strongly-recommended', // Priority B: Strongly Recommended (Improving Readability)
    'plugin:vue/vue3-recommended', // Priority C: Recommended (Minimizing Arbitrary Choices and Cognitive Overhead)

    // https://github.com/prettier/eslint-config-prettier#installation
    // usage with Prettier, provided by 'eslint-config-prettier'.
    'prettier'
  ],

  plugins: [
    // https://eslint.vuejs.org/user-guide/#why-doesn-t-it-work-on-vue-files
    // required to lint *.vue files
    'vue',

    '@typescript-eslint'

    // https://github.com/typescript-eslint/typescript-eslint/issues/389#issuecomment-509292674
    // Prettier has not been included as plugin to avoid performance impact
    // add it as an extension for your IDE
  ],

  globals: {
    ga: 'readonly', // Google Analytics
    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',
    google: 'readonly'
  },

  // add your custom rules here
  rules: {
    'prefer-promise-reject-errors': 'off',

    // this rule, if on, would require explicit return type on the `render` function
    '@typescript-eslint/explicit-function-return-type': 'off',

    // in plain CommonJS modules, you can't use `import foo = require('foo')` to pass this rule, so it has to be disabled
    '@typescript-eslint/no-var-requires': 'off',

    // allow debugger during development only
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'no-unused-vars': 'off',
    '@typescript-eslint/no-unused-vars': [
      'warn',
      {
        vars: 'all',
        args: 'after-used',
        argsIgnorePattern: '^_',
        ignoreRestSiblings: true,
        destructuredArrayIgnorePattern: '^_'
      }
    ]
  }
}

What did you do?

// Defining emits with the new vue 3.3 emit syntax
const emit = defineEmits<{
  submit: []
  'update:refetch': [update: boolean]
}>()

// ... later in the code calling emit
emit('update:refetch', true)

What did you expect to happen?

Eslint should not give me a warning that the event I am firing has not been declared (since it was).

What actually happened?

I am getting the following errors:
250:10 warning The "update:refetch" event has been triggered but not declared on defineEmits vue/require-explicit-emits
253:27 warning The "update:refetch" event has been triggered but not declared on defineEmits vue/require-explicit-emits
258:8 warning The "submit" event has been triggered but not declared on defineEmits vue/require-explicit-emits

Repository to reproduce this issue

Repo to reproduce

By setting up this reproduction repo, I could isolate the issue to switching the extend key's value from plugin:vue/vue3-essential to plugin:vue/vue3-recommended. This enables the vue/require-explicit-emits rule that to my understanding is not updated to handle vue 3.3 emit definitions

@FloEdelmann
Copy link
Member

This is already being worked on; see #2126 or more generally #2127.

@FloEdelmann FloEdelmann closed this as not planned Won't fix, can't repro, duplicate, stale May 15, 2023
@Noxdor
Copy link
Author

Noxdor commented May 15, 2023

This is already being worked on; see #2126 or more generally #2127.

Thanks, I actually checked that and saw that the PR for this was done, but didn't see that it wasn't yet included in the last version. Thanks for pointing that out to me, sorry for the bother.

@FloEdelmann
Copy link
Member

No worries!

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

No branches or pull requests

2 participants