Skip to content

Latest commit

 

History

History
83 lines (66 loc) · 2.01 KB

html-closing-bracket-spacing.md

File metadata and controls

83 lines (66 loc) · 2.01 KB

require or disallow a space before tag's closing brackets (weex/vue/html-closing-bracket-spacing)

  • 🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

This rule enforces consistent spacing style before closing brackets > of tags.

<div class="foo"> or <div class="foo" >
<div class="foo"/> or <div class="foo" />

Rule Details

This rule has options.

{
    "html-closing-bracket-spacing": ["error", {
        "startTag": "always" | "never",
        "endTag": "always" | "never",
        "selfClosingTag": "always" | "never"
    }]
}
  • startTag ("always" | "never") ... Setting for the > of start tags (e.g. <div>). Default is "never".
    • "always" ... requires one or more spaces.
    • "never" ... disallows spaces.
  • endTag ("always" | "never") ... Setting for the > of end tags (e.g. </div>). Default is "never".
    • "always" ... requires one or more spaces.
    • "never" ... disallows spaces.
  • selfClosingTag ("always" | "never") ... Setting for the /> of self-closing tags (e.g. <div/>). Default is "always".
    • "always" ... requires one or more spaces.
    • "never" ... disallows spaces.

Examples of incorrect code for this rule:

<!--eslint html-closing-bracket-spacing: "error" -->

<div >
<div foo >
<div foo="bar" >
</div >
<div/>
<div foo/>
<div foo="bar"/>

Examples of correct code for this rule:

<!--eslint html-closing-bracket-spacing: "error" -->

<div>
<div foo>
<div foo="bar">
</div>
<div />
<div foo />
<div foo="bar" />
<!--eslint html-closing-bracket-spacing: ["error", {
    "startTag": "always",
    "endTag": "always",
    "selfClosingTag": "always"
}] -->

<div >
<div foo >
<div foo="bar" >
</div >
<div />
<div foo />
<div foo="bar" />

Related rules