Skip to content

Commit ab99b7b

Browse files
committed
update html-closing-bracket-spacing rule
1 parent 54a8e42 commit ab99b7b

File tree

1 file changed

+48
-60
lines changed

1 file changed

+48
-60
lines changed

docs/rules/html-closing-bracket-spacing.md

Lines changed: 48 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,41 @@
33
- :gear: This rule is included in `"plugin:vue/strongly-recommended"` and `"plugin:vue/recommended"`.
44
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
55

6-
This rule enforces consistent spacing style before closing brackets `>` of tags.
7-
8-
```html
9-
<div class="foo"> or <div class="foo" >
10-
<div class="foo"/> or <div class="foo" />
11-
```
12-
13-
## Rule Details
14-
15-
This rule has options.
6+
## :book: Rule Details
7+
8+
This rule aims to enforce consistent spacing style before closing brackets `>` of tags.
9+
10+
<eslint-code-block :rules="{'vue/html-closing-bracket-spacing': ['error']}" code="
11+
&lt;template&gt;
12+
&lt;!-- ✓ GOOD --&gt;
13+
&lt;div&gt;
14+
&lt;div foo&gt;
15+
&lt;div foo=&quot;bar&quot;&gt;
16+
&lt;/div&gt;
17+
&lt;div /&gt;
18+
&lt;div foo /&gt;
19+
&lt;div foo=&quot;bar&quot; /&gt;
20+
21+
&lt;!-- ✗ BAD --&gt;
22+
&lt;div &gt;
23+
&lt;div foo &gt;
24+
&lt;div foo=&quot;bar&quot; &gt;
25+
&lt;/div &gt;
26+
&lt;div/&gt;
27+
&lt;div foo/&gt;
28+
&lt;div foo=&quot;bar&quot;/&gt;
29+
&lt;/template&gt;
30+
" />
31+
32+
## :wrench: Options
1633

1734
```json
1835
{
19-
"vue/html-closing-bracket-spacing": ["error", {
20-
"startTag": "always" | "never",
21-
"endTag": "always" | "never",
22-
"selfClosingTag": "always" | "never"
23-
}]
36+
"vue/html-closing-bracket-spacing": ["error", {
37+
"startTag": "always" | "never",
38+
"endTag": "always" | "never",
39+
"selfClosingTag": "always" | "never"
40+
}]
2441
}
2542
```
2643

@@ -34,51 +51,22 @@ This rule has options.
3451
- `"always"` ... requires one or more spaces.
3552
- `"never"` ... disallows spaces.
3653

37-
Examples of **incorrect** code for this rule:
38-
39-
```html
40-
<!--eslint html-closing-bracket-spacing: "error" -->
41-
42-
<div >
43-
<div foo >
44-
<div foo="bar" >
45-
</div >
46-
<div/>
47-
<div foo/>
48-
<div foo="bar"/>
49-
```
50-
51-
Examples of **correct** code for this rule:
52-
53-
```html
54-
<!--eslint html-closing-bracket-spacing: "error" -->
55-
56-
<div>
57-
<div foo>
58-
<div foo="bar">
59-
</div>
60-
<div />
61-
<div foo />
62-
<div foo="bar" />
63-
```
64-
65-
```html
66-
<!--eslint html-closing-bracket-spacing: ["error", {
67-
"startTag": "always",
68-
"endTag": "always",
69-
"selfClosingTag": "always"
70-
}] -->
71-
72-
<div >
73-
<div foo >
74-
<div foo="bar" >
75-
</div >
76-
<div />
77-
<div foo />
78-
<div foo="bar" />
79-
```
80-
81-
# Related rules
54+
### `{ "startTag": "always", "endTag": "always", "selfClosingTag": "always" }`
55+
56+
<eslint-code-block :rules="{'vue/html-closing-bracket-spacing': ['error', {strtTag: 'always', endTag: 'always', selfClosingTag: 'always' }]}" code="
57+
&lt;template&gt;
58+
&lt;!-- ✓ GOOD --&gt;
59+
&lt;div &gt;
60+
&lt;div foo &gt;
61+
&lt;div foo=&quot;bar&quot; &gt;
62+
&lt;/div &gt;
63+
&lt;div /&gt;
64+
&lt;div foo /&gt;
65+
&lt;div foo=&quot;bar&quot; /&gt;
66+
&lt;/template&gt;
67+
" />
68+
69+
## :bookmark: Related rules
8270

8371
- [vue/no-multi-spaces](./no-multi-spaces.md)
8472
- [vue/html-closing-bracket-newline](./html-closing-bracket-newline.md)

0 commit comments

Comments
 (0)