vue/valid-v-once
Enforce valid v-once directives.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
error |
essential, happy-path, nuxt, ecosystem, opinionated |
No | None |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
Bad
v-once has a value, argument, or modifier, although this directive is a value-free render-once marker.
<template>
<div v-once="foo"></div>
<div v-once:arg></div>
<div v-once.mod></div>
</template>
Good
Bare v-once marks the subtree for one-time rendering without unsupported syntax.
<template>
<div v-once></div>
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/valid-v-once": "error"
}
},
});
Then run vp run lint.