Skip to content

Commit 539b34b

Browse files
authored
Merge pull request #22 from vuejs/dev
Update master branch
2 parents a3ffb66 + b018309 commit 539b34b

File tree

97 files changed

+7868
-59
lines changed

Some content is hidden

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

97 files changed

+7868
-59
lines changed

Diff for: .eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
lib/recommended-rules.js

Diff for: .eslintrc.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
root: true,
3+
parserOptions: {
4+
ecmaVersion: 6
5+
},
6+
env: {
7+
node: true,
8+
mocha: true
9+
},
10+
extends: [
11+
'plugin:eslint-plugin/recommended',
12+
'plugin:vue-libs/recommended'
13+
],
14+
plugins: [
15+
'eslint-plugin'
16+
],
17+
rules: {
18+
'eslint-plugin/report-message-format': ['error', '^[A-Z].*\\.$'],
19+
'eslint-plugin/prefer-placeholders': 'error',
20+
'eslint-plugin/consistent-output': 'error'
21+
}
22+
}

Diff for: .gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

Diff for: .gitignore

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
node_modules
2-
.DS_Store
1+
/.nyc_output
2+
/coverage
3+
/node_modules
4+
/test.*

Diff for: LICENSE

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
The MIT License (MIT)
1+
MIT License
22

3-
Copyright (c) 2016 Evan You
3+
Copyright (c) 2017 Toru Nagashima
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
99
copies of the Software, and to permit persons to whom the Software is
1010
furnished to do so, subject to the following conditions:
1111

12-
The above copyright notice and this permission notice shall be included in
13-
all copies or substantial portions of the Software.
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
1414

1515
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1616
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1717
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
THE SOFTWARE.
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Diff for: README.md

+128-24
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,138 @@
11
# eslint-plugin-vue
22

