Skip to content

vue/custom-event-name-casing doesn't flag incorrectly cased emits in the template #2577

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 Oct 15, 2024 · 0 comments · Fixed by #2585
Closed
2 tasks done

vue/custom-event-name-casing doesn't flag incorrectly cased emits in the template #2577

henribru opened this issue Oct 15, 2024 · 0 comments · Fixed by #2585
Labels

Comments

@henribru
Copy link

henribru commented Oct 15, 2024

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: 9.12.0
  • eslint-plugin-vue version: 9.29.0
  • Vue version: 3.5.9
  • Node version: 18.20.4
  • Operating System: Arch Linux

Please show your full configuration:

import pluginVue from 'eslint-plugin-vue'
import vueTsEslintConfig from '@vue/eslint-config-typescript'
import pluginVitest from '@vitest/eslint-plugin'
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'

export default [
  {
    name: 'app/files-to-lint',
    files: ['**/*.{ts,mts,tsx,vue}'],
  },

  {
    name: 'app/files-to-ignore',
    ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
  },

  ...pluginVue.configs['flat/essential'],
  ...vueTsEslintConfig(),
  
  {
    ...pluginVitest.configs.recommended,
    files: ['src/**/__tests__/*'],
  },
  skipFormatting,
  {
    rules: {
      "vue/custom-event-name-casing": "error"
    }
  }
]

What did you do?

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

emit('foo-bar')
</script>

<template>
  <button @click="emit('foo-bar')">Foo</button>
  <button @click="$emit('foo-bar')">Foo</button>
</template>

What did you expect to happen?
ESLint should flag all three emits because they all use kebab case instead of camelcase.

What actually happened?

It flags the one in script setup and the one using $emit in the template, but not the one using emit.

➜  vue-project npm run lint

> [email protected] lint
> eslint . --fix


/home/.../dev/vue-project/src/components/HelloWorld.vue
  4:6   error  Custom event name 'foo-bar' must be camelCase  vue/custom-event-name-casing
  9:25  error  Custom event name 'foo-bar' must be camelCase  vue/custom-event-name-casing

✖ 2 problems (2 errors, 0 warnings)

Repository to reproduce this issue

https://github.com/henribru/eslint-plugin-vue-custom-event-name-casing-bug

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