Skip to content

Commit 09765b0

Browse files
committed
Merge eslint-plugin-vue-trial
1 parent a3ffb66 commit 09765b0

File tree

91 files changed

+5641
-63
lines changed

Some content is hidden

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

91 files changed

+5641
-63
lines changed

.eslintrc.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"root": true,
3+
"extends": [
4+
"mysticatea",
5+
"mysticatea/node",
6+
"plugin:eslint-plugin/recommended"
7+
],
8+
"plugins": [
9+
"eslint-plugin"
10+
],
11+
"rules": {
12+
"complexity": "off",
13+
"eslint-plugin/report-message-format": ["error", "^[A-Z].*\\.$"],
14+
"eslint-plugin/prefer-placeholders": "error",
15+
"eslint-plugin/consistent-output": "error"
16+
}
17+
}

.gitattributes

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

.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.*

.travis.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
sudo: false
2+
language: node_js
3+
node_js:
4+
- "4"
5+
- "6"
6+
- "7"
7+
before_install:
8+
- if [[ `npm --version` == 2* ]]; then npm install -g npm@3; fi
9+
after_success:
10+
- npm run codecov

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.

README.md

+114-22
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,126 @@
11
# eslint-plugin-vue
22

3-
ESLint plugin for Vue.js projects
3+
> Official ESLint plugin for Vue.js
44
5-
## Usage
5+
## 💿 Installation
66

