|
1 | 1 | # eslint-plugin-vue
|
2 | 2 |
|
3 |
| -ESLint plugin for Vue.js projects |
| 3 | +[](https://npmjs.org/package/eslint-plugin-vue) |
| 4 | +[](https://npmjs.org/package/eslint-plugin-vue) |
| 5 | +[](https://circleci.com/gh/vuejs/eslint-plugin-vue) |
4 | 6 |
|
5 |
| -## Usage |
| 7 | +> Official ESLint plugin for Vue.js |
6 | 8 |
|
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 |
9 | 23 |
|
10 |
| -```js |
11 |
| -{ |
12 |
| - extends: [ /* your usual extends */ ], |
13 |
| - plugins: ["vue"], |
14 |
| - rules: { |
15 |
| - 'vue/jsx-uses-vars': 2, |
16 |
| - }, |
17 |
| -} |
18 | 24 | ```
|
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 | + } |
29 | 44 | }
|
30 | 45 | ```
|
31 | 46 |
|
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 |
33 | 137 |
|
34 |
| -[MIT](http://opensource.org/licenses/MIT) |
| 138 | +See the [LICENSE](LICENSE) file for license rights and limitations (MIT). |
0 commit comments