3-
ESLint plugin for Vue.js projects
3+
[![NPM version](https://img.shields.io/npm/v/eslint-plugin-vue.svg?style=flat)](https://npmjs.org/package/eslint-plugin-vue)
4+
[![NPM downloads](https://img.shields.io/npm/dm/eslint-plugin-vue.svg?style=flat)](https://npmjs.org/package/eslint-plugin-vue)
5+
[![CircleCI](https://circleci.com/gh/vuejs/eslint-plugin-vue.svg?style=svg)](https://circleci.com/gh/vuejs/eslint-plugin-vue)
46

5-
## Usage
7+
> Official ESLint plugin for Vue.js
68
7-
1. `npm install --save-dev eslint-plugin-vue`
8-
2. create a file named `.eslintrc` in your project:
9+
## :exclamation: Attention - this is documentation for beta `3.0.0` :exclamation:
10+
11+
This branch contains `eslint-plugin-vue@beta` which is pre-released `3.0`, but it's not the default version that you get with `npm install eslint-plugin-vue`. In order to install this you need to specify either `"eslint-plugin-vue": "beta"` in `package.json` or do `npm install eslint-plugin-vue@beta`.
12+
13+
Please try it and report any issues that you might experience.
14+
15+
If you want to check previous releases [go here](https://github.com/vuejs/eslint-plugin-vue/releases).
16+
17+
## :grey_exclamation: Requirements
18+
19+
- [ESLint](http://eslint.org/) `>=3.18.0`.
20+
- Node.js `>=4.0.0`
21+
22+
## :cd: Installation
923

10-
```js
11-
{
12-
extends: [ /* your usual extends */ ],
13-
 plugins: ["vue"],
14-
rules: {
15-
   'vue/jsx-uses-vars': 2,
16-
},
17-
}
1824
```
19-
3. OPTIONAL: install [eslint-config-vue](https://github.com/vuejs/eslint-config-vue): `npm install --save-dev eslint-config-vue`
20-
4. OPTIONAL: then use the recommended configurations in your `.eslintrc`:
21-
22-
```js
23-
{
24-
 extends: ["vue", /* your other extends */],
25-
 plugins: ["vue"],
26-
 rules: {
27-
   /* your overrides -- vue/jsx-uses-vars is included in eslint-config-vue */
28-
 },
25+
npm install --save-dev eslint eslint-plugin-vue@beta
26+
```
27+
28+
## :rocket: Usage
29+
30+
Create `.eslintrc.*` file to configure rules. See also: [http://eslint.org/docs/user-guide/configuring](http://eslint.org/docs/user-guide/configuring).
31+
32+
Example **.eslintrc.js**:
33+
34+
```javascript
35+
module.exports = {
36+
extends: [
37+
'eslint:recommended',
38+
'plugin:vue/recommended' // or 'plugin:vue/base'
39+
],
40+
rules: {
41+
// override/add rules' settings here
42+
'vue/no-invalid-v-if': 'error'
43+
}
2944
}
3045
```
3146

32-
## License
47+
## ⚙ Configs
48+
49+
This plugin provides two predefined configs:
50+
- `plugin:vue/base` - contains necessary settings for this plugin to work properly
51+
- `plugin:vue/recommended` - extends base config with recommended rules (the ones with check mark :white_check_mark: in the table below)
52+
53+
## :bulb: Rules
54+
55+
Rules are grouped by category to help you understand their purpose.
56+
57+
No rules are enabled by `plugin:vue/base` config. The `plugin:vue/recommended` config enables rules that report common problems, which have a check mark :white_check_mark: below.
58+
59+
The `--fix` option on the command line automatically fixes problems reported by rules which have a wrench :wrench: below.
60+
61+
<!--RULES_TABLE_START-->
62+
63+
### Best Practices
64+
65+
| | Rule ID | Description |
66+
|:---|:--------|:------------|
67+
| :wrench: | [html-end-tags](./docs/rules/html-end-tags.md) | enforce end tag style. |
68+
| :white_check_mark::wrench: | [html-no-self-closing](./docs/rules/html-no-self-closing.md) | disallow self-closing elements. |
69+
| :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+
| :white_check_mark: | [no-textarea-mustache](./docs/rules/no-textarea-mustache.md) | disallow mustaches in `<textarea>`. |
72+
| :white_check_mark: | [require-component-is](./docs/rules/require-component-is.md) | require `v-bind:is` of `<component>` elements. |
73+
| :white_check_mark: | [require-v-for-key](./docs/rules/require-v-for-key.md) | require `v-bind:key` with `v-for` directives. |
74+
75+
76+
### Stylistic Issues
77+
78+
| | Rule ID | Description |
79+
|:---|:--------|:------------|
80+
| | [html-quotes](./docs/rules/html-quotes.md) | enforce quotes style of HTML attributes. |
81+
| :wrench: | [v-bind-style](./docs/rules/v-bind-style.md) | enforce v-bind directive style. |
82+
| :wrench: | [v-on-style](./docs/rules/v-on-style.md) | enforce v-on directive style. |
83+
84+
85+
### Variables
86+
87+
| | Rule ID | Description |
88+
|:---|:--------|:------------|
89+
| :white_check_mark: | [jsx-uses-vars](./docs/rules/jsx-uses-vars.md) | Prevent variables used in JSX to be marked as unused |
90+
91+
92+
### Possible Errors
93+
94+
| | Rule ID | Description |
95+
|:---|:--------|:------------|
96+
| :white_check_mark: | [no-invalid-template-root](./docs/rules/no-invalid-template-root.md) | disallow invalid template root. |
97+
| :white_check_mark: | [no-invalid-v-bind](./docs/rules/no-invalid-v-bind.md) | disallow invalid v-bind directives. |
98+
| :white_check_mark: | [no-invalid-v-cloak](./docs/rules/no-invalid-v-cloak.md) | disallow invalid v-cloak directives. |
99+
| :white_check_mark: | [no-invalid-v-else-if](./docs/rules/no-invalid-v-else-if.md) | disallow invalid v-else-if directives. |
100+
| :white_check_mark: | [no-invalid-v-else](./docs/rules/no-invalid-v-else.md) | disallow invalid v-else directives. |
101+
| :white_check_mark: | [no-invalid-v-for](./docs/rules/no-invalid-v-for.md) | disallow invalid v-for directives. |
102+
| :white_check_mark: | [no-invalid-v-html](./docs/rules/no-invalid-v-html.md) | disallow invalid v-html directives. |
103+
| :white_check_mark: | [no-invalid-v-if](./docs/rules/no-invalid-v-if.md) | disallow invalid v-if directives. |
104+
| :white_check_mark: | [no-invalid-v-model](./docs/rules/no-invalid-v-model.md) | disallow invalid v-model directives. |
105+
| :white_check_mark: | [no-invalid-v-on](./docs/rules/no-invalid-v-on.md) | disallow invalid v-on directives. |
106+
| :white_check_mark: | [no-invalid-v-once](./docs/rules/no-invalid-v-once.md) | disallow invalid v-once directives. |
107+
| :white_check_mark: | [no-invalid-v-pre](./docs/rules/no-invalid-v-pre.md) | disallow invalid v-pre directives. |
108+
| :white_check_mark: | [no-invalid-v-show](./docs/rules/no-invalid-v-show.md) | disallow invalid v-show directives. |
109+
| :white_check_mark: | [no-invalid-v-text](./docs/rules/no-invalid-v-text.md) | disallow invalid v-text directives. |
110+
| :white_check_mark: | [no-parsing-error](./docs/rules/no-parsing-error.md) | disallow parsing errors in `<template>`. |
111+
112+
<!--RULES_TABLE_END-->
113+
114+
## :anchor: Semantic Versioning Policy
115+
116+
This plugin follows [semantic versioning](http://semver.org/) and [ESLint's Semantic Versioning Policy](https://github.com/eslint/eslint#semantic-versioning-policy).
117+
118+
## :newspaper: Changelog
119+
120+
We're using [GitHub Releases](https://github.com/vuejs/eslint-plugin-vue/releases).
121+
122+
## :beers: Contribution guide
123+
124+
In order to add a new rule, you should:
125+
- Create issue on GH with description of proposed rule
126+
- Generate a new rule using the [official yeoman generator](https://github.com/eslint/generator-eslint)
127+
- Run `npm start`
128+
- Write test scenarios & implement logic
129+
- Describe the rule in the generated `docs` file
130+
- Make sure all tests are passing
131+
- Run `npm run update` in order to update readme and recommended configuration
132+
- Create PR and link created issue in description
133+
134+
We're more than happy to see potential contributions, so don't hesitate. If you have any suggestions, ideas or problems feel free to add new [issue](https://github.com/vuejs/eslint-plugin-vue/issues), but first please make sure your question does not repeat previous ones.
135+
136+
## :lock: License
33137

34-
[MIT](http://opensource.org/licenses/MIT)
138+
See the [LICENSE](LICENSE) file for license rights and limitations (MIT).

Diff for: circle.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
machine:
2+
node:
3+
version: 4
4+
5+
dependencies:
6+
pre:
7+
- nvm install 7
8+
- nvm install 8
9+
10+
test:
11+
override:
12+
- npm test
13+
- nvm use 6 && npm test
14+
- nvm use 7 && npm test
15+
- nvm use 8 && npm test

Diff for: docs/rules/html-end-tags.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Enforce end tag style (html-end-tags)
2+
3+
- 🔧 This rule is fixable with `eslint --fix` command.
4+
5+
This rule enforce the way of end tags.
6+
7+
- [Void elements] disallow end tags.
8+
- Other elements require end tags.
9+
10+
## 📖 Rule Details
11+
12+
This rule reports the following elements:
13+
14+
- [Void elements] which have end tags.
15+
- Other elements which do not have end tags and are not self-closing.
16+
17+
👎 Examples of **incorrect** code for this rule:
18+
19+
```html
20+
<template>
21+
<div>
22+
<div>
23+
<p>
24+
<p>
25+
<input></input>
26+
<br></br>
27+
</div>
28+
</template>
29+
```
30+
31+
👍 Examples of **correct** code for this rule:
32+
33+
```html
34+
<template>
35+
<div>
36+
<div></div>
37+
<p></p>
38+
<p></p>
39+
<input>
40+
<br>
41+
</div>
42+
</template>
43+
```
44+
45+
## 🔧 Options
46+
47+
Nothing.
48+
49+
[Void elements]: https://www.w3.org/TR/html51/syntax.html#void-elements
50+
51+
## TODO: `<br></br>`
52+
53+
`parse5` does not recognize the illegal end tags of void elements.

Diff for: docs/rules/html-no-self-closing.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Disallow self-closing elements (html-no-self-closing)
2+
3+
- 🔧 This rule is fixable with `eslint --fix` command.
4+
5+
Self-closing (e.g. `<br/>`) is syntax of XML/XHTML.
6+
HTML ignores it.
7+
8+
## 📖 Rule Details
9+
10+
This rule reports every self-closing element except XML context.
11+
12+
👎 Examples of **incorrect** code for this rule:
13+
14+
```html
15+
<template>
16+
<div>
17+
<img src="./logo.png"/>
18+
</div>
19+
</template>
20+
```
21+
22+
👍 Examples of **correct** code for this rule:
23+
24+
```html
25+
<template>
26+
<div>
27+
<img src="./logo.png">
28+
<svg>
29+
<!-- this is XML context -->
30+
<rect width="100" height="100" />
31+
</svg>
32+
</div>
33+
</template>
34+
```
35+
36+
## 🔧 Options
37+
38+
Nothing.

Diff for: docs/rules/html-quotes.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Enforce quotes style of HTML attributes (html-quotes)
2+
3+
You can shoose quotes of HTML attributes from:
4+
5+
- Double quotes: `<div class="foo">`
6+
- Single quotes: `<div class='foo'>`
7+
- No quotes: `<div class=foo>`
8+
9+
This rule enforces the quotes style of HTML attributes.
10+
11+
## 📖 Rule Details
12+
13+
This rule reports the quotes of attributes if it is different to configured quotes.
14+
15+
👎 Examples of **incorrect** code for this rule:
16+
17+
```html
18+
<template>
19+
<div>
20+
<img src='./logo.png'>
21+
<img src=./logo.png>
22+
</div>
23+
</template>
24+
```
25+
26+
👍 Examples of **correct** code for this rule:
27+
28+
```html
29+
<template>
30+
<div>
31+
<img src="./logo.png">
32+
</div>
33+
</template>
34+
```
35+
36+
👎 Examples of **incorrect** code for this rule with `"single"` option:
37+
38+
```html
39+
<template>
40+
<div>
41+
<img src="./logo.png">
42+
<img src=./logo.png>
43+
</div>
44+
</template>
45+
```
46+
47+
👍 Examples of **correct** code for this rule with `"single"` option:
48+
49+
```html
50+
<template>
51+
<div>
52+
<img src='./logo.png'>
53+
</div>
54+
</template>
55+
```
56+
57+
## 🔧 Options
58+
59+
- `"double"` (default) ... requires double quotes.
60+
- `"single"` ... requires single quotes.

0 commit comments

Comments
 (0)