Skip to content

Commit 6653d54

Browse files
committed
Merge remote-tracking branch 'origin/master' into issue46
2 parents da2aeb0 + 3ed8c5c commit 6653d54

File tree

80 files changed

+2258
-174
lines changed

Some content is hidden

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

80 files changed

+2258
-174
lines changed

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ The `--fix` option on the command line automatically fixes problems reported by
9494
|:---|:--------|:------------|
9595
| | [no-dupe-keys](./docs/rules/no-dupe-keys.md) | Prevents duplication of field names. |
9696
| :white_check_mark: | [no-parsing-error](./docs/rules/no-parsing-error.md) | disallow parsing errors in `<template>`. |
97-
| | [no-reservered-keys](./docs/rules/no-reservered-keys.md) | Prevent overwrite reserved keys. |
97+
| | [no-reserved-keys](./docs/rules/no-reserved-keys.md) | Prevent overwrite reserved keys. |
9898
| | [no-shared-component-data](./docs/rules/no-shared-component-data.md) | Enforces component's data property to be a function. |
9999
| | [no-template-key](./docs/rules/no-template-key.md) | disallow `key` attribute on `<template>`. |
100100
| | [require-render-return](./docs/rules/require-render-return.md) | Enforces render function to always return value. |
@@ -128,8 +128,10 @@ The `--fix` option on the command line automatically fixes problems reported by
128128
| :white_check_mark: | [no-textarea-mustache](./docs/rules/no-textarea-mustache.md) | disallow mustaches in `<textarea>`. |
129129
| | [order-in-components](./docs/rules/order-in-components.md) | Keep order of properties in components |
130130
| :white_check_mark: | [require-component-is](./docs/rules/require-component-is.md) | require `v-bind:is` of `<component>` elements. |
131+
| | [require-default-prop](./docs/rules/require-default-prop.md) | Require default value for props |
131132
| | [require-prop-types](./docs/rules/require-prop-types.md) | Prop definitions should be detailed |
132133
| :white_check_mark: | [require-v-for-key](./docs/rules/require-v-for-key.md) | require `v-bind:key` with `v-for` directives. |
134+
| | [this-in-template](./docs/rules/this-in-template.md) | enforce usage of `this` in template. |
133135

134136

135137
### Stylistic Issues
@@ -139,7 +141,10 @@ The `--fix` option on the command line automatically fixes problems reported by
139141
| :wrench: | [attribute-hyphenation](./docs/rules/attribute-hyphenation.md) | Define a style for the props casing in templates. |
140142
| | [html-quotes](./docs/rules/html-quotes.md) | enforce quotes style of HTML attributes. |
141143
| :wrench: | [html-self-closing](./docs/rules/html-self-closing.md) | enforce self-closing style. |
144+
| | [max-attributes-per-line](./docs/rules/max-attributes-per-line.md) | Define the number of attributes allows per line |
145+
| :wrench: | [mustache-interpolation-spacing](./docs/rules/mustache-interpolation-spacing.md) | enforce unified spacing in mustache interpolations. |
142146
| :wrench: | [name-property-casing](./docs/rules/name-property-casing.md) | Requires specific casing for the name property in Vue components |
147+
| :wrench: | [no-multi-spaces](./docs/rules/no-multi-spaces.md) | This rule warns about the usage of extra whitespaces between attributes |
143148
| :wrench: | [v-bind-style](./docs/rules/v-bind-style.md) | enforce `v-bind` directive style. |
144149
| :wrench: | [v-on-style](./docs/rules/v-on-style.md) | enforce `v-on` directive style. |
145150

@@ -172,6 +177,7 @@ The `--fix` option on the command line automatically fixes problems reported by
172177
| [no-invalid-v-pre](./rules/no-invalid-v-pre.md) | [valid-v-pre](./rules/valid-v-pre.md) |
173178
| [no-invalid-v-show](./rules/no-invalid-v-show.md) | [valid-v-show](./rules/valid-v-show.md) |
174179
| [no-invalid-v-text](./rules/no-invalid-v-text.md) | [valid-v-text](./rules/valid-v-text.md) |
180+
| [no-reservered-keys](./rules/no-reservered-keys.md) | [no-reserved-keys](./rules/no-reserved-keys.md) |
175181

