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