Vue Rules: Directive Conventions
Every rule on this page includes its purpose, prerequisites, configuration, and complete Bad/Good examples. Highlighted lines show the changes; copied code keeps the complete source. Each packet states its current support limits.
| Rule | Examples | Purpose |
|---|---|---|
vue/scoped-event-names |
Bad · Good | Recommend scoped event names using context:event format |
vue/use-v-on-exact |
Bad · Good | Enforce .exact modifier on v-on when there are modifier-based handlers |
vue/v-bind-style |
Bad · Good | Enforce v-bind directive style |
vue/v-on-style |
Bad · Good | Enforce v-on directive style |
vue/v-slot-style |
Bad · Good | Enforce v-slot directive style |
vue/warn-custom-directive |
Bad · Good | Warn about custom directives that need registration |
All rules · Rule Options · ESLint migration map · Project checks · Attributes across components
vue/scoped-event-names
Recommend scoped event names using context:event format
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: 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/scoped-event-names": "warn"
}
},
},
});
vp run lint
Bad
playAudio, pauseAudio, and reloadAudio encode their scope as camel-case suffixes rather than the rule's colon-separated event convention.
<template>
<AudioPlayer
@playAudio="play"
@pauseAudio="pause"
@reloadAudio="reload"
/>
</template>
Good
audio:play, audio:pause, and audio:reload share an explicit audio: scope. The emitting component must use the same names.
<template>
<AudioPlayer
@audio:play="play"
@audio:pause="pause"
@audio:reload="reload"
/>
</template>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.
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.
vue/v-bind-style
Enforce v-bind directive style
Default severity: warning
Presets: nuxt, opinionated
Automatic fix: Available for supported findings
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/v-bind-style": "warn"
}
},
},
});
vp run lint
Bad
v-bind:class uses the long form where the configured binding style requires the colon shorthand.
<template>
<div v-bind:class="panelClass"></div>
</template>
Good
:class retains the same expression with the required shorthand; this rule concerns spelling rather than the value's type.
<template>
<div :class="panelClass"></div>
</template>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.
vue/v-on-style
Enforce v-on directive style
Default severity: warning
Presets: happy-path, nuxt, ecosystem, opinionated
Automatic fix: Available for supported findings
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/v-on-style": "warn"
}
},
},
});
vp run lint
Bad
v-on:click uses the long event-listener form where the rule requires shorthand.
<template>
<div v-on:click="handleClick"></div>
</template>
Good
@click keeps the same handler while using the configured shorthand.
<template>
<div @click="handleClick"></div>
</template>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.
vue/v-slot-style
Enforce v-slot directive style
Default severity: warning
Presets: happy-path, nuxt, ecosystem, opinionated
Automatic fix: Available for supported findings
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/v-slot-style": "warn"
}
},
},
});
vp run lint
Bad
The component uses #default and the template uses v-slot:header, opposite to the rule's context-specific styles.
<template>
<MyComponent #default="props">{{ props.item }}</MyComponent>
<MyComponent>
<template v-slot:header>Header</template>
</MyComponent>
</template>
Good
Use v-slot for the component's default slot and #header for the template's named slot.
<template>
<MyComponent v-slot="props">{{ props.item }}</MyComponent>
<MyComponent>
<template #header>Header</template>
</MyComponent>
</template>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.
vue/warn-custom-directive
Warn about custom directives that need registration
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: 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/warn-custom-directive": "warn"
}
},
},
});
vp run lint
Bad
v-focus, v-mask, and v-click-outside require project-specific directive implementations that this optional convention flags.
<template>
<input v-focus />
<input v-mask="'###-####'" />
<div v-click-outside="handleClose"></div>
</template>
Good
The example uses built-in v-if, v-model, and v-on. A correctly registered custom directive can still be valid Vue when this policy is disabled.
<template>
<div v-if="ready"></div>
<input v-model="value" />
<button type="button" @click="onClick">Save</button>
</template>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.