Skip to content

vue/require-explicit-emits does not pick up type-only definition #1898

@eikooc

Description

@eikooc

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.15.0
  • eslint-plugin-vue version:
    v9.0.1
  • Node version:
    v16.4.2
  • Operating System:
    Ubuntu 22.04

Please show your full configuration:

// eslint-disable-next-line no-undef
module.exports = {
  root: true,
  parser: 'vue-eslint-parser',
  parserOptions: {
    ecmaVersion: 'latest',
    parser: '@typescript-eslint/parser',
    sourceType: 'module',
  },
  env: {
    browser: true,
    es2021: true,
    'vue/setup-compiler-macros': true,
  },
  extends: [
    'eslint:recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:vue/vue3-recommended',
    'prettier',
    'plugin:storybook/recommended',
  ],
  plugins: ['vue', '@typescript-eslint', 'prettier'],
  rules: {
    'prettier/prettier': 'error',
    '@typescript-eslint/consistent-type-imports': 'error',
    '@typescript-eslint/no-unused-vars': [
      1,
      {
        argsIgnorePattern: '^_',
      },
    ],
    'linebreak-style': ['error', 'unix'],
  },
}

What did you do?

<template>
  <div @click="$emit('click:this')"></div>
</template>

<script setup lang="ts">
defineEmits<{ 'click:this': string }>()
</script>
<style scoped></style>

What did you expect to happen?
vue/require-explicit-emits to not cause a lint warning.

What actually happened?

/home/src/views/minimal-example.vue
  2:22  warning  The "click:this" event has been triggered but not declared on `defineEmits`  vue/require-explicit-emits

Repository to reproduce this issue

Is this needed?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions