vue/v-on-event-hyphenation
Enforce hyphenation of custom event names in v-on on components
Default severity: warning
Presets: nuxt, opinionated
Automatic fix: None; review the suggested change
Applies to: Vue SFC templates and blocks, with script context where the rule requires it
Options: See typed options and defaults.
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({
lint: {
vize: {
"preset": "incremental",
"rules": {
"vue/v-on-event-hyphenation": "warn"
}
},
},
});
vp run lint
Bad
The custom component listener uses @myEvent instead of a hyphenated event name.
<template>
<MyComponent @myEvent="handler" />
<MyComponent v-on:myEvent="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>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.