Skip to content

Latest commit

 

History

History
78 lines (59 loc) · 1.83 KB

html-self-closing.md

File metadata and controls

78 lines (59 loc) · 1.83 KB
pageClass sidebarDepth title description
rule-details
0
svelte/html-self-closing
enforce self-closing style

svelte/html-self-closing

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.

📖 Rule Details

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 />

🔧 Options

{
  "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 elements
  • html.component ("always" by default)... Style of svelte components
  • html.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>)

🔍 Implementation