Skip to content

Commit df1207b

Browse files
Merge branch 'master' into 47-props-per-line
2 parents ed73ad8 + 3361366 commit df1207b

File tree

78 files changed

+2591
-273
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+2591
-273
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

README.md

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ The `--fix` option on the command line automatically fixes problems reported by
6666
|:---|:--------|:------------|
6767
| :wrench: | [html-end-tags](./docs/rules/html-end-tags.md) | enforce end tag style. |
6868
| :wrench: | [html-no-self-closing](./docs/rules/html-no-self-closing.md) | disallow self-closing elements. |
69+
| | [no-async-in-computed-properties](./docs/rules/no-async-in-computed-properties.md) | Check if there are no asynchronous actions inside computed properties. |
6970
| :white_check_mark: | [no-confusing-v-for-v-if](./docs/rules/no-confusing-v-for-v-if.md) | disallow confusing `v-for` and `v-if` on the same element. |
70-
| | [no-duplicate-attributes](./docs/rules/no-duplicate-attributes.md) | disallow duplicate arguments. |
71+
| | [no-duplicate-attributes](./docs/rules/no-duplicate-attributes.md) | disallow duplicate attributes. |
72+
| | [no-side-effects-in-computed-properties](./docs/rules/no-side-effects-in-computed-properties.md) | Don't introduce side effects in computed properties |
7173
| :white_check_mark: | [no-textarea-mustache](./docs/rules/no-textarea-mustache.md) | disallow mustaches in `<textarea>`. |
7274
| | [order-in-components](./docs/rules/order-in-components.md) | Keep order of properties in components |
7375
| :white_check_mark: | [require-component-is](./docs/rules/require-component-is.md) | require `v-bind:is` of `<component>` elements. |
@@ -79,8 +81,9 @@ The `--fix` option on the command line automatically fixes problems reported by
7981
| | Rule ID | Description |
8082
|:---|:--------|:------------|
8183
| | [html-quotes](./docs/rules/html-quotes.md) | enforce quotes style of HTML attributes. |
82-
| :wrench: | [v-bind-style](./docs/rules/v-bind-style.md) | enforce v-bind directive style. |
83-
| :wrench: | [v-on-style](./docs/rules/v-on-style.md) | enforce v-on directive style. |
84+
| :wrench: | [name-property-casing](./docs/rules/name-property-casing.md) | Requires specific casing for the name property in Vue components |
85+
| :wrench: | [v-bind-style](./docs/rules/v-bind-style.md) | enforce `v-bind` directive style. |
86+
| :wrench: | [v-on-style](./docs/rules/v-on-style.md) | enforce `v-on` directive style. |
8487

8588

