# svelte/html-closing-bracket-new-line
Require or disallow a line break 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
This rule enforces a line break (or no line break) before tagβs closing brackets, which can also be configured to be enforced on self-closing tags.
<script>
/* eslint svelte/html-closing-bracket-new-line: "error" */
</script>
<!-- β GOOD -->
<div></div>
<div
multiline
>
Children
</div>
<SelfClosing />
<SelfClosing
multiline
/>
<!-- β BAD -->
<divExpected no line breaks before closing bracket, but 1 line break found. (svelte/html-closing-bracket-new-line)
></div>
<div
multilineExpected 1 line break before closing bracket, but no line breaks found. (svelte/html-closing-bracket-new-line)>
Children
</div>
<SelfClosingExpected no line breaks before closing bracket, but 1 line break found. (svelte/html-closing-bracket-new-line)
/>
<SelfClosing
multilineExpected 1 line break before closing bracket, but no line breaks found. (svelte/html-closing-bracket-new-line)/>
# π§ Options
{
"svelte/html-closing-bracket-new-line": [
"error",
{
"singleline": "never", // ["never", "always"]
"multiline": "always", // ["never", "always"]
"selfClosingTag": {
"singleline": "never", // ["never", "always"]
"multiline": "always" // ["never", "always"]
}
}
]
}
singleline
: ("never"
by default) Configuration for single-line elements. Itβs a single-line element if the element does not have attributes or the last attribute is on the same line as the opening bracket.multiline
: ("always"
by default) Configuration for multi-line elements. Itβs a multi-line element if the last attribute is not on the same line of the opening bracket.selfClosingTag.singleline
: Configuration for single-line self closing elements.selfClosingTag.multiline
: Configuration for multi-line self closing elements.
The selfClosing
is optional, and by default it will use the same configuration as singleline
and multiline
, respectively.
# π Version
This rule was introduced in eslint-plugin-svelte v2.45.0