176182
<!--RULES_TABLE_END-->
177183

circle.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ machine:
44

55
dependencies:
66
pre:
7-
- nvm install 7
7+
- nvm install 6
88
- nvm install 8
99

1010
test:
1111
override:
12-
- npm test
12+
- nvm use 4 && npm test
1313
- nvm use 6 && npm test
14-
- nvm use 7 && npm test
1514
- nvm use 8 && npm test
15+
- nvm use 8 && npm i [email protected] --no-save && npm run -s test:base

docs/rules/max-attributes-per-line.md

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Define the number of attributes allows per line (max-attributes-per-line)
2+
3+
Limits the maximum number of attributes/properties per line to improve readability.
4+
5+
6+
## :book: Rule Details
7+
8+
This rule aims to enforce a number of attributes per line in templates.
9+
It checks all the elements in a template and verifies that the number of attributes per line does not exceed the defined maximum.
10+
An attribute is considered to be in a new line when there is a line break between two attributes.
11+
12+
There is a configurable number of attributes that are acceptable in one-line case (default 3), as well as how many attributes are acceptable per line in multi-line case (default 1).
13+
14+
:-1: Examples of **incorrect** code for this rule:
15+
16+
```html
17+
<component lorem="1" ipsum="2" dolor="3" sit="4">
18+
</component>
19+
20+
<component
21+
lorem="1" ipsum="2"
22+
dolor="3"
23+
sit="4"
24+
>
25+
</component>
26+
```
27+
28+
:+1: Examples of **correct** code for this rule:
29+
30+
```html
31+
<component lorem="1" ipsum="2" dolor="3">
32+
</component>
33+
34+
<component
35+
lorem="1"
36+
ipsum="2"
37+
dolor="3"
38+
sit="4"
39+
>
40+
</component>
41+
42+
```
43+
44+
### :wrench: Options
45+
46+
```
47+
{
48+
"vue/max-attributes-per-line": [{
49+
"singleline": 3,
50+
"multiline": {
51+
max: 1,
52+
allowFirstLine: false
53+
}
54+
}]
55+
}
56+
```
57+
58+
#### `allowFirstLine`
59+
For multi-line declarations, defines if allows attributes to be put in the first line. (Default false)
60+
61+
:-1: Example of **incorrect** code for this setting:
62+
```html
63+
// [{ "multiline": { "allowFirstLine": false }}]
64+
<component foo="John" bar="Smith"
65+
foobar={5555555}>
66+
</component>;
67+
```
68+
69+
:+1: Example of **correct** code for this setting:
70+
```html
71+
// [{ "multiline": { "allowFirstLine": false }}]
72+
<component
73+
foo="John"
74+
bar="Smith"
75+
foobar={5555555}
76+
>
77+
</component>;
78+
```
79+
80+
81+
#### `singleline`
82+
Number of maximum attributes per line when the opening tag is in a single line. (Default is 3)
83+
84+
:-1: Example of **incorrect** code for this setting:
85+
```html
86+
// [{"singleline": 2,}]
87+
<component foo="John" bar="Smith" foobar={5555555}></component>;
88+
```
89+
90+
:+1: Example of **correct** code for this setting:
91+
```html
92+
// [{"singleline": 3,}]
93+
<component foo="John" bar="Smith" foobar={5555555}></component>;
94+
```
95+
96+
97+
#### `multiline`
98+
Number of maximum attributes per line when a tag is in multiple lines. (Default is 1)
99+
100+
:-1: Example of **incorrect** code for this setting:
101+
```html
102+
// [{"multiline": 1}]
103+
<component foo="John" bar="Smith"
104+
foobar={5555555}>
105+
</component>;
106+
```
107+
108+
:+1: Example of **correct** code for this setting:
109+
```html
110+
// [{"multiline": 1}]
111+
<component
112+
foo="John"
113+
bar="Smith"
114+
foobar={5555555}
115+
>
116+
</component>;
117+
```
118+
119+
## When Not To Use It
120+
121+
If you do not want to check the number of attributes declared per line you can disable this rule.
122+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# enforce unified spacing in mustache interpolations. (mustache-interpolation-spacing)
2+
3+
- :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.
4+
5+
## :book: Rule Details
6+
7+
This rule aims to enforce unified spacing in mustache interpolations.
8+
9+
:-1: Examples of **incorrect** code for this rule:
10+
11+
```html
12+
<template>
13+
<div>{{ text }}</div>
14+
</template>
15+
```
16+
17+
:+1: Examples of **correct** code for this rule:
18+
19+
```html
20+
<template>
21+
<div>{{ text }}</div>
22+
</template>
23+
```
24+
25+
## :wrench: Options
26+
27+
Default spacing is set to `always`
28+
29+
```
30+
'vue/mustache-interpolation-spacing': [2, 'always'|'never']
31+
```
32+
33+
### `"always"` - Expect one space between expression and curly brackets.
34+
35+
:+1: Examples of **correct** code`:
36+
37+
```html
38+
<template>
39+
<div>{{ text }}</div>
40+
</template>
41+
```
42+
43+
:-1: Examples of **incorrect** code`:
44+
45+
```html
46+
<template>
47+
<div>{{text}}</div>
48+
</template>
49+
```
50+
51+
### `"never"` - Expect no spaces between expression and curly brackets.
52+
53+
:+1: Examples of **correct** code`:
54+
55+
```html
56+
<template>
57+
<div>{{text}}</div>
58+
</template>
59+
```
60+
61+
:-1: Examples of **incorrect** code`:
62+
63+
```html
64+
<template>
65+
<div>{{ text }}</div>
66+
</template>
67+
```

