vue/valid-v-html
Enforce valid v-html directives
Default severity: error
Presets: essential, happy-path, nuxt, ecosystem, 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/valid-v-html": "error"
}
},
},
});
vp run lint
Bad
v-html lacks its expression or uses an argument/modifier that this directive does not support.
<template>
<div v-html></div>
<div v-html:arg="foo"></div>
<div v-html.mod="foo"></div>
</template>
Good
v-html="html" supplies a valid expression. Syntax validity does not sanitize HTML or make untrusted content safe.
<template>
<div v-html="html"></div>
</template>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.