Skip to content

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

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
henribru opened this issue Nov 30, 2023 · 1 comment · Fixed by #2340
Closed
2 tasks done

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

henribru opened this issue Nov 30, 2023 · 1 comment · Fixed by #2340
Labels

Comments

@henribru
Copy link

henribru commented Nov 30, 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.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

@henribru
Copy link
Author

It seems like it works if you use $emit in the template.

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

Successfully merging a pull request may close this issue.

2 participants