vue/html-self-closing
Enforce self-closing 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: See typed options and defaults.
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({
lint: {
vize: {
"preset": "incremental",
"rules": {
"vue/html-self-closing": "warn"
}
},
},
});
vp run lint
Bad
The empty component uses a closing pair, while void img and br elements omit the configured self-closing spelling.
<template>
<MyComponent></MyComponent>
<img>
<br>
</template>
Good
The component and void elements use self-closing syntax; a div with content retains its closing tag.
<template>
<MyComponent />
<div></div>
<div />
<img />
<br />
<div>content</div>
</template>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.