Skip to content

Commit a5e5e5f

Browse files
committed
New: vue/html-indent rule (fixes #46)
1 parent 164b2ae commit a5e5e5f

File tree

4 files changed

+1215
-1
lines changed

4 files changed

+1215
-1
lines changed

docs/rules/html-indent.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# enforce consistent indentation in `<template>` (vue/html-indent)
2+
3+
## :book: Rule Details
4+
5+
This rule enforces a consistent indentation style. The default style is 4 spaces as same as [the core indent rule](http://eslint.org/docs/rules/indent).
6+
7+
:-1: Examples of **incorrect** code for this rule:
8+
9+
```html
10+
<template>
11+
<div class="foo">
12+
Hello.
13+
</div>
14+
</template>
15+
```
16+
17+
:+1: Examples of **correct** code for this rule:
18+
19+
```html
20+
<template>
21+
<div class="foo">
22+
Hello.
23+
</div>
24+
<div
25+
id="a"
26+
class="b"
27+
other-attr=
28+
"{longname: longvalue}"
29+
other-attr2
30+
="{longname: longvalue}"
31+
>
32+
Text
33+
</div>
34+
</template>
35+
```
36+
37+
## :wrench: Options
38+
39+
```json
40+
{
41+
"vue/html-indent": ["error", kind, {
42+
"attribute": 1,
43+
"closeBracket": 0
44+
}]
45+
}
46+
```
47+
48+
- `kind` (`number | "tab"`) ... The kind of indentation. Default is `4`. If this is a number, it's the number of spaces for one indent. If this is `"tab"`, it uses one tab for one indent.
49+
- `attribute` (`integer`) ... The multiplier of indentation for attributes. Default is `1`.
50+
- `closeBracket` (`integer`) ... The multiplier of indentation for right brackets. Default is `0`.
51+
52+
:+1: Examples of **correct** code for `{attribute: 1, closeBracket: 1}`:
53+
54+
```html
55+
<template>
56+
<div
57+
id="a"
58+
class="b"
59+
other-attr=
60+
"{longname: longvalue}"
61+
other-attr2
62+
="{longname: longvalue}"
63+
>
64+
Text
65+
</div>
66+
</template>
67+
```
68+
69+
:+1: Examples of **correct** code for `{attribute: 2, closeBracket: 1}`:
70+
71+
```html
72+
<template>
73+
<div
74+
id="a"
75+
class="b"
76+
other-attr=
77+
"{longname: longvalue}"
78+
other-attr2
79+
="{longname: longvalue}"
80+
>
81+
Text
82+
</div>
83+
</template>
84+
```

0 commit comments

Comments
 (0)