7-
1. `npm install --save-dev eslint-plugin-vue`
8-
2. create a file named `.eslintrc` in your project:
7+
Use [npm](https://www.npmjs.com/).
98

10-
```js
11-
{
12-
extends: [ /* your usual extends */ ],
13-
 plugins: ["vue"],
14-
rules: {
15-
   'vue/jsx-uses-vars': 2,
16-
},
17-
}
189
```
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`:
10+
> npm install --save-dev eslint eslint-plugin-vue
11+
```
12+
13+
- Requires Node.js `^4.0.0 || >=6.0.0`
14+
- Requires ESLint `>=3.18.0`
15+
16+
## 📖 Usage
17+
18+
Write `.eslintrc.*` file to configure rules. See also: http://eslint.org/docs/user-guide/configuring
19+
20+
**.eslintrc.json** (An example)
2121

22-
```js
22+
```json
2323
{
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-
 },
24+
"plugins": ["vue"],
25+
"extends": ["eslint:recommended", "plugin:vue/recommended"],
26+
"rules": {
27+
"vue/html-quotes": ["error", "double"],
28+
"vue/v-bind-style": ["error", "shorthand"],
29+
"vue/v-on-style": ["error", "shorthand"]
30+
}
2931
}
3032
```
3133

32-
## License
34+
## 💡 Rules
35+
36+
- ⭐️ the mark of a recommended rule.
37+
- ✒️ the mark of a fixable rule.
38+
39+
<!--RULES_TABLE_START-->
40+
### Possible Errors
41+
42+
| | Rule ID | Description |
43+
|:---|:--------|:------------|
44+
| ⭐️ | [no-invalid-template-root](./docs/rules/no-invalid-template-root.md) | disallow invalid template root. |
45+
| ⭐️ | [no-invalid-v-bind](./docs/rules/no-invalid-v-bind.md) | disallow invalid v-bind directives. |
46+
| ⭐️ | [no-invalid-v-cloak](./docs/rules/no-invalid-v-cloak.md) | disallow invalid v-cloak directives. |
47+
| ⭐️ | [no-invalid-v-else-if](./docs/rules/no-invalid-v-else-if.md) | disallow invalid v-else-if directives. |
48+
| ⭐️ | [no-invalid-v-else](./docs/rules/no-invalid-v-else.md) | disallow invalid v-else directives. |
49+
| ⭐️ | [no-invalid-v-for](./docs/rules/no-invalid-v-for.md) | disallow invalid v-for directives. |
50+
| ⭐️ | [no-invalid-v-html](./docs/rules/no-invalid-v-html.md) | disallow invalid v-html directives. |
51+
| ⭐️ | [no-invalid-v-if](./docs/rules/no-invalid-v-if.md) | disallow invalid v-if directives. |
52+
| ⭐️ | [no-invalid-v-model](./docs/rules/no-invalid-v-model.md) | disallow invalid v-model directives. |
53+
| ⭐️ | [no-invalid-v-on](./docs/rules/no-invalid-v-on.md) | disallow invalid v-on directives. |
54+
| ⭐️ | [no-invalid-v-once](./docs/rules/no-invalid-v-once.md) | disallow invalid v-once directives. |
55+
| ⭐️ | [no-invalid-v-pre](./docs/rules/no-invalid-v-pre.md) | disallow invalid v-pre directives. |
56+
| ⭐️ | [no-invalid-v-show](./docs/rules/no-invalid-v-show.md) | disallow invalid v-show directives. |
57+
| ⭐️ | [no-invalid-v-text](./docs/rules/no-invalid-v-text.md) | disallow invalid v-text directives. |
58+
| ⭐️ | [no-parsing-error](./docs/rules/no-parsing-error.md) | disallow parsing errors in `<template>`. |
59+
60+
### Best Practices
61+
62+
| | Rule ID | Description |
63+
|:---|:--------|:------------|
64+
| ⭐️✒️ | [html-end-tags](./docs/rules/html-end-tags.md) | enforce end tag style. |
65+
| ⭐️✒️ | [html-no-self-closing](./docs/rules/html-no-self-closing.md) | disallow self-closing elements. |
66+
| ⭐️ | [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. |
67+
| ⭐️ | [no-duplicate-attributes](./docs/rules/no-duplicate-attributes.md) | disallow duplicate arguments. |
68+
| ⭐️ | [no-textarea-mustache](./docs/rules/no-textarea-mustache.md) | disallow mustaches in `<textarea>`. |
69+
| ⭐️ | [require-component-is](./docs/rules/require-component-is.md) | require `v-bind:is` of `<component>` elements. |
70+
| ⭐️ | [require-v-for-key](./docs/rules/require-v-for-key.md) | require `v-bind:key` with `v-for` directives. |
71+
72+
### Stylistic Issues
73+
74+
| | Rule ID | Description |
75+
|:---|:--------|:------------|
76+
| | [html-quotes](./docs/rules/html-quotes.md) | enforce quotes style of HTML attributes. |
77+
| ✒️ | [v-bind-style](./docs/rules/v-bind-style.md) | enforce v-bind directive style. |
78+
| ✒️ | [v-on-style](./docs/rules/v-on-style.md) | enforce v-on directive style. |
79+
80+
<!--RULES_TABLE_END-->
81+
82+
## ⚙ Configs
83+
84+
This plugin provides `plugin:vue/recommended` preset config.
85+
This preset config:
86+
87+
- adds `parser: "vue-eslint-parser"`
88+
- enables rules which are given ⭐️ in the above table.
89+
90+
## ⚓️ Semantic Versioning Policy
91+
92+
`eslint-plugin-vue` follows [semantic versioning](http://semver.org/) and [ESLint's Semantic Versioning Policy](https://github.com/eslint/eslint#semantic-versioning-policy).
93+
94+
- Patch release (intended to not break your lint build)
95+
- A bug fix in a rule that results in it reporting fewer errors.
96+
- Improvements to documentation.
97+
- Non-user-facing changes such as refactoring code, adding, deleting, or modifying tests, and increasing test coverage.
98+
- Re-releasing after a failed release (i.e., publishing a release that doesn't work for anyone).
99+
- Minor release (might break your lint build)
100+
- A bug fix in a rule that results in it reporting more errors.
101+
- A new rule is created.
102+
- A new option to an existing rule is created.
103+
- An existing rule is deprecated.
104+
- Major release (likely to break your lint build)
105+
- A support for old Node version is dropped.
106+
- A support for old ESLint version is dropped.
107+
- An existing rule is changed in it reporting more errors.
108+
- An existing rule is removed.
109+
- An existing option of a rule is removed.
110+
- An existing config is updated.
111+
112+
## 📰 Changelog
113+
114+
- [GitHub Releases](https://github.com/vuejs/eslint-plugin-vue/releases)
115+
116+
## 💎 Contributing
117+
118+
Welcome contributing!
119+
120+
Please use GitHub's Issues/PRs.
121+
122+
### Development Tools
33123

34-
[MIT](http://opensource.org/licenses/MIT)
124+
- `npm test` runs tests and measures coverage.
125+
- `npm run coverage` shows the coverage result of `npm test` command.
126+
- `npm run clean` removes the coverage result of `npm test` command.

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.

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.

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)