Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

vue/no-unused-emit-declarations would throw Error when using dynamic render #2387

Copy link
Copy link
Closed
@ntnyq

Description

@ntnyq
Issue body actions

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: 8.56.0
  • eslint-plugin-vue version: 9.21.0
  • Vue version: 3.4.15
  • Node version: 18.18.2
  • Operating System: MacOS

Please show your full configuration:

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

What did you do?

<script>
import { defineComponent, h } from 'vue'

export default defineComponent({
  emits: ['update'],

  setup(_, ctx) {
    return () =>
      h(
        'button',
        {
          type: 'button',
          onClick: () => ctx.emit('update'),
        },
        'Click me!',
      )
  },
})
</script>

What did you expect to happen?

Lint works well.

What actually happened?

TypeError: Cannot read properties of undefined (reading 'name')
Occurred while linting /Users/ntnyq/Desktop/github/ntnyq/repro-eslint-plugin-vue/src/VButton.vue:9
Rule: "vue/no-unused-emit-declarations"
    at isEmitVariableName (/Users/ntnyq/Desktop/github/ntnyq/repro-eslint-plugin-vue/node_modules/.pnpm/eslint-plugin-vue@9.21.0_eslint@8.56.0/node_modules/eslint-plugin-vue/lib/rules/no-unused-emit-declarations.js:66:62)
    at Object.CallExpression (/Users/ntnyq/Desktop/github/ntnyq/repro-eslint-plugin-vue/node_modules/.pnpm/eslint-plugin-vue@9.21.0_eslint@8.56.0/node_modules/eslint-plugin-vue/lib/rules/no-unused-emit-declarations.js:209:13)
    at callVisitor (/Users/ntnyq/Desktop/github/ntnyq/repro-eslint-plugin-vue/node_modules/.pnpm/eslint-plugin-vue@9.21.0_eslint@8.56.0/node_modules/eslint-plugin-vue/lib/utils/index.js:1215:21)
    at vueVisitor.<computed> (/Users/ntnyq/Desktop/github/ntnyq/repro-eslint-plugin-vue/node_modules/.pnpm/eslint-plugin-vue@9.21.0_eslint@8.56.0/node_modules/eslint-plugin-vue/lib/utils/index.js:1222:35)
    at ruleErrorHandler (/Users/ntnyq/Desktop/github/ntnyq/repro-eslint-plugin-vue/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/linter/linter.js:1076:28)
    at /Users/ntnyq/Desktop/github/ntnyq/repro-eslint-plugin-vue/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/ntnyq/Desktop/github/ntnyq/repro-eslint-plugin-vue/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/Users/ntnyq/Desktop/github/ntnyq/repro-eslint-plugin-vue/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (/Users/ntnyq/Desktop/github/ntnyq/repro-eslint-plugin-vue/node_modules/.pnpm/eslint@8.56.0/node_modules/eslint/lib/linter/node-event-generator.js:326:22)

Repository to reproduce this issue

https://github.com/ntnyq-dev/repro-no-unused-emit-declarations

Additional text

#2340 introduced a function isEmitVariableName.

emitReferenceIds may be an empty Set.

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.