8689
### Variables
@@ -95,23 +98,50 @@ The `--fix` option on the command line automatically fixes problems reported by
9598
| | Rule ID | Description |
9699
|:---|:--------|:------------|
97100
| :white_check_mark: | [no-invalid-template-root](./docs/rules/no-invalid-template-root.md) | disallow invalid template root. |
98-
| :white_check_mark: | [no-invalid-v-bind](./docs/rules/no-invalid-v-bind.md) | disallow invalid v-bind directives. |
99-
| :white_check_mark: | [no-invalid-v-cloak](./docs/rules/no-invalid-v-cloak.md) | disallow invalid v-cloak directives. |
100-
| :white_check_mark: | [no-invalid-v-else-if](./docs/rules/no-invalid-v-else-if.md) | disallow invalid v-else-if directives. |
101-
| :white_check_mark: | [no-invalid-v-else](./docs/rules/no-invalid-v-else.md) | disallow invalid v-else directives. |
102-
| :white_check_mark: | [no-invalid-v-for](./docs/rules/no-invalid-v-for.md) | disallow invalid v-for directives. |
103-
| :white_check_mark: | [no-invalid-v-html](./docs/rules/no-invalid-v-html.md) | disallow invalid v-html directives. |
104-
| :white_check_mark: | [no-invalid-v-if](./docs/rules/no-invalid-v-if.md) | disallow invalid v-if directives. |
105-
| :white_check_mark: | [no-invalid-v-model](./docs/rules/no-invalid-v-model.md) | disallow invalid v-model directives. |
106-
| :white_check_mark: | [no-invalid-v-on](./docs/rules/no-invalid-v-on.md) | disallow invalid v-on directives. |
107-
| :white_check_mark: | [no-invalid-v-once](./docs/rules/no-invalid-v-once.md) | disallow invalid v-once directives. |
108-
| :white_check_mark: | [no-invalid-v-pre](./docs/rules/no-invalid-v-pre.md) | disallow invalid v-pre directives. |
109-
| :white_check_mark: | [no-invalid-v-show](./docs/rules/no-invalid-v-show.md) | disallow invalid v-show directives. |
110-
| :white_check_mark: | [no-invalid-v-text](./docs/rules/no-invalid-v-text.md) | disallow invalid v-text directives. |
101+
| :white_check_mark: | [no-invalid-v-bind](./docs/rules/no-invalid-v-bind.md) | disallow invalid `v-bind` directives. |
102+
| :white_check_mark: | [no-invalid-v-cloak](./docs/rules/no-invalid-v-cloak.md) | disallow invalid `v-cloak` directives. |
103+
| :white_check_mark: | [no-invalid-v-else-if](./docs/rules/no-invalid-v-else-if.md) | disallow invalid `v-else-if` directives. |
104+
| :white_check_mark: | [no-invalid-v-else](./docs/rules/no-invalid-v-else.md) | disallow invalid `v-else` directives. |
105+
| :white_check_mark: | [no-invalid-v-for](./docs/rules/no-invalid-v-for.md) | disallow invalid `v-for` directives. |
106+
| :white_check_mark: | [no-invalid-v-html](./docs/rules/no-invalid-v-html.md) | disallow invalid `v-html` directives. |
107+
| :white_check_mark: | [no-invalid-v-if](./docs/rules/no-invalid-v-if.md) | disallow invalid `v-if` directives. |
108+
| :white_check_mark: | [no-invalid-v-model](./docs/rules/no-invalid-v-model.md) | disallow invalid `v-model` directives. |
109+
| :white_check_mark: | [no-invalid-v-on](./docs/rules/no-invalid-v-on.md) | disallow invalid `v-on` directives. |
110+
| :white_check_mark: | [no-invalid-v-once](./docs/rules/no-invalid-v-once.md) | disallow invalid `v-once` directives. |
111+
| :white_check_mark: | [no-invalid-v-pre](./docs/rules/no-invalid-v-pre.md) | disallow invalid `v-pre` directives. |
112+
| :white_check_mark: | [no-invalid-v-show](./docs/rules/no-invalid-v-show.md) | disallow invalid `v-show` directives. |
113+
| :white_check_mark: | [no-invalid-v-text](./docs/rules/no-invalid-v-text.md) | disallow invalid `v-text` directives. |
111114
| :white_check_mark: | [no-parsing-error](./docs/rules/no-parsing-error.md) | disallow parsing errors in `<template>`. |
115+
| | [no-shared-component-data](./docs/rules/no-shared-component-data.md) | Enforces component's data property to be a function. |
116+
| | [no-template-key](./docs/rules/no-template-key.md) | disallow `key` attribute on `<template>`. |
117+
| | [return-in-computed-property](./docs/rules/return-in-computed-property.md) | Enforces that a return statement is present in computed property. |
112118

113119
<!--RULES_TABLE_END-->
114120

121+
## :couple: FAQ
122+
123+
### What is the "Use the latest vue-eslint-parser" error?
124+
125+
The most rules of `eslint-plugin-vue` require `vue-eslint-parser` to check `<template>` ASTs.
126+
127+
Make sure you have one of the following settings in your **.eslintrc**:
128+
129+
- `"extends": ["plugin:vue/recommended"]`
130+
- `"extends": ["plugin:vue/base"]`
131+
132+
If you already use other parser (e.g. `"parser": "babel-eslint"`), please move it into `parserOptions`, so it doesn't collide with the `vue-eslint-parser` used by this plugin's configuration:
133+
134+
```diff
135+
- "parser": "babel-eslint",
136+
"parserOptions": {
137+
+ "parser": "babel-eslint",
138+
"ecmaVersion": 2017,
139+
"sourceType": "module"
140+
}
141+
```
142+
143+
The `vue-eslint-parser` uses the parser which is set by `parserOptions.parser` to parse scripts.
144+
115145
## :anchor: Semantic Versioning Policy
116146

