Skip to content

Latest commit

 

History

History
80 lines (61 loc) · 1.98 KB

html-self-closing.md

File metadata and controls

80 lines (61 loc) · 1.98 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 />
<svelte:head />

<!-- ✗ BAD -->
<div></div>
<p> </p>
<div><div></div></div>
<img>
<svelte:head></svelte:head>

🔧 Options

{
  "svelte/html-self-closing": [
    "error",
    {
      "void": "always", // or "always" or "ignore"
      "normal": "always", // or "never" or "ignore"
      "component": "always", // or "never" or "ignore"
      "svelte": "always" // or "never" or "ignore"
    }
  ]
}
  • void ("always" by default)... Style of HTML void elements
  • component ("always" by default)... Style of svelte components
  • svelte ("always" by default)... Style of svelte special elements (<svelte:head>, <svelte:self>)
  • 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