Skip to content

Commit 2f0492d

Browse files
author
Filipa Lacerda
committed
Merge branch 'master' into 47-props-per-line
* master: Add rule `vue/require-valid-default-prop`. (vuejs#119) 3.10.0 Update readme to 3.10.0 Chore: remove package-lock.json (vuejs#128) Fix: parserService must exist always (fixes vuejs#125) (vuejs#127) Add rule `require-render-return`. (vuejs#114) 3.9.0 Update package-lock Update: options for `no-duplicate-attributes` (fixes vuejs#112)(vuejs#113) New: add rule `attribute-hyphenation`. (fixes vuejs#92)(vuejs#95) Add namespace check of svg & mathML instead of tag names (vuejs#120) ⚠️ Add support for deprecated state in update-rules ⚠️ (vuejs#121) Add rules: `no-dupe-keys` and `no-reserved-keys`. (vuejs#88) Chore: Improve tests for name-property-casing & improve documentation (vuejs#115) New: add `require-prop-types` rule (fixes vuejs#19)(vuejs#85) Update: upgrade vue-eslint-parser (fixes vuejs#36, fixes vuejs#56, fixes vuejs#96) (vuejs#116)
2 parents 982d9f2 + a3d64c7 commit 2f0492d

Some content is hidden

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

66 files changed

+3115
-2375
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules
22
lib/recommended-rules.js
3+
coverage
4+
.nyc_output

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

README.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,34 +58,38 @@ No rules are enabled by `plugin:vue/base` config. The `plugin:vue/recommended` c
5858

5959
The `--fix` option on the command line automatically fixes problems reported by rules which have a wrench :wrench: below.
6060

61+
Deprecated rules witch should be used with caution and only enabled when you know what you are doing have a warning :warning: icon.
62+
6163
<!--RULES_TABLE_START-->
6264

65+
### Stylistic Issues
66+
67+
| | Rule ID | Description |
68+
|:---|:--------|:------------|
69+
| :wrench: | [attribute-hyphenation](./docs/rules/attribute-hyphenation.md) | Define a style for the props casing in templates. |
70+
| | [html-quotes](./docs/rules/html-quotes.md) | enforce quotes style of HTML attributes. |
71+
| :wrench: | [name-property-casing](./docs/rules/name-property-casing.md) | Requires specific casing for the name property in Vue components |
72+
| :wrench: | [v-bind-style](./docs/rules/v-bind-style.md) | enforce `v-bind` directive style. |
73+
| :wrench: | [v-on-style](./docs/rules/v-on-style.md) | enforce `v-on` directive style. |
74+
75+
6376
### Best Practices
6477

6578
| | Rule ID | Description |
6679
|:---|:--------|:------------|
6780
| :wrench: | [html-end-tags](./docs/rules/html-end-tags.md) | enforce end tag style. |
68-
| :wrench: | [html-no-self-closing](./docs/rules/html-no-self-closing.md) | disallow self-closing elements. |
81+
| :wrench::warning: | [html-no-self-closing](./docs/rules/html-no-self-closing.md) | disallow self-closing elements. - (deprecated) |
6982
| | [no-async-in-computed-properties](./docs/rules/no-async-in-computed-properties.md) | Check if there are no asynchronous actions inside computed properties. |
7083
| :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. |
7184
| | [no-duplicate-attributes](./docs/rules/no-duplicate-attributes.md) | disallow duplicate attributes. |
7285
| | [no-side-effects-in-computed-properties](./docs/rules/no-side-effects-in-computed-properties.md) | Don't introduce side effects in computed properties |
7386
| :white_check_mark: | [no-textarea-mustache](./docs/rules/no-textarea-mustache.md) | disallow mustaches in `<textarea>`. |
7487
| | [order-in-components](./docs/rules/order-in-components.md) | Keep order of properties in components |
7588
| :white_check_mark: | [require-component-is](./docs/rules/require-component-is.md) | require `v-bind:is` of `<component>` elements. |
89+
| | [require-prop-types](./docs/rules/require-prop-types.md) | Prop definitions should be detailed |
7690
| :white_check_mark: | [require-v-for-key](./docs/rules/require-v-for-key.md) | require `v-bind:key` with `v-for` directives. |
7791

7892

79-
### Stylistic Issues
80-
81-
| | Rule ID | Description |
82-
|:---|:--------|:------------|
83-
| | [html-quotes](./docs/rules/html-quotes.md) | enforce quotes style of HTML attributes. |
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. |
87-
88-
8993
### Variables
9094

9195
| | Rule ID | Description |
@@ -97,6 +101,7 @@ The `--fix` option on the command line automatically fixes problems reported by
97101

98102
| | Rule ID | Description |
99103
|:---|:--------|:------------|
104+
| | [no-dupe-keys](./docs/rules/no-dupe-keys.md) | Prevents duplication of field names. |
100105
| :white_check_mark: | [no-invalid-template-root](./docs/rules/no-invalid-template-root.md) | disallow invalid template root. |
101106
| :white_check_mark: | [no-invalid-v-bind](./docs/rules/no-invalid-v-bind.md) | disallow invalid `v-bind` directives. |
102107
| :white_check_mark: | [no-invalid-v-cloak](./docs/rules/no-invalid-v-cloak.md) | disallow invalid `v-cloak` directives. |
@@ -112,8 +117,10 @@ The `--fix` option on the command line automatically fixes problems reported by
112117
| :white_check_mark: | [no-invalid-v-show](./docs/rules/no-invalid-v-show.md) | disallow invalid `v-show` directives. |
113118
| :white_check_mark: | [no-invalid-v-text](./docs/rules/no-invalid-v-text.md) | disallow invalid `v-text` directives. |
114119
| :white_check_mark: | [no-parsing-error](./docs/rules/no-parsing-error.md) | disallow parsing errors in `<template>`. |
120+
| | [no-reservered-keys](./docs/rules/no-reservered-keys.md) | Prevent overwrite reserved keys. |
115121
| | [no-shared-component-data](./docs/rules/no-shared-component-data.md) | Enforces component's data property to be a function. |
116122
| | [no-template-key](./docs/rules/no-template-key.md) | disallow `key` attribute on `<template>`. |
123+
| | [require-render-return](./docs/rules/require-render-return.md) | Enforces render function to always return value. |
117124
| | [return-in-computed-property](./docs/rules/return-in-computed-property.md) | Enforces that a return statement is present in computed property. |
118125

119126
<!--RULES_TABLE_END-->

docs/rules/attribute-hyphenation.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Define if attributes on cusom components can be hyphened. (attribute-hyphenation)
2+
3+
## :wrench: Options
4+
5+
Default casing is set to `always`
6+
7+
```
8+
'vue/attribute-hyphenation': [2, 'always'|'never']
9+
```
10+
11+
### `"always"` - Use hyphenated name. (It errors on upper case letters.)
12+
13+
:+1: Examples of **correct** code`:
14+
15+
```html
16+
<template>
17+
<foo my-prop="prop">
18+
<a onClick="return false"></a>
19+
</foo>
20+
</template>
21+
```
22+
23+
:-1: Examples of **incorrect** code`:
24+
25+
```html
26+
<template>
27+
<foo myProp="prop">
28+
<a onClick="return false"></a>
29+
</foo>
30+
</template>
31+
```
32+
33+
### `"never"` - Don't use hyphenated name. (It errors on hyphens except `data-` and `aria-`.)
34+
35+
:+1: Examples of **correct** code`:
36+
37+
```html
38+
<template>
39+
<foo myProp="prop">
40+
<a onClick="return false"></a>
41+
</foo>
42+
</template>
43+
```
44+
45+
:-1: Examples of **incorrect** code`:
46+
47+
```html
48+
<template>
49+
<foo my-prop="prop">
50+
<a onClick="return false"></a>
51+
</foo>
52+
</template>
53+
```

docs/rules/no-dupe-keys.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Prevents duplication of field names (no-dupe-keys)
2+
3+
This rule prevents to use duplicated names.
4+
5+
## :book: Rule Details
6+
7+
This rule is aimed at preventing duplicated property names.
8+
9+
:-1: Examples of **incorrect** code for this rule:
10+
11+
```js
12+
export default {
13+
props: {
14+
foo: String
15+
},
16+
computed: {
17+
foo: {
18+
get () {
19+
}
20+
}
21+
},
22+
data: {
23+
foo: null
24+
},
25+
methods: {
26+
foo () {
27+
}
28+
}
29+
}
30+
```
31+
32+
:+1: Examples of **correct** code for this rule:
33+
34+
```js
35+
export default {
36+
props: ['foo'],
37+
computed: {
38+
bar () {
39+
}
40+
},
41+
data () {
42+
return {
43+
dat: null
44+
}
45+
},
46+
methods: {
47+
test () {
48+
}
49+
}
50+
}
51+
```
52+
53+
## :wrench: Options
54+
55+
This rule has an object option:
56+
57+
`"groups"`: [] (default) array of additional groups to search for duplicates.
58+
59+
### Example:
60+
61+
```
62+
vue/no-dupe-keys: [2, {
63+
groups: ['asyncComputed']
64+
}]
65+
```
66+
67+
:-1: Examples of **incorrect** code for this configuration
68+
69+
```js
70+
export default {
71+
computed: {
72+
foo () {}
73+
},
74+
asyncComputed: {
75+
foo () {}
76+
}
77+
}
78+
```

docs/rules/no-duplicate-attributes.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,20 @@ This rule reports duplicate attributes.
2727

2828
## :wrench: Options
2929

30-
Nothing.
30+
`allowCoexistClass` - Enables [`v-bind:class`] directive can coexist with the plain `class` attribute.
31+
`allowCoexistStyle` - Enables [`v-bind:style`] directive can coexist with the plain `style` attribute.
32+
33+
```
34+
'vue/name-property-casing': [2, {
35+
allowCoexistClass: Boolean // default: true
36+
allowCoexistStyle: Boolean, // default: true
37+
}]
38+
```
3139

3240
## TODO: `<div foo foo></div>`
3341

3442
`parse5` remove duplicate attributes on the tokenization phase.
3543
Needs investigation to check.
44+
45+
[`v-bind:class`]: https://vuejs.org/v2/guide/class-and-style.html
46+
[`v-bind:style`]: https://vuejs.org/v2/guide/class-and-style.html

docs/rules/no-parsing-error.md

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Disallow parsing errors in `<template>` (no-parsing-error)
22

3-
This rule reports syntax errors in directives/mustaches of `<template>`.
3+
This rule reports syntax errors in `<template>`. For example:
4+
5+
- Syntax errors of scripts in directives.
6+
- Syntax errors of scripts in mustaches.
7+
- Syntax errors of HTML.
8+
- Invalid end tags.
9+
- Attributes in end tags.
10+
- ...
11+
- See also: https://html.spec.whatwg.org/multipage/parsing.html#parse-errors
412

513
## :book: Rule Details
614

@@ -25,4 +33,56 @@ Then reports syntax errors if exist.
2533

2634
## :wrench: Options
2735

28-
Nothing.
36+
```json
37+
{
38+
"vue/no-parsing-error": ["error", {
39+
"abrupt-closing-of-empty-comment": false,
40+
"absence-of-digits-in-numeric-character-reference": false,
41+
"cdata-in-html-content": false,
42+
"character-reference-outside-unicode-range": false,
43+
"control-character-in-input-stream": false,
44+
"control-character-reference": false,
45+
"eof-before-tag-name": false,
46+
"eof-in-cdata": false,
47+
"eof-in-comment": false,
48+
"eof-in-tag": false,
49+
"incorrectly-closed-comment": false,
50+
"incorrectly-opened-comment": false,
51+
"invalid-first-character-of-tag-name": false,
52+
"missing-attribute-value": false,
53+
"missing-end-tag-name": false,
54+
"missing-semicolon-after-character-reference": false,
55+
"missing-whitespace-between-attributes": false,
56+
"nested-comment": false,
57+
"noncharacter-character-reference": false,
58+
"noncharacter-in-input-stream": false,
59+
"null-character-reference": false,
60+
"surrogate-character-reference": false,
61+
"surrogate-in-input-stream": false,
62+
"unexpected-character-in-attribute-name": false,
63+
"unexpected-character-in-unquoted-attribute-value": false,
64+
"unexpected-equals-sign-before-attribute-name": false,
65+
"unexpected-null-character": false,
66+
"unexpected-question-mark-instead-of-tag-name": false,
67+
"unexpected-solidus-in-tag": false,
68+
"unknown-named-character-reference": false,
69+
"end-tag-with-attributes": false,
70+
"duplicate-attribute": false,
71+
"end-tag-with-trailing-solidus": false,
72+
"non-void-html-element-start-tag-with-trailing-solidus": false,
73+
"x-invalid-end-tag": false,
74+
"x-invalid-namespace": false
75+
}]
76+
}
77+
```
78+
79+
You can enable HTML syntax errors by opt-in.
80+
81+
For example, if `"x-invalid-end-tag": true` is given then this rule will catch the end tags of elements which have not opened.
82+
The error codes are defined in [WHATWG spec](https://html.spec.whatwg.org/multipage/parsing.html#parse-errors), but this rule does not support all of those (E.g., it does not catch errors about DOCTYPE).
83+
Also, The codes which have `x-` prefix are original in this rule because errors in tree construction phase have not codified yet.
84+
85+
- `x-invalid-end-tag` enables the errors about the end tags of elements which have not opened.
86+
- `x-invalid-namespace` enables the errors about invalid `xmlns` attributes. See also [step 10. of "create an element for a token"](https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token).
87+
88+
> TODO(mysticatea): I will revisit errors in tree construction phase after those are codified.

docs/rules/no-reservered-keys.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Prevent overwrite reserved keys (no-reservered-keys)
2+
3+
This rule prevents to use reserved names from to avoid conflicts and unexpected behavior.
4+
5+
## Rule Details
6+
7+
:-1: Examples of **incorrect** code for this rule:
8+
9+
```js
10+
export default {
11+
props: {
12+
$el: String
13+
},
14+
computed: {
15+
$on: {
16+
get () {
17+
}
18+
}
19+
},
20+
data: {
21+
_foo: null
22+
},
23+
methods: {
24+
$nextTick () {
25+
}
26+
}
27+
}
28+
```
29+
30+
## :wrench: Options
31+
32+
This rule has an object option:
33+
34+
`"reserved"`: [] (default) array of dissalowed names inside `groups`.
35+
36+
`"groups"`: [] (default) array of additional groups to search for duplicates.
37+
38+
### Example:
39+
40+
```
41+
vue/no-dupe-keys: [2, {
42+
reserved: ['foo']
43+
}]
44+
```
45+
46+
:-1: Examples of **incorrect** code for this configuration
47+
48+
```js
49+
export default {
50+
computed: {
51+
foo () {}
52+
}
53+
}
54+
```

0 commit comments

Comments
 (0)