|
1 | 1 | # eslint-plugin-vue
|
2 | 2 |
|
| 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) |
| 6 | + |
3 | 7 | > Official ESLint plugin for Vue.js
|
4 | 8 |
|
5 |
| -## 💿 Installation |
| 9 | +## :exclamation: Requirements |
| 10 | + |
| 11 | +- [ESLint](http://eslint.org/) `>=3.18.0`. |
| 12 | +- Node.js `>=4.0.0` |
6 | 13 |
|
7 |
| -Use [npm](https://www.npmjs.com/). |
| 14 | +## :cd: Installation |
8 | 15 |
|
9 | 16 | ```
|
10 |
| -> npm install --save-dev eslint eslint-plugin-vue |
| 17 | +npm install --save-dev eslint eslint-plugin-vue |
11 | 18 | ```
|
12 | 19 |
|
13 |
| -- Requires Node.js `^4.0.0 || >=6.0.0` |
14 |
| -- Requires ESLint `>=3.18.0` |
15 |
| - |
16 |
| -## 📖 Usage |
| 20 | +## :rocket: Usage |
17 | 21 |
|
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). |
19 | 23 |
|
20 |
| -**.eslintrc.json** (An example) |
| 24 | +Example **.eslintrc.js**: |
21 | 25 |
|
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 | + } |
31 | 36 | }
|
32 | 37 | ```
|
33 | 38 |
|
34 |
| -## 💡 Rules |
| 39 | +## ⚙ Configs |
35 | 40 |
|
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) |
38 | 44 |
|
39 |
| -<!--RULES_TABLE_START--> |
40 |
| -### Possible Errors |
| 45 | +## :bulb: Rules |
41 | 46 |
|
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--> |
59 | 54 |
|
60 | 55 | ### Best Practices
|
61 | 56 |
|
62 | 57 | | | Rule ID | Description |
|
63 | 58 | |:---|:--------|:------------|
|
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 | + |
71 | 67 |
|
72 | 68 | ### Stylistic Issues
|
73 | 69 |
|
74 | 70 | | | Rule ID | Description |
|
75 | 71 | |:---|:--------|:------------|
|
76 | 72 | | | [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. | |
79 | 75 |
|
80 |
| -<!--RULES_TABLE_END--> |
81 | 76 |
|
82 |
| -## ⚙ Configs |
| 77 | +### Variables |
83 | 78 |
|
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 | |
86 | 82 |
|
87 |
| -- adds `parser: "vue-eslint-parser"` |
88 |
| -- enables rules which are given ⭐️ in the above table. |
89 | 83 |
|
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--> |
91 | 105 |
|
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 |
93 | 107 |
|
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). |
111 | 109 |
|
112 |
| -## 📰 Changelog |
| 110 | +## :newspaper: Changelog |
113 | 111 |
|
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). |
115 | 113 |
|
116 |
| -## 💎 Contributing |
| 114 | +## :beers: Contribution guide |
117 | 115 |
|
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 |
119 | 125 |
|
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. |
121 | 127 |
|
122 |
| -### Development Tools |
| 128 | +## :lock: License |
123 | 129 |
|
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). |
0 commit comments