-
-
Notifications
You must be signed in to change notification settings - Fork 679
Simplify configuration #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
1d13f40
Simplify config
michalsnik f1961e3
Move config to separate folder, simplify rules' resolver
michalsnik 75961db
Remove unused packages
michalsnik 26f282e
Update config
michalsnik db9c67d
Change travis to circleCI
michalsnik 9c2d146
CircleCI - Install Node 7
michalsnik c9daf2d
Update rules update script
michalsnik 4ecb8d2
Fix configuration, update generator
michalsnik a8c1dad
Add jsx-uses-vars rule
michalsnik e4976f9
Update README
e6eaf52
Use eslint-plugin-vue-libs recommended config
michalsnik 40614ca
Change eslintrc format
michalsnik ac6a4fd
Add node 8 to list of test environments
michalsnik 8366692
Use .eslintrc.js, add eslint 4 to peer dependencies, add lockfile
michalsnik 57b0c6f
Do not recommend rules that currently have slight problems due to par…
michalsnik 760a8a1
Add es6 to env
michalsnik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
lib/recommended-rules.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"root": true, | ||
"parserOptions": { | ||
"ecmaVersion": 6, | ||
}, | ||
"env": { | ||
"node": true, | ||
"mocha": true, | ||
}, | ||
extends: [ | ||
"plugin:eslint-plugin/recommended", | ||
"plugin:vue-libs/recommended", | ||
], | ||
"plugins": [ | ||
"eslint-plugin", | ||
], | ||
"rules": { | ||
"complexity": "off", | ||
"eslint-plugin/report-message-format": ["error", "^[A-Z].*\\.$"], | ||
"eslint-plugin/prefer-placeholders": "error", | ||
"eslint-plugin/consistent-output": "error", | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,126 +1,130 @@ | ||
# eslint-plugin-vue | ||
|
||
[](https://npmjs.org/package/eslint-plugin-vue) | ||
[](https://npmjs.org/package/eslint-plugin-vue) | ||
[](https://circleci.com/gh/vuejs/eslint-plugin-vue) | ||
|
||
> Official ESLint plugin for Vue.js | ||
|
||
## 💿 Installation | ||
## :exclamation: Requirements | ||
|
||
- [ESLint](http://eslint.org/) `>=3.18.0`. | ||
- Node.js `>=4.0.0` | ||
|
||
Use [npm](https://www.npmjs.com/). | ||
## :cd: Installation | ||
|
||
``` | ||
> npm install --save-dev eslint eslint-plugin-vue | ||
npm install --save-dev eslint eslint-plugin-vue | ||
``` | ||
|
||
- Requires Node.js `^4.0.0 || >=6.0.0` | ||
- Requires ESLint `>=3.18.0` | ||
|
||
## 📖 Usage | ||
## :rocket: Usage | ||
|
||
Write `.eslintrc.*` file to configure rules. See also: http://eslint.org/docs/user-guide/configuring | ||
Create `.eslintrc.*` file to configure rules. See also: [http://eslint.org/docs/user-guide/configuring](http://eslint.org/docs/user-guide/configuring). | ||
|
||
**.eslintrc.json** (An example) | ||
Example **.eslintrc.js**: | ||
|
||
```json | ||
{ | ||
"plugins": ["vue"], | ||
"extends": ["eslint:recommended", "plugin:vue/recommended"], | ||
"rules": { | ||
"vue/html-quotes": ["error", "double"], | ||
"vue/v-bind-style": ["error", "shorthand"], | ||
"vue/v-on-style": ["error", "shorthand"] | ||
} | ||
```javascript | ||
module.exports = { | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:vue/recommended' // or 'plugin:vue/base' | ||
], | ||
rules: { | ||
// override/add rules' settings here | ||
'vue/no-invalid-v-if': 'error' | ||
} | ||
} | ||
``` | ||
|
||
## 💡 Rules | ||
## ⚙ Configs | ||
|
||
- ⭐️ the mark of a recommended rule. | ||
- ✒️ the mark of a fixable rule. | ||
This plugin provides two predefined configs: | ||
- `plugin:vue/base` - contains necessary settings for this plugin to work properly | ||
- `plugin:vue/recommended` - extends base config with recommended rules (the ones with check mark :white_check_mark: in the table below) | ||
|
||
<!--RULES_TABLE_START--> | ||
### Possible Errors | ||
## :bulb: Rules | ||
|
||
| | Rule ID | Description | | ||
|:---|:--------|:------------| | ||
| ⭐️ | [no-invalid-template-root](./docs/rules/no-invalid-template-root.md) | disallow invalid template root. | | ||
| ⭐️ | [no-invalid-v-bind](./docs/rules/no-invalid-v-bind.md) | disallow invalid v-bind directives. | | ||
| ⭐️ | [no-invalid-v-cloak](./docs/rules/no-invalid-v-cloak.md) | disallow invalid v-cloak directives. | | ||
| ⭐️ | [no-invalid-v-else-if](./docs/rules/no-invalid-v-else-if.md) | disallow invalid v-else-if directives. | | ||
| ⭐️ | [no-invalid-v-else](./docs/rules/no-invalid-v-else.md) | disallow invalid v-else directives. | | ||
| ⭐️ | [no-invalid-v-for](./docs/rules/no-invalid-v-for.md) | disallow invalid v-for directives. | | ||
| ⭐️ | [no-invalid-v-html](./docs/rules/no-invalid-v-html.md) | disallow invalid v-html directives. | | ||
| ⭐️ | [no-invalid-v-if](./docs/rules/no-invalid-v-if.md) | disallow invalid v-if directives. | | ||
| ⭐️ | [no-invalid-v-model](./docs/rules/no-invalid-v-model.md) | disallow invalid v-model directives. | | ||
| ⭐️ | [no-invalid-v-on](./docs/rules/no-invalid-v-on.md) | disallow invalid v-on directives. | | ||
| ⭐️ | [no-invalid-v-once](./docs/rules/no-invalid-v-once.md) | disallow invalid v-once directives. | | ||
| ⭐️ | [no-invalid-v-pre](./docs/rules/no-invalid-v-pre.md) | disallow invalid v-pre directives. | | ||
| ⭐️ | [no-invalid-v-show](./docs/rules/no-invalid-v-show.md) | disallow invalid v-show directives. | | ||
| ⭐️ | [no-invalid-v-text](./docs/rules/no-invalid-v-text.md) | disallow invalid v-text directives. | | ||
| ⭐️ | [no-parsing-error](./docs/rules/no-parsing-error.md) | disallow parsing errors in `<template>`. | | ||
Rules are grouped by category to help you understand their purpose. | ||
|
||
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. | ||
|
||
The `--fix` option on the command line automatically fixes problems reported by rules which have a wrench :wrench: below. | ||
|
||
<!--RULES_TABLE_START--> | ||
|
||
### Best Practices | ||
|
||
| | Rule ID | Description | | ||
|:---|:--------|:------------| | ||
| ⭐️✒️ | [html-end-tags](./docs/rules/html-end-tags.md) | enforce end tag style. | | ||
| ⭐️✒️ | [html-no-self-closing](./docs/rules/html-no-self-closing.md) | disallow self-closing elements. | | ||
| ⭐️ | [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. | | ||
| ⭐️ | [no-duplicate-attributes](./docs/rules/no-duplicate-attributes.md) | disallow duplicate arguments. | | ||
| ⭐️ | [no-textarea-mustache](./docs/rules/no-textarea-mustache.md) | disallow mustaches in `<textarea>`. | | ||
| ⭐️ | [require-component-is](./docs/rules/require-component-is.md) | require `v-bind:is` of `<component>` elements. | | ||
| ⭐️ | [require-v-for-key](./docs/rules/require-v-for-key.md) | require `v-bind:key` with `v-for` directives. | | ||
| :white_check_mark::wrench: | [html-end-tags](./docs/rules/html-end-tags.md) | enforce end tag style. | | ||
| :white_check_mark::wrench: | [html-no-self-closing](./docs/rules/html-no-self-closing.md) | disallow self-closing elements. | | ||
| :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. | | ||
| :white_check_mark: | [no-duplicate-attributes](./docs/rules/no-duplicate-attributes.md) | disallow duplicate arguments. | | ||
| :white_check_mark: | [no-textarea-mustache](./docs/rules/no-textarea-mustache.md) | disallow mustaches in `<textarea>`. | | ||
| :white_check_mark: | [require-component-is](./docs/rules/require-component-is.md) | require `v-bind:is` of `<component>` elements. | | ||
| :white_check_mark: | [require-v-for-key](./docs/rules/require-v-for-key.md) | require `v-bind:key` with `v-for` directives. | | ||
|
||
|
||
### Stylistic Issues | ||
|
||
| | Rule ID | Description | | ||
|:---|:--------|:------------| | ||
| | [html-quotes](./docs/rules/html-quotes.md) | enforce quotes style of HTML attributes. | | ||
| ✒️ | [v-bind-style](./docs/rules/v-bind-style.md) | enforce v-bind directive style. | | ||
| ✒️ | [v-on-style](./docs/rules/v-on-style.md) | enforce v-on directive style. | | ||
| :wrench: | [v-bind-style](./docs/rules/v-bind-style.md) | enforce v-bind directive style. | | ||
| :wrench: | [v-on-style](./docs/rules/v-on-style.md) | enforce v-on directive style. | | ||
|
||
<!--RULES_TABLE_END--> | ||
|
||
## ⚙ Configs | ||
### Variables | ||
|
||
This plugin provides `plugin:vue/recommended` preset config. | ||
This preset config: | ||
| | Rule ID | Description | | ||
|:---|:--------|:------------| | ||
| :white_check_mark: | [jsx-uses-vars](./docs/rules/jsx-uses-vars.md) | Prevent variables used in JSX to be marked as unused | | ||
|
||
- adds `parser: "vue-eslint-parser"` | ||
- enables rules which are given ⭐️ in the above table. | ||
|
||
## ⚓️ Semantic Versioning Policy | ||
### Possible Errors | ||
|
||
| | Rule ID | Description | | ||
|:---|:--------|:------------| | ||
| :white_check_mark: | [no-invalid-template-root](./docs/rules/no-invalid-template-root.md) | disallow invalid template root. | | ||
| :white_check_mark: | [no-invalid-v-bind](./docs/rules/no-invalid-v-bind.md) | disallow invalid v-bind directives. | | ||
| :white_check_mark: | [no-invalid-v-cloak](./docs/rules/no-invalid-v-cloak.md) | disallow invalid v-cloak directives. | | ||
| :white_check_mark: | [no-invalid-v-else-if](./docs/rules/no-invalid-v-else-if.md) | disallow invalid v-else-if directives. | | ||
| :white_check_mark: | [no-invalid-v-else](./docs/rules/no-invalid-v-else.md) | disallow invalid v-else directives. | | ||
| :white_check_mark: | [no-invalid-v-for](./docs/rules/no-invalid-v-for.md) | disallow invalid v-for directives. | | ||
| :white_check_mark: | [no-invalid-v-html](./docs/rules/no-invalid-v-html.md) | disallow invalid v-html directives. | | ||
| :white_check_mark: | [no-invalid-v-if](./docs/rules/no-invalid-v-if.md) | disallow invalid v-if directives. | | ||
| :white_check_mark: | [no-invalid-v-model](./docs/rules/no-invalid-v-model.md) | disallow invalid v-model directives. | | ||
| :white_check_mark: | [no-invalid-v-on](./docs/rules/no-invalid-v-on.md) | disallow invalid v-on directives. | | ||
| :white_check_mark: | [no-invalid-v-once](./docs/rules/no-invalid-v-once.md) | disallow invalid v-once directives. | | ||
| :white_check_mark: | [no-invalid-v-pre](./docs/rules/no-invalid-v-pre.md) | disallow invalid v-pre directives. | | ||
| :white_check_mark: | [no-invalid-v-show](./docs/rules/no-invalid-v-show.md) | disallow invalid v-show directives. | | ||
| :white_check_mark: | [no-invalid-v-text](./docs/rules/no-invalid-v-text.md) | disallow invalid v-text directives. | | ||
| :white_check_mark: | [no-parsing-error](./docs/rules/no-parsing-error.md) | disallow parsing errors in `<template>`. | | ||
|
||
<!--RULES_TABLE_END--> | ||
|
||
`eslint-plugin-vue` follows [semantic versioning](http://semver.org/) and [ESLint's Semantic Versioning Policy](https://github.com/eslint/eslint#semantic-versioning-policy). | ||
## :anchor: Semantic Versioning Policy | ||
|
||
- Patch release (intended to not break your lint build) | ||
- A bug fix in a rule that results in it reporting fewer errors. | ||
- Improvements to documentation. | ||
- Non-user-facing changes such as refactoring code, adding, deleting, or modifying tests, and increasing test coverage. | ||
- Re-releasing after a failed release (i.e., publishing a release that doesn't work for anyone). | ||
- Minor release (might break your lint build) | ||
- A bug fix in a rule that results in it reporting more errors. | ||
- A new rule is created. | ||
- A new option to an existing rule is created. | ||
- An existing rule is deprecated. | ||
- Major release (likely to break your lint build) | ||
- A support for old Node version is dropped. | ||
- A support for old ESLint version is dropped. | ||
- An existing rule is changed in it reporting more errors. | ||
- An existing rule is removed. | ||
- An existing option of a rule is removed. | ||
- An existing config is updated. | ||
This plugin follows [semantic versioning](http://semver.org/) and [ESLint's Semantic Versioning Policy](https://github.com/eslint/eslint#semantic-versioning-policy). | ||
|
||
## 📰 Changelog | ||
## :newspaper: Changelog | ||
|
||
- [GitHub Releases](https://github.com/vuejs/eslint-plugin-vue/releases) | ||
We're using [GitHub Releases](https://github.com/vuejs/eslint-plugin-vue/releases). | ||
|
||
## 💎 Contributing | ||
## :beers: Contribution guide | ||
|
||
Welcome contributing! | ||
In order to add a new rule, you should: | ||
- Create issue on GH with description of proposed rule | ||
- Generate a new rule using the [official yeoman generator](https://github.com/eslint/generator-eslint) | ||
- Run `npm start` | ||
- Write test scenarios & implement logic | ||
- Describe the rule in the generated `docs` file | ||
- Make sure all tests are passing | ||
- Run `npm run update` in order to update readme and recommended configuration | ||
- Create PR and link created issue in description | ||
|
||
Please use GitHub's Issues/PRs. | ||
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. | ||
|
||
### Development Tools | ||
## :lock: License | ||
|
||
- `npm test` runs tests and measures coverage. | ||
- `npm run coverage` shows the coverage result of `npm test` command. | ||
- `npm run clean` removes the coverage result of `npm test` command. | ||
See the [LICENSE](LICENSE) file for license rights and limitations (MIT). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
machine: | ||
node: | ||
version: 4 | ||
|
||
dependencies: | ||
pre: | ||
- nvm install 7 | ||
- nvm install 8 | ||
|
||
test: | ||
override: | ||
- npm test | ||
- nvm use 6 && npm test | ||
- nvm use 7 && npm test | ||
- nvm use 8 && npm test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = { | ||
root: true, | ||
|
||
parser: 'vue-eslint-parser', | ||
|
||
parserOptions: { | ||
ecmaVersion: 6, | ||
sourceType: 'module', | ||
ecmaFeatures: { | ||
jsx: true | ||
} | ||
}, | ||
|
||
env: { | ||
browser: true | ||
}, | ||
|
||
plugins: [ | ||
'vue' | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
extends: require.resolve('./base.js'), | ||
rules: require('../lib/recommended-rules.js') | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Prevent variables used in JSX to be marked as unused (jsx-uses-vars) | ||
|
||
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)). | ||
This rule will find variables used in JSX and mark them as used. | ||
|
||
This rule only has an effect when the `no-unused-vars` rule is enabled. | ||
|
||
## Rule Details | ||
|
||
Without this rule this code triggers warning: | ||
|
||
```js | ||
import Hello from './Hello'; | ||
|
||
export default { | ||
render () { | ||
return ( | ||
<Hello msg="world"></Hello> | ||
) | ||
}, | ||
}; | ||
``` | ||
|
||
After turning on, `Hello` is being marked as used and `no-unused-vars` rule doesn't report an issue. | ||
|
||
## When Not To Use It | ||
|
||
If you are not using JSX or if you do not use the `no-unused-vars` rule then you can disable this rule. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict' | ||
|
||
const resolve = require('path').resolve | ||
const requireIndex = require('requireindex') | ||
|
||
const rules = requireIndex(resolve(__dirname, 'lib/rules')) | ||
const configs = requireIndex(resolve(__dirname, 'config')) | ||
|
||
module.exports = { | ||
rules, | ||
configs | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think good if we use 8 instead of 7.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add 8 additionally. These tests run pretty fast and we'll be sure it's actually bulletproof.