Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 047b229

Browse files
Simplify configuration (#17)
* Simplify config * Move config to separate folder, simplify rules' resolver * Remove unused packages * Update config * Change travis to circleCI * CircleCI - Install Node 7 * Update rules update script * Fix configuration, update generator * Add jsx-uses-vars rule * Update README * Use eslint-plugin-vue-libs recommended config * Change eslintrc format * Add node 8 to list of test environments * Use .eslintrc.js, add eslint 4 to peer dependencies, add lockfile * Do not recommend rules that currently have slight problems due to parser issues * Add es6 to env
1 parent 09765b0 commit 047b229

Some content is hidden

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

70 files changed

+5378
-3153
lines changed

‎.eslintignore

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

‎.eslintrc.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
'complexity': 'off',
19+
'eslint-plugin/report-message-format': ['error', '^[A-Z].*\\.$'],
20+
'eslint-plugin/prefer-placeholders': 'error',
21+
'eslint-plugin/consistent-output': 'error'
22+
}
23+
}

‎.eslintrc.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

‎.travis.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎README.md

Lines changed: 87 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,130 @@
11
# eslint-plugin-vue
22

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)
6+
37
> Official ESLint plugin for Vue.js
48
5-
## 💿 Installation
9+
## :exclamation: Requirements
10+
11+
- [ESLint](http://eslint.org/) `>=3.18.0`.
12+
- Node.js `>=4.0.0`
613

7-
Use [npm](https://www.npmjs.com/).
14+
## :cd: Installation
815

916
```
10-
> npm install --save-dev eslint eslint-plugin-vue
17+
npm install --save-dev eslint eslint-plugin-vue
1118
```
1219

13-
- Requires Node.js `^4.0.0 || >=6.0.0`
14-
- Requires ESLint `>=3.18.0`
15-
16-
## 📖 Usage
20+
## :rocket: Usage
1721

18-
Write `.eslintrc.*` file to configure rules. See also: http://eslint.org/docs/user-guide/configuring
22+
Create `.eslintrc.*` file to configure rules. See also: [http://eslint.org/docs/user-guide/configuring](http://eslint.org/docs/user-guide/configuring).
1923

20-
**.eslintrc.json** (An example)
24+
Example **.eslintrc.js**:
2125

22-
```json
23-
{
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-
}
26+
```javascript
27+
module.exports = {
28+
extends: [
29+
'eslint:recommended',
30+
'plugin:vue/recommended' // or 'plugin:vue/base'
31+
],
32+
rules: {
33+
// override/add rules' settings here
34+
'vue/no-invalid-v-if': 'error'
35+
}
3136
}
3237
```
3338

34-
## 💡 Rules
39+
## ⚙ Configs
3540

36-
- ⭐️ the mark of a recommended rule.
37-
- ✒️ the mark of a fixable rule.
41+
This plugin provides two predefined configs:
42+
- `plugin:vue/base` - contains necessary settings for this plugin to work properly
43+
- `plugin:vue/recommended` - extends base config with recommended rules (the ones with check mark :white_check_mark: in the table below)
3844

39-
<!--RULES_TABLE_START-->
40-
### Possible Errors
45+
## :bulb: Rules
4146

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>`. |
47+
Rules are grouped by category to help you understand their purpose.
48+
49+
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.
50+
51+
The `--fix` option on the command line automatically fixes problems reported by rules which have a wrench :wrench: below.
52+
53+
<!--RULES_TABLE_START-->
5954

6055
### Best Practices
6156

6257
| | Rule ID | Description |
6358
|:---|:--------|:------------|
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. |
59+
| :wrench: | [html-end-tags](./docs/rules/html-end-tags.md) | enforce end tag style. |
60+
| :white_check_mark::wrench: | [html-no-self-closing](./docs/rules/html-no-self-closing.md) | disallow self-closing elements. |
61+
| :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. |
62+
| | [no-duplicate-attributes](./docs/rules/no-duplicate-attributes.md) | disallow duplicate arguments. |
63+
| :white_check_mark: | [no-textarea-mustache](./docs/rules/no-textarea-mustache.md) | disallow mustaches in `<textarea>`. |
64+
| :white_check_mark: | [require-component-is](./docs/rules/require-component-is.md) | require `v-bind:is` of `<component>` elements. |
65+
| :white_check_mark: | [require-v-for-key](./docs/rules/require-v-for-key.md) | require `v-bind:key` with `v-for` directives. |
66+
7167

7268
### Stylistic Issues
7369

7470
| | Rule ID | Description |
7571
|:---|:--------|:------------|
7672
| | [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. |
73+
| :wrench: | [v-bind-style](./docs/rules/v-bind-style.md) | enforce v-bind directive style. |
74+
| :wrench: | [v-on-style](./docs/rules/v-on-style.md) | enforce v-on directive style. |
7975

80-
<!--RULES_TABLE_END-->
8176

82-
##⚙ Configs
77+
### Variables
8378

84-
This plugin provides `plugin:vue/recommended` preset config.
85-
This preset config:
79+
| | Rule ID | Description |
80+
|:---|:--------|:------------|
81+
| :white_check_mark: | [jsx-uses-vars](./docs/rules/jsx-uses-vars.md) | Prevent variables used in JSX to be marked as unused |
8682

87-
- adds `parser: "vue-eslint-parser"`
88-
- enables rules which are given ⭐️ in the above table.
8983

90-
## ⚓️ Semantic Versioning Policy
84+
### Possible Errors
85+
86+
| | Rule ID | Description |
87+
|:---|:--------|:------------|
88+
| :white_check_mark: | [no-invalid-template-root](./docs/rules/no-invalid-template-root.md) | disallow invalid template root. |
89+
| :white_check_mark: | [no-invalid-v-bind](./docs/rules/no-invalid-v-bind.md) | disallow invalid v-bind directives. |
90+
| :white_check_mark: | [no-invalid-v-cloak](./docs/rules/no-invalid-v-cloak.md) | disallow invalid v-cloak directives. |
91+
| :white_check_mark: | [no-invalid-v-else-if](./docs/rules/no-invalid-v-else-if.md) | disallow invalid v-else-if directives. |
92+
| :white_check_mark: | [no-invalid-v-else](./docs/rules/no-invalid-v-else.md) | disallow invalid v-else directives. |
93+
| :white_check_mark: | [no-invalid-v-for](./docs/rules/no-invalid-v-for.md) | disallow invalid v-for directives. |
94+
| :white_check_mark: | [no-invalid-v-html](./docs/rules/no-invalid-v-html.md) | disallow invalid v-html directives. |
95+
| :white_check_mark: | [no-invalid-v-if](./docs/rules/no-invalid-v-if.md) | disallow invalid v-if directives. |
96+
| :white_check_mark: | [no-invalid-v-model](./docs/rules/no-invalid-v-model.md) | disallow invalid v-model directives. |
97+
| :white_check_mark: | [no-invalid-v-on](./docs/rules/no-invalid-v-on.md) | disallow invalid v-on directives. |
98+
| :white_check_mark: | [no-invalid-v-once](./docs/rules/no-invalid-v-once.md) | disallow invalid v-once directives. |
99+
| :white_check_mark: | [no-invalid-v-pre](./docs/rules/no-invalid-v-pre.md) | disallow invalid v-pre directives. |
100+
| :white_check_mark: | [no-invalid-v-show](./docs/rules/no-invalid-v-show.md) | disallow invalid v-show directives. |
101+
| :white_check_mark: | [no-invalid-v-text](./docs/rules/no-invalid-v-text.md) | disallow invalid v-text directives. |
102+
| :white_check_mark: | [no-parsing-error](./docs/rules/no-parsing-error.md) | disallow parsing errors in `<template>`. |
103+
104+
<!--RULES_TABLE_END-->
91105

92-
`eslint-plugin-vue` follows [semantic versioning](http://semver.org/) and [ESLint's Semantic Versioning Policy](https://github.com/eslint/eslint#semantic-versioning-policy).
106+
## :anchor:Semantic Versioning Policy
93107

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.
108+
This plugin follows [semantic versioning](http://semver.org/) and [ESLint's Semantic Versioning Policy](https://github.com/eslint/eslint#semantic-versioning-policy).
111109

112-
## 📰 Changelog
110+
## :newspaper: Changelog
113111

114-
-[GitHub Releases](https://github.com/vuejs/eslint-plugin-vue/releases)
112+
We're using [GitHub Releases](https://github.com/vuejs/eslint-plugin-vue/releases).
115113

116-
## 💎 Contributing
114+
## :beers: Contribution guide
117115

118-
Welcome contributing!
116+
In order to add a new rule, you should:
117+
- Create issue on GH with description of proposed rule
118+
- Generate a new rule using the [official yeoman generator](https://github.com/eslint/generator-eslint)
119+
- Run `npm start`
120+
- Write test scenarios & implement logic
121+
- Describe the rule in the generated `docs` file
122+
- Make sure all tests are passing
123+
- Run `npm run update` in order to update readme and recommended configuration
124+
- Create PR and link created issue in description
119125

120-
Please use GitHub's Issues/PRs.
126+
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.
121127

122-
### Development Tools
128+
##:lock: License
123129

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.
130+
See the [LICENSE](LICENSE) file for license rights and limitations (MIT).

‎circle.yml

Lines changed: 15 additions & 0 deletions
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

‎config/base.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
root: true,
3+
4+
parser: 'vue-eslint-parser',
5+
6+
parserOptions: {
7+
ecmaVersion: 6,
8+
sourceType: 'module',
9+
ecmaFeatures: {
10+
jsx: true
11+
}
12+
},
13+
14+
env: {
15+
browser: true,
16+
es6: true
17+
},
18+
19+
plugins: [
20+
'vue'
21+
]
22+
}

‎config/recommended.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
extends: require.resolve('./base.js'),
3+
rules: require('../lib/recommended-rules.js')
4+
}

‎docs/rules/jsx-uses-vars.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Prevent variables used in JSX to be marked as unused (jsx-uses-vars)
2+
3+
Since 0.17.0 the ESLint `no-unused-vars` rule does not detect variables used in JSX ([see details](http://eslint.org/blog/2015/03/eslint-0.17.0-released#changes-to-jsxreact-handling)).
4+
This rule will find variables used in JSX and mark them as used.
5+
6+
This rule only has an effect when the `no-unused-vars` rule is enabled.
7+
8+
## Rule Details
9+
10+
Without this rule this code triggers warning:
11+
12+
```js
13+
import Hello from './Hello';
14+
15+
export default {
16+
render () {
17+
return (
18+
<Hello msg="world"></Hello>
19+
)
20+
},
21+
};
22+
```
23+
24+
After turning on, `Hello` is being marked as used and `no-unused-vars` rule doesn't report an issue.
25+
26+
## When Not To Use It
27+
28+
If you are not using JSX or if you do not use the `no-unused-vars` rule then you can disable this rule.

‎index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict'
2+
3+
const resolve = require('path').resolve
4+
const requireIndex = require('requireindex')
5+
6+
const rules = requireIndex(resolve(__dirname, 'lib/rules'))
7+
const configs = requireIndex(resolve(__dirname, 'config'))
8+
9+
module.exports = {
10+
rules,
11+
configs
12+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /