vue/warn-custom-directive
Warn about custom directives that need registration.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
nuxt, opinionated |
No | None |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
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>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/warn-custom-directive": "warn"
}
},
});
Then run vp run lint.