docs/rules/no-multi-spaces.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This rule warns about the usage of extra whitespaces between attributes (no-multi-spaces)
2+
3+
The `--fix` option on the command line can automatically fix some of the problems reported by this rule.
4+
5+
This rule aims to remove multiple spaces in a row between attributes witch are not used for indentation.
6+
7+
## Rule Details
8+
9+
Examples of **incorrect** code for this rule:
10+
11+
```html
12+
<template>
13+
<div class="foo" :style="foo"
14+
:foo="bar" >
15+
</div>
16+
</template>
17+
```
18+
19+
Examples of **correct** code for this rule:
20+
21+
```html
22+
<template>
23+
<div class="foo"
24+
:style="foo">
25+
</div>
26+
</template>
27+
```
28+
29+
### Options
30+
31+
Nothing

docs/rules/no-reserved-keys.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Prevent overwrite reserved keys (no-reserved-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-reserved-keys: [2, {
42+
reserved: ['foo', 'foo2'],
43+
groups: ['asyncComputed']
44+
}]
45+
```
46+
47+
:-1: Examples of **incorrect** code for this configuration
48+
49+
```js
50+
export default {
51+
asyncComputed: {
52+
foo2 () {}
53+
},
54+
computed: {
55+
foo () {}
56+
}
57+
}
58+
```

docs/rules/require-default-prop.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Require default value for props (require-default-prop)
2+
3+
This rule requires default value to be set for each props that are not marked as `required`.
4+
5+
## Rule Details
6+
7+
Examples of **incorrect** code for this rule:
8+
9+
```js
10+
export default {
11+
props: {
12+
a: Number,
13+
b: [Number, String],
14+
c: {
15+
type: Number
16+
},
17+
d: {
18+
type: Number,
19+
required: false
20+
}
21+
}
22+
}
23+
```
24+
25+
Examples of **correct** code for this rule:
26+
27+
```js
28+
export default {
29+
props: {
30+
a: {
31+
type: Number,
32+
required: true
33+
},
34+
b: {
35+
type: Number,
36+
default: 0
37+
},
38+
c: {
39+
type: Number,
40+
default: 0,
41+
required: false
42+
}
43+
}
44+
}
45+
```

docs/rules/require-render-return.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Enforces render function to always return value (require-render-return)
22

3-
This rule aims to enforce render function to allways return value
3+
This rule aims to enforce render function to always return value
44

55
## :book: Rule Details
66

0 commit comments

Comments
 (0)