pageClass | sidebarDepth | title | description |
---|---|---|---|
rule-details |
0 |
svelte/html-self-closing |
enforce self-closing style |
enforce self-closing style
- ❗ This rule has not been released yet.
- 🔧 The
--fix
option on the command line can automatically fix some of the problems reported by this rule.
You can choose either two styles for elements without content
- always:
<div />
- never:
<div></div>
<script>
/* eslint svelte/html-self-closing: "error" */
</script>
<!-- ✓ GOOD -->
<div />
<p>Hello</p>
<div><div /></div>
<img>
<!-- ✗ BAD -->
<div></div>
<p> </p>
<div><div></div></div>
<img />
{
"svelte/html-self-closing": [
"error",
{
"html": {
"void": "always", // or "always" or "ignore"
"normal": "always", // or "never" or "ignore"
"component": "always" // or "never" or "ignore"
}
}
]
}
html.void
("always"
by default)... Style of HTML void elementshtml.component
("always"
by default)... Style of svelte componentshtml.normal
("always"
by default)... Style of other elements
Every option can be set to
- "always" (
<div />
) - "never" (
<div></div>
) - "ignore" (either
<div />
or<div></div>
)