Skip to content

vue/no-unused-emit-declarations doesn't detect emits in templates #2337

Closed
@henribru

Description

@henribru

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.54.0
  • eslint-plugin-vue version: v9.19.2
  • Node version: v18.17.1
  • Operating System: Ubuntu 23.04

Please show your full configuration:

/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')

module.exports = {
  root: true,
  'extends': [
    'plugin:vue/vue3-essential',
    'eslint:recommended',
    '@vue/eslint-config-typescript',
    '@vue/eslint-config-prettier/skip-formatting'
  ],
  parserOptions: {
    ecmaVersion: 'latest'
  },
  rules: {
    "vue/no-unused-emit-declarations": "error",
  }
}

What did you do?

<script setup lang="ts">
const emit = defineEmits({"foo": () => true})
</script>

<template>
  <button @click="emit('foo')">Foo</button>
</template>
</style>

What did you expect to happen?
The emit shouldn't be flagged as unused since it's used in the template

What actually happened?

The emit is flagged as unused:

6:27  error  `foo` is defined as emit but never used  vue/no-unused-emit-declarations

Repository to reproduce this issue

https://github.com/henribru/eslint-unused-emit-repro

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions