|
1 | 1 | # eslint-plugin-vue
|
2 | 2 |
|
3 |
| -ESLint plugin for Vue.js projects |
| 3 | +> Official ESLint plugin for Vue.js |
4 | 4 |
|
5 |
| -## Usage |
| 5 | +## 💿 Installation |
6 | 6 |
|
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/). |
9 | 8 |
|
10 |
| -```js |
11 |
| -{ |
12 |
| - extends: [ /* your usual extends */ ], |
13 |
| - plugins: ["vue"], |
14 |
| - rules: { |
15 |
| - 'vue/jsx-uses-vars': 2, |
16 |
| - }, |
17 |
| -} |
18 | 9 | ```
|
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) |
21 | 21 |
|
22 |
| -```js |
| 22 | +```json |
23 | 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 |
| - }, |
| 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 | + } |
29 | 31 | }
|
30 | 32 | ```
|
31 | 33 |
|
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 |
33 | 123 |
|
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. |
0 commit comments