117147
This plugin follows [semantic versioning](http://semver.org/) and [ESLint's Semantic Versioning Policy](https://github.com/eslint/eslint#semantic-versioning-policy).

docs/rules/html-end-tags.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# Enforce end tag style (html-end-tags)
22

3-
- 🔧 This rule is fixable with `eslint --fix` command.
3+
- :wrench: This rule is fixable with `eslint --fix` command.
44

55
This rule enforce the way of end tags.
66

77
- [Void elements] disallow end tags.
88
- Other elements require end tags.
99

10-
## 📖 Rule Details
10+
## :book: Rule Details
1111

1212
This rule reports the following elements:
1313

1414
- [Void elements] which have end tags.
1515
- Other elements which do not have end tags and are not self-closing.
1616

17-
👎 Examples of **incorrect** code for this rule:
17+
:-1: Examples of **incorrect** code for this rule:
1818

1919
```html
2020
<template>
@@ -28,7 +28,7 @@ This rule reports the following elements:
2828
</template>
2929
```
3030

31-
👍 Examples of **correct** code for this rule:
31+
:+1: Examples of **correct** code for this rule:
3232

3333
```html
3434
<template>
@@ -42,7 +42,7 @@ This rule reports the following elements:
4242
</template>
4343
```
4444

45-
## 🔧 Options
45+
## :wrench: Options
4646

4747
Nothing.
4848

docs/rules/html-no-self-closing.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Disallow self-closing elements (html-no-self-closing)
22

3-
- 🔧 This rule is fixable with `eslint --fix` command.
3+
- :wrench: This rule is fixable with `eslint --fix` command.
44

55
Self-closing (e.g. `<br/>`) is syntax of XML/XHTML.
66
HTML ignores it.
77

8-
## 📖 Rule Details
8+
## :book: Rule Details
99

1010
This rule reports every self-closing element except XML context.
1111

12-
👎 Examples of **incorrect** code for this rule:
12+
:-1: Examples of **incorrect** code for this rule:
1313

1414
```html
1515
<template>
@@ -19,7 +19,7 @@ This rule reports every self-closing element except XML context.
1919
</template>
2020
```
2121

22-
👍 Examples of **correct** code for this rule:
22+
:+1: Examples of **correct** code for this rule:
2323

2424
```html
2525
<template>
@@ -33,6 +33,6 @@ This rule reports every self-closing element except XML context.
3333
</template>
3434
```
3535

36-
## 🔧 Options
36+
## :wrench: Options
3737

3838
Nothing.

docs/rules/html-quotes.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# Enforce quotes style of HTML attributes (html-quotes)
22

3-
You can shoose quotes of HTML attributes from:
3+
You can choose quotes of HTML attributes from:
44

55
- Double quotes: `<div class="foo">`
66
- Single quotes: `<div class='foo'>`
77
- No quotes: `<div class=foo>`
88

99
This rule enforces the quotes style of HTML attributes.
1010

11-
## 📖 Rule Details
11+
## :book: Rule Details
1212

1313
This rule reports the quotes of attributes if it is different to configured quotes.
1414

15-
👎 Examples of **incorrect** code for this rule:
15+
:-1: Examples of **incorrect** code for this rule:
1616

1717
```html
1818
<template>
@@ -23,7 +23,7 @@ This rule reports the quotes of attributes if it is different to configured quot
2323
</template>
2424
```
2525

26-
👍 Examples of **correct** code for this rule:
26+
:+1: Examples of **correct** code for this rule:
2727

2828
```html
2929
<template>
@@ -33,7 +33,7 @@ This rule reports the quotes of attributes if it is different to configured quot
3333
</template>
3434
```
3535

36-
👎 Examples of **incorrect** code for this rule with `"single"` option:
36+
:-1: Examples of **incorrect** code for this rule with `"single"` option:
3737

3838
```html
3939
<template>
@@ -44,7 +44,7 @@ This rule reports the quotes of attributes if it is different to configured quot
4444
</template>
4545
```
4646

47-
👍 Examples of **correct** code for this rule with `"single"` option:
47+
:+1: Examples of **correct** code for this rule with `"single"` option:
4848

4949
```html
5050
<template>
@@ -54,7 +54,7 @@ This rule reports the quotes of attributes if it is different to configured quot
5454
</template>
5555
```
5656

57-
## 🔧 Options
57+
## :wrench: Options
5858

5959
- `"double"` (default) ... requires double quotes.
6060
- `"single"` ... requires single quotes.

docs/rules/name-property-casing.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Requires specific casing for the name property in Vue components (name-property-casing)
2+
3+
Define a style for the `name` property casing for consistency purposes.
4+
5+
## :book: Rule Details
6+
7+
:+1: Examples of **correct** code for `PascalCase`:
8+
9+
```js
10+
export default {
11+
name: 'MyComponent'
12+
}
13+
```
14+
15+
:+1: Examples of **correct** code for `kebab-case`:
16+
17+
```js
18+
export default {
19+
name: 'my-component'
20+
}
21+
```
22+
23+
:+1: Examples of **correct** code for `camelCase`:
24+
25+
```js
26+
export default {
27+
name: 'myComponent'
28+
}
29+
```
30+
31+
## :wrench: Options
32+
33+
Default casing is set to `PascalCase`
34+
35+
```
36+
'vue/name-property-casing': [2, 'camelCase|kebab-case|PascalCase']
37+
```
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Check if there are no asynchronous actions inside computed properties (no-async-in-computed-properties)
2+
3+
Computed properties should be synchronous. Asynchronous actions inside them may not work as expected and can lead to an unexpected behaviour, that's why you should avoid them.
4+
If you need async computed properties you might want to consider using additional plugin [vue-async-computed]
5+
6+
## :book: Rule Details
7+
8+
This rule is aimed at preventing asynchronous methods from being called in computed properties.
9+
10+
:-1: Examples of **incorrect** code for this rule:
11+
12+
```js
13+
export default {
14+
computed: {
15+
pro () {
16+
return Promise.all([new Promise((resolve, reject) => {})])
17+
},
18+
foo: async function () {
19+
return await someFunc()
20+
},
21+
bar () {
22+
return fetch(url).then(response => {})
23+
},
24+
tim () {
25+
setTimeout(() => { }, 0)
26+
},
27+
inter () {
28+
setInterval(() => { }, 0)
29+
},
30+
anim () {
31+
requestAnimationFrame(() => {})
32+
}
33+
}
34+
}
35+
```
36+
37+
:+1: Examples of **correct** code for this rule:
38+
39+
```js
40+
export default {
41+
computed: {
42+
foo () {
43+
var bar = 0
44+
try {
45+
bar = bar / this.a
46+
} catch (e) {
47+
return 0
48+
} finally {
49+
return bar
50+
}
51+
}
52+
}
53+
}
54+
```
55+
56+
## :wrench: Options
57+
58+
Nothing.
59+
60+
[vue-async-computed]: https://github.com/foxbenjaminfox/vue-async-computed

docs/rules/no-confusing-v-for-v-if.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
77
So when they exist on the same node, `v-if` directive should use the reference which is to the variables which are defined by the `v-for` directives.
88

9-
## 📖 Rule Details
9+
## :book: Rule Details
1010

1111
This rule reports the elements which have both `v-for` and `v-if` directives in the following cases:
1212

1313
- The `v-if` directive does not use the reference which is to the variables which are defined by the `v-for` directives.
1414

1515
In that case, the `v-if` should be written on the wrapper element.
1616

17-
👎 Examples of **incorrect** code for this rule:
17+
:-1: Examples of **incorrect** code for this rule:
1818

1919
```html
2020
<template>
@@ -26,7 +26,7 @@ In that case, the `v-if` should be written on the wrapper element.
2626
</template>
2727
```
2828

29-
👍 Examples of **correct** code for this rule:
29+
:+1: Examples of **correct** code for this rule:
3030

3131
```html
3232
<template>
@@ -48,6 +48,6 @@ In that case, the `v-if` should be written on the wrapper element.
4848
</template>
4949
```
5050

51-
## 🔧 Options
51+
## :wrench: Options
5252

5353
Nothing.

0 commit comments

Comments
 (0)