Skip to content

Commit 8e5baca

Browse files
committed
docs(html-closing-bracket-new-line): add docs
1 parent b516c57 commit 8e5baca

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

docs/rules/html-closing-bracket-new-line.md

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ description: "require or disallow a line break before tag's closing brackets"
1414

1515
## :book: Rule Details
1616

17-
This rule reports ???.
17+
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.
1818

1919
<ESLintCodeBlock fix>
2020

@@ -26,8 +26,31 @@ This rule reports ???.
2626
</script>
2727
2828
<!-- ✓ GOOD -->
29+
<div></div>
30+
<div
31+
multiline
32+
>
33+
Children
34+
</div>
35+
36+
<SelfClosing />
37+
<SelfClosing
38+
multiline
39+
/>
2940
3041
<!-- ✗ BAD -->
42+
43+
<div
44+
></div>
45+
<div
46+
multiline>
47+
Children
48+
</div>
49+
50+
<SelfClosing
51+
/>
52+
<SelfClosing
53+
multiline />
3154
```
3255

3356
</ESLintCodeBlock>
@@ -36,15 +59,23 @@ This rule reports ???.
3659

3760
```json
3861
{
39-
"svelte/brackets-same-line": ["error", {}]
62+
"svelte/brackets-same-line": ["error", {
63+
"singleline": "never", // ["never", "always"]
64+
"multiline": "always", // ["never", "always"]
65+
"selfClosingTag": {
66+
"singleline": "never", // ["never", "always"]
67+
"multiline": "always" // ["never", "always"]
68+
}
69+
}]
4070
}
4171
```
4272

43-
-
44-
45-
## :books: Further Reading
73+
- `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.
74+
- `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.
75+
- `selfClosingTag.singleline`: Configuration for single-line self closing elements.
76+
- `selfClosingTag.multiline`: Configuration for multi-line self closing elements.
4677

47-
-
78+
The `selfClosing` is optional, and by default it will use the same configuration as `singleline` and `multiline`, respectively.
4879

4980
## :mag: Implementation
5081

packages/eslint-plugin-svelte/src/rules/html-closing-bracket-new-line.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function getNodeData(
8787
export default createRule('html-closing-bracket-new-line', {
8888
meta: {
8989
docs: {
90-
description: "require or disallow a line break before tag's closing brackets",
90+
description: "Require or disallow a line break before tag's closing brackets",
9191
category: 'Stylistic Issues',
9292
recommended: false,
9393
conflictWithPrettier: true

0 commit comments

Comments
 (0)