vue/use-v-on-exact
Enforce .exact modifier on v-on when there are modifier-based handlers
Default severity: warning
Presets: essential, 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: No rule-specific options. Severity and preset selection are configurable.
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({
lint: {
vize: {
"preset": "incremental",
"rules": {
"vue/use-v-on-exact": "warn"
}
},
},
});
vp run lint
Bad
The plain click handler can also run on Ctrl-click, overlapping the separate .ctrl handler.
<template>
<button type="button" @click="handleClick" @click.ctrl="handleCtrlClick">
Save
</button>
</template>
Good
.exact limits the ordinary click handler to clicks without modifier keys; the Ctrl-specific handler remains separate.
<template>
<button
type="button"
@click.exact="handleClick"
@click.ctrl="handleCtrlClick"
>
Save
</button>
</template>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.