# svelte/html-closing-bracket-spacing

require or disallow a space before tag’s closing brackets

  • 🔧 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 spacing before closing bracket

  • always: <div />
  • never: <div/>
<script>
  /* eslint svelte/html-closing-bracket-spacing: "error" */
</script>

<!-- ✓ GOOD -->
<div />
<p>Hello</p>
<div
 >
</div>

<!-- ✗ BAD -->
<div
Expected space before '>', but not found. (svelte/html-closing-bracket-spacing)
/>
<p
Expected no space before '>', but found. (svelte/html-closing-bracket-spacing)
>
Expected no space before '>', but found. (svelte/html-closing-bracket-spacing)
Hello</p >
<div
Expected no space before '>', but found. (svelte/html-closing-bracket-spacing)
>
</div
Expected no space before '>', but found. (svelte/html-closing-bracket-spacing)
>

# 🔧 Options

{
  "svelte/html-closing-bracket-spacing": [
    "error",
    {
      "startTag": "never", // or "always" or "ignore"
      "endTag": "never", // or "always" or "ignore"
      "selfClosingTag": "always" // or "never" or "ignore"
    }
  ]
}
  • startTag ("never" by default)… Spacing in start tags
  • endTag ("never" by default)… Spacing in end tags
  • selfClosingTag ("always" by default)… Spacing in self closing tags

Every option can be set to

  • “always” (<div />)
  • “never” (<div/>)
  • “ignore” (either <div /> or <div/>)

# 🚀 Version

This rule was introduced in eslint-plugin-svelte v2.3.0

# 🔍 Implementation