vue/v-on-event-hyphenation
Enforce hyphenation of custom event names in v-on on components.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
happy-path, nuxt, ecosystem, opinionated |
Yes | Rule options |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
Bad
The custom component listener uses @myEvent instead of a hyphenated event name.
<template>
<MyComponent @myEvent="handler" />
<MyComponent v-on:myEvent="handler" />
<my-component @update:modelValue="handler" />
</template>
Good
@my-event uses the required custom-event spelling. Native-element listeners and dynamic event arguments shown below are outside this check.
<template>
<MyComponent @my-event="handler" />
<div @myEvent="handler" />
<MyComponent @[dynamicEvent]="handler" />
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/v-on-event-hyphenation": "warn"
}
},
});
Then run vp run lint.