html-self-closing
What it does
Section titled “What it does”Reports an element written in the wrong form for Vue’s style: an HTML element, a component, an SVG or MathML element without content should be self-closed (<div />), a void HTML element should not (<img>). The elements of the file’s root (<template>, <script>) are not reported. Only in .vue files.
Why it matters
Section titled “Why it matters”Both forms mean the same in a Vue template, and the style puts the empty elements in one shape that is quick to see.
To fix, write the empty element as <div /> and the void one as <img>.
Example
Section titled “Example”<template> <div> <div></div> <img /> <img> <div /> <div>text</div> <MyCard></MyCard> <svg><path d="M0"></path></svg>... <a v-if="ok" :href="u" @click="go">x</a> <input v-bind="props" :id="i" v-model="m">...Configuration
Section titled “Configuration”angular: lint: rules: html-self-closing: warn # off (default), warn, errorhtml: lint: rules: html-self-closing: warn # off (default), warn, errorsvelte: lint: rules: html-self-closing: warn # off (default), warn, errorvue: lint: rules: html-self-closing: warn # off (default), warn, errorEnabled by the presets: html/eslint-plugin-vue-recommended.
Suppress one line with sudsy-disable-next-line html-self-closing in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| eslint-plugin-vue | html-self-closing |
partial | the default options only |