Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules
coverage
.nyc_output
/.nyc_output
/coverage
/node_modules
/tests/fixtures
/tests/integrations/*/node_modules
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ Enforce all the rules in this category, as well as all higher priority rules, wi
|:---|:--------|:------------|
| :wrench: | [vue/html-closing-bracket-newline](./docs/rules/html-closing-bracket-newline.md) | require or disallow a line break before tag's closing brackets |
| :wrench: | [vue/html-closing-bracket-spacing](./docs/rules/html-closing-bracket-spacing.md) | require or disallow a space before tag's closing brackets |
| :wrench: | [vue/script-indent](./docs/rules/script-indent.md) | enforce consistent indentation in `<script>` |

<!--RULES_TABLE_END-->

Expand Down
4 changes: 2 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
machine:
node:
version: 4
version: 8

dependencies:
pre:
- nvm install 6
- nvm install 8
- nvm install 4

test:
override:
Expand Down
85 changes: 85 additions & 0 deletions docs/rules/script-indent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# enforce consistent indentation in `<script>` (script-indent)

- :wrench: The `--fix` option on the [command line](http://eslint.org/docs/user-guide/command-line-interface#fix) can automatically fix some of the problems reported by this rule.

This rule is similar to core [indent](https://eslint.org/docs/rules/indent) rule, but it has an option for inside of `<script>` tag.

## Rule Details

This rule has some options.

```json
{
"script-indent": ["error", TYPE, {
"baseIndent": 0,
"switchCase": 0,
"ignores": []
}]
}
```

- `TYPE` (`number | "tab"`) ... The type of indentation. Default is `2`. 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.
- `baseIndent` (`integer`) ... The multiplier of indentation for top-level statements. Default is `0`.
- `switchCase` (`integer`) ... The multiplier of indentation for `case`/`default` clauses. 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 this rule:

```js
/*eslint script-indent: "error"*/
<script>
let a = {
foo: 1,
bar: 2
}
let b = {
foo: 1,
bar: 2
},
c = {
foo: 1,
bar: 2
}
const d = {
foo: 1,
bar: 2
},
e = {
foo: 1,
bar: 2
}
</script>
```

:+1: Examples of **correct** code for this rule:

```js
/*eslint script-indent: ["error", 2, {"baseIndent": 1}]*/
<script>
let a = {
foo: 1,
bar: 2
}
let b = {
foo: 1,
bar: 2
},
c = {
foo: 1,
bar: 2
}
const d = {
foo: 1,
bar: 2
},
e = {
foo: 1,
bar: 2
}
</script>
```

## Related rules

- [indent](https://eslint.org/docs/rules/indent)
- [vue/html-indent](./html-indent.md)
Loading