-
-
Notifications
You must be signed in to change notification settings - Fork 681
New: vue/html-indent
rule (fixes #46)
#145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f020d17
New: `vue/html-indent` rule (fixes #46)
mysticatea 25a8f3c
remove garbages
mysticatea 55670ac
add some tests for comma in mustache
mysticatea 0cdb709
remove switchCase option from docs
mysticatea 762bae9
add tests for mix of text and mustache
mysticatea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"editor.tabSize": 2 | ||
"editor.tabSize": 2, | ||
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# enforce consistent indentation in `<template>` (vue/html-indent) | ||
|
||
## :book: Rule Details | ||
|
||
This rule enforces a consistent indentation style in `<template>`. The default style is 4 spaces as same as [the core indent rule](http://eslint.org/docs/rules/indent). | ||
|
||
- This rule checks all tags, also all expressions in directives and mustaches. | ||
- In the expressions, this rule supports ECMAScript 2017 syntaxes. It ignores unknown AST nodes, but it might be confused by non-standard syntaxes. | ||
|
||
:-1: Examples of **incorrect** code for this rule: | ||
|
||
```html | ||
<template> | ||
<div class="foo"> | ||
Hello. | ||
</div> | ||
</template> | ||
``` | ||
|
||
:+1: Examples of **correct** code for this rule: | ||
|
||
```html | ||
<template> | ||
<div class="foo"> | ||
Hello. | ||
</div> | ||
</template> | ||
``` | ||
|
||
```html | ||
<template> | ||
<div class="foo"> | ||
Hello. | ||
</div> | ||
<div | ||
id="a" | ||
class="b" | ||
:other-attr="{ | ||
aaa: 1, | ||
bbb: 2 | ||
}" | ||
@other-attr2=" | ||
foo(); | ||
bar(); | ||
" | ||
> | ||
{{ | ||
displayMessage | ||
}} | ||
</div> | ||
</template> | ||
``` | ||
|
||
## :wrench: Options | ||
|
||
```json | ||
{ | ||
"vue/html-indent": ["error", type, { | ||
"attribute": 1, | ||
"closeBracket": 0, | ||
"switchCase": 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you please add an example for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or maybe I should remove the option from this rule since |
||
"ignores": [] | ||
}] | ||
} | ||
``` | ||
|
||
- `type` (`number | "tab"`) ... The type 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. | ||
- `attribute` (`integer`) ... The multiplier of indentation for attributes. Default is `1`. | ||
- `closeBracket` (`integer`) ... The multiplier of indentation for right brackets. Default is `0`. | ||
- `ignores` (`string[]`) ... The selector to ignore nodes. The AST spec is [here](https://github.com/mysticatea/vue-eslint-parser/blob/master/docs/ast.md). You can use [esquery](https://github.com/estools/esquery#readme) to select nodes. Default is an empty array. | ||
|
||
:+1: Examples of **correct** code for `{attribute: 1, closeBracket: 1}`: | ||
|
||
```html | ||
<template> | ||
<div | ||
id="a" | ||
class="b" | ||
other-attr= | ||
"{longname: longvalue}" | ||
other-attr2 | ||
="{longname: longvalue}" | ||
> | ||
Text | ||
</div> | ||
</template> | ||
``` | ||
|
||
:+1: Examples of **correct** code for `{attribute: 2, closeBracket: 1}`: | ||
|
||
```html | ||
<template> | ||
<div | ||
id="a" | ||
class="b" | ||
other-attr= | ||
"{longname: longvalue}" | ||
other-attr2 | ||
="{longname: longvalue}" | ||
> | ||
Text | ||
</div> | ||
</template> | ||
``` | ||
|
||
:+1: Examples of **correct** code for `{ignores: ["VAttribute"]}`: | ||
|
||
```html | ||
<template> | ||
<div | ||
id="" | ||
class="" | ||
/> | ||
</template> | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems not related to the
vue/html-indent
. I think it can be in another PR?