From 09765b07536049dca5eb0ee84586693b93d87172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sajn=C3=B3g?= Date: Fri, 2 Jun 2017 19:44:22 +0200 Subject: [PATCH 01/10] Merge eslint-plugin-vue-trial --- .eslintrc.json | 17 ++ .gitattributes | 1 + .gitignore | 6 +- .travis.yml | 10 + LICENSE | 12 +- README.md | 136 +++++++++-- docs/rules/html-end-tags.md | 53 +++++ docs/rules/html-no-self-closing.md | 38 +++ docs/rules/html-quotes.md | 60 +++++ docs/rules/no-confusing-v-for-v-if.md | 53 +++++ docs/rules/no-duplicate-attributes.md | 35 +++ docs/rules/no-invalid-template-root.md | 59 +++++ docs/rules/no-invalid-v-bind.md | 50 ++++ docs/rules/no-invalid-v-cloak.md | 37 +++ docs/rules/no-invalid-v-else-if.md | 53 +++++ docs/rules/no-invalid-v-else.md | 49 ++++ docs/rules/no-invalid-v-for.md | 60 +++++ docs/rules/no-invalid-v-html.md | 46 ++++ docs/rules/no-invalid-v-if.md | 55 +++++ docs/rules/no-invalid-v-model.md | 62 +++++ docs/rules/no-invalid-v-on.md | 48 ++++ docs/rules/no-invalid-v-once.md | 37 +++ docs/rules/no-invalid-v-pre.md | 37 +++ docs/rules/no-invalid-v-show.md | 46 ++++ docs/rules/no-invalid-v-text.md | 46 ++++ docs/rules/no-parsing-error.md | 28 +++ docs/rules/no-textarea-mustache.md | 29 +++ docs/rules/require-component-is.md | 29 +++ docs/rules/require-v-for-key.md | 41 ++++ docs/rules/v-bind-style.md | 52 +++++ docs/rules/v-on-style.md | 52 +++++ index.js | 13 -- lib/index.js | 11 + lib/recommended.json | 33 +++ lib/rules.js | 34 +++ lib/rules/html-end-tags.js | 70 ++++++ lib/rules/html-no-self-closing.js | 57 +++++ lib/rules/html-quotes.js | 65 ++++++ lib/rules/no-confusing-v-for-v-if.js | 70 ++++++ lib/rules/no-duplicate-attributes.js | 82 +++++++ lib/rules/no-invalid-template-root.js | 130 +++++++++++ lib/rules/no-invalid-v-bind.js | 68 ++++++ lib/rules/no-invalid-v-cloak.js | 69 ++++++ lib/rules/no-invalid-v-else-if.js | 90 ++++++++ lib/rules/no-invalid-v-else.js | 90 ++++++++ lib/rules/no-invalid-v-for.js | 147 ++++++++++++ lib/rules/no-invalid-v-html.js | 69 ++++++ lib/rules/no-invalid-v-if.js | 83 +++++++ lib/rules/no-invalid-v-model.js | 182 +++++++++++++++ lib/rules/no-invalid-v-on.js | 78 +++++++ lib/rules/no-invalid-v-once.js | 69 ++++++ lib/rules/no-invalid-v-pre.js | 69 ++++++ lib/rules/no-invalid-v-show.js | 69 ++++++ lib/rules/no-invalid-v-text.js | 69 ++++++ lib/rules/no-parsing-error.js | 60 +++++ lib/rules/no-textarea-mustache.js | 57 +++++ lib/rules/require-component-is.js | 55 +++++ lib/rules/require-v-for-key.js | 55 +++++ lib/rules/v-bind-style.js | 66 ++++++ lib/rules/v-on-style.js | 67 ++++++ lib/utils/html-elements.json | 1 + lib/utils/index.js | 244 ++++++++++++++++++++ lib/utils/svg-elements.json | 1 + lib/utils/void-elements.json | 1 + package.json | 62 +++-- tests/lib/rules/html-end-tags.js | 80 +++++++ tests/lib/rules/html-no-self-closing.js | 63 +++++ tests/lib/rules/html-quotes.js | 146 ++++++++++++ tests/lib/rules/no-confusing-v-for-v-if.js | 59 +++++ tests/lib/rules/no-duplicate-attributes.js | 56 +++++ tests/lib/rules/no-invalid-template-root.js | 108 +++++++++ tests/lib/rules/no-invalid-v-bind.js | 92 ++++++++ tests/lib/rules/no-invalid-v-cloak.js | 52 +++++ tests/lib/rules/no-invalid-v-else-if.js | 96 ++++++++ tests/lib/rules/no-invalid-v-else.js | 96 ++++++++ tests/lib/rules/no-invalid-v-for.js | 149 ++++++++++++ tests/lib/rules/no-invalid-v-html.js | 52 +++++ tests/lib/rules/no-invalid-v-if.js | 62 +++++ tests/lib/rules/no-invalid-v-model.js | 118 ++++++++++ tests/lib/rules/no-invalid-v-on.js | 64 +++++ tests/lib/rules/no-invalid-v-once.js | 52 +++++ tests/lib/rules/no-invalid-v-pre.js | 52 +++++ tests/lib/rules/no-invalid-v-show.js | 52 +++++ tests/lib/rules/no-invalid-v-text.js | 52 +++++ tests/lib/rules/no-parsing-error.js | 86 +++++++ tests/lib/rules/no-textarea-mustache.js | 50 ++++ tests/lib/rules/require-component-is.js | 51 ++++ tests/lib/rules/require-v-for-key.js | 55 +++++ tests/lib/rules/v-bind-style.js | 71 ++++++ tests/lib/rules/v-on-style.js | 71 ++++++ tools/update-rules.js | 96 ++++++++ 91 files changed, 5641 insertions(+), 63 deletions(-) create mode 100644 .eslintrc.json create mode 100644 .gitattributes create mode 100644 .travis.yml create mode 100644 docs/rules/html-end-tags.md create mode 100644 docs/rules/html-no-self-closing.md create mode 100644 docs/rules/html-quotes.md create mode 100644 docs/rules/no-confusing-v-for-v-if.md create mode 100644 docs/rules/no-duplicate-attributes.md create mode 100644 docs/rules/no-invalid-template-root.md create mode 100644 docs/rules/no-invalid-v-bind.md create mode 100644 docs/rules/no-invalid-v-cloak.md create mode 100644 docs/rules/no-invalid-v-else-if.md create mode 100644 docs/rules/no-invalid-v-else.md create mode 100644 docs/rules/no-invalid-v-for.md create mode 100644 docs/rules/no-invalid-v-html.md create mode 100644 docs/rules/no-invalid-v-if.md create mode 100644 docs/rules/no-invalid-v-model.md create mode 100644 docs/rules/no-invalid-v-on.md create mode 100644 docs/rules/no-invalid-v-once.md create mode 100644 docs/rules/no-invalid-v-pre.md create mode 100644 docs/rules/no-invalid-v-show.md create mode 100644 docs/rules/no-invalid-v-text.md create mode 100644 docs/rules/no-parsing-error.md create mode 100644 docs/rules/no-textarea-mustache.md create mode 100644 docs/rules/require-component-is.md create mode 100644 docs/rules/require-v-for-key.md create mode 100644 docs/rules/v-bind-style.md create mode 100644 docs/rules/v-on-style.md delete mode 100644 index.js create mode 100644 lib/index.js create mode 100644 lib/recommended.json create mode 100644 lib/rules.js create mode 100644 lib/rules/html-end-tags.js create mode 100644 lib/rules/html-no-self-closing.js create mode 100644 lib/rules/html-quotes.js create mode 100644 lib/rules/no-confusing-v-for-v-if.js create mode 100644 lib/rules/no-duplicate-attributes.js create mode 100644 lib/rules/no-invalid-template-root.js create mode 100644 lib/rules/no-invalid-v-bind.js create mode 100644 lib/rules/no-invalid-v-cloak.js create mode 100644 lib/rules/no-invalid-v-else-if.js create mode 100644 lib/rules/no-invalid-v-else.js create mode 100644 lib/rules/no-invalid-v-for.js create mode 100644 lib/rules/no-invalid-v-html.js create mode 100644 lib/rules/no-invalid-v-if.js create mode 100644 lib/rules/no-invalid-v-model.js create mode 100644 lib/rules/no-invalid-v-on.js create mode 100644 lib/rules/no-invalid-v-once.js create mode 100644 lib/rules/no-invalid-v-pre.js create mode 100644 lib/rules/no-invalid-v-show.js create mode 100644 lib/rules/no-invalid-v-text.js create mode 100644 lib/rules/no-parsing-error.js create mode 100644 lib/rules/no-textarea-mustache.js create mode 100644 lib/rules/require-component-is.js create mode 100644 lib/rules/require-v-for-key.js create mode 100644 lib/rules/v-bind-style.js create mode 100644 lib/rules/v-on-style.js create mode 100644 lib/utils/html-elements.json create mode 100644 lib/utils/index.js create mode 100644 lib/utils/svg-elements.json create mode 100644 lib/utils/void-elements.json create mode 100644 tests/lib/rules/html-end-tags.js create mode 100644 tests/lib/rules/html-no-self-closing.js create mode 100644 tests/lib/rules/html-quotes.js create mode 100644 tests/lib/rules/no-confusing-v-for-v-if.js create mode 100644 tests/lib/rules/no-duplicate-attributes.js create mode 100644 tests/lib/rules/no-invalid-template-root.js create mode 100644 tests/lib/rules/no-invalid-v-bind.js create mode 100644 tests/lib/rules/no-invalid-v-cloak.js create mode 100644 tests/lib/rules/no-invalid-v-else-if.js create mode 100644 tests/lib/rules/no-invalid-v-else.js create mode 100644 tests/lib/rules/no-invalid-v-for.js create mode 100644 tests/lib/rules/no-invalid-v-html.js create mode 100644 tests/lib/rules/no-invalid-v-if.js create mode 100644 tests/lib/rules/no-invalid-v-model.js create mode 100644 tests/lib/rules/no-invalid-v-on.js create mode 100644 tests/lib/rules/no-invalid-v-once.js create mode 100644 tests/lib/rules/no-invalid-v-pre.js create mode 100644 tests/lib/rules/no-invalid-v-show.js create mode 100644 tests/lib/rules/no-invalid-v-text.js create mode 100644 tests/lib/rules/no-parsing-error.js create mode 100644 tests/lib/rules/no-textarea-mustache.js create mode 100644 tests/lib/rules/require-component-is.js create mode 100644 tests/lib/rules/require-v-for-key.js create mode 100644 tests/lib/rules/v-bind-style.js create mode 100644 tests/lib/rules/v-on-style.js create mode 100644 tools/update-rules.js diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 000000000..ef741a1a1 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,17 @@ +{ + "root": true, + "extends": [ + "mysticatea", + "mysticatea/node", + "plugin:eslint-plugin/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" + } +} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..6313b56c5 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/.gitignore b/.gitignore index fd4f2b066..0f23426ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ -node_modules -.DS_Store +/.nyc_output +/coverage +/node_modules +/test.* diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..97175d6db --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +sudo: false +language: node_js +node_js: + - "4" + - "6" + - "7" +before_install: + - if [[ `npm --version` == 2* ]]; then npm install -g npm@3; fi +after_success: + - npm run codecov diff --git a/LICENSE b/LICENSE index 32cc6c272..c914149a6 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ -The MIT License (MIT) +MIT License -Copyright (c) 2016 Evan You +Copyright (c) 2017 Toru Nagashima Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index f61d40bdb..f06a04430 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,126 @@ # eslint-plugin-vue -ESLint plugin for Vue.js projects +> Official ESLint plugin for Vue.js -## Usage +## πŸ’Ώ Installation -1. `npm install --save-dev eslint-plugin-vue` -2. create a file named `.eslintrc` in your project: +Use [npm](https://www.npmjs.com/). -```js -{ - extends: [ /* your usual extends */ ], - Β plugins: ["vue"], - rules: { - Β  Β 'vue/jsx-uses-vars': 2, - }, -} ``` -3. OPTIONAL: install [eslint-config-vue](https://github.com/vuejs/eslint-config-vue): `npm install --save-dev eslint-config-vue` -4. OPTIONAL: then use the recommended configurations in your `.eslintrc`: +> npm install --save-dev eslint eslint-plugin-vue +``` + +- Requires Node.js `^4.0.0 || >=6.0.0` +- Requires ESLint `>=3.18.0` + +## πŸ“– Usage + +Write `.eslintrc.*` file to configure rules. See also: http://eslint.org/docs/user-guide/configuring + +**.eslintrc.json** (An example) -```js +```json { - Β extends: ["vue", /* your other extends */], - Β plugins: ["vue"], - Β rules: { - Β  Β /* your overrides -- vue/jsx-uses-vars is included in eslint-config-vue */ - Β }, + "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"] + } } ``` -## License +## πŸ’‘ Rules + +- ⭐️ the mark of a recommended rule. +- βœ’οΈ the mark of a fixable rule. + + +### Possible Errors + +| | 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 ` +``` + +## πŸ”§ Options + +Nothing. + +## πŸ‘« Related rules + +- [no-parsing-error] + + +[no-parsing-error]: no-parsing-error.md diff --git a/docs/rules/no-invalid-v-on.md b/docs/rules/no-invalid-v-on.md new file mode 100644 index 000000000..38da1e6e6 --- /dev/null +++ b/docs/rules/no-invalid-v-on.md @@ -0,0 +1,48 @@ +# Disallow invalid v-on directives (no-invalid-v-on) + +This rule checks whether every `v-on` directive is valid. + +## πŸ“– Rule Details + +This rule reports `v-on` directives if the following cases: + +- The directive does not have that event name. E.g. `
` +- The directive has invalid modifiers. E.g. `
` +- The directive does not have that attribute value. E.g. `
` + +This rule does not check syntax errors in directives because it's checked by [no-parsing-error] rule. + +πŸ‘Ž Examples of **incorrect** code for this rule: + +```html + +``` + +πŸ‘ Examples of **correct** code for this rule: + +```html + +``` + +## πŸ”§ Options + +Nothing. + +## πŸ‘« Related rules + +- [no-parsing-error] + + +[no-parsing-error]: no-parsing-error.md diff --git a/docs/rules/no-invalid-v-once.md b/docs/rules/no-invalid-v-once.md new file mode 100644 index 000000000..8f5ab7b13 --- /dev/null +++ b/docs/rules/no-invalid-v-once.md @@ -0,0 +1,37 @@ +# Disallow invalid v-once directives (no-invalid-v-once) + +This rule checks whether every `v-once` directive is valid. + +## πŸ“– Rule Details + +This rule reports `v-once` directives if the following cases: + +- The directive has that argument. E.g. `
` +- The directive has that modifier. E.g. `
` +- The directive has that attribute value. E.g. `
` + +πŸ‘Ž Examples of **incorrect** code for this rule: + +```html + +``` + +πŸ‘ Examples of **correct** code for this rule: + +```html + +``` + +## πŸ”§ Options + +Nothing. diff --git a/docs/rules/no-invalid-v-pre.md b/docs/rules/no-invalid-v-pre.md new file mode 100644 index 000000000..989120333 --- /dev/null +++ b/docs/rules/no-invalid-v-pre.md @@ -0,0 +1,37 @@ +# Disallow invalid v-pre directives (no-invalid-v-pre) + +This rule checks whether every `v-pre` directive is valid. + +## πŸ“– Rule Details + +This rule reports `v-pre` directives if the following cases: + +- The directive has that argument. E.g. `
` +- The directive has that modifier. E.g. `
` +- The directive has that attribute value. E.g. `
` + +πŸ‘Ž Examples of **incorrect** code for this rule: + +```html + +``` + +πŸ‘ Examples of **correct** code for this rule: + +```html + +``` + +## πŸ”§ Options + +Nothing. diff --git a/docs/rules/no-invalid-v-show.md b/docs/rules/no-invalid-v-show.md new file mode 100644 index 000000000..1a13ef881 --- /dev/null +++ b/docs/rules/no-invalid-v-show.md @@ -0,0 +1,46 @@ +# Disallow invalid v-show directives (no-invalid-v-show) + +This rule checks whether every `v-show` directive is valid. + +## πŸ“– Rule Details + +This rule reports `v-show` directives if the following cases: + +- The directive has that argument. E.g. `
` +- The directive has that modifier. E.g. `
` +- The directive does not have that attribute value. E.g. `
` + +This rule does not check syntax errors in directives because it's checked by [no-parsing-error] rule. + +πŸ‘Ž Examples of **incorrect** code for this rule: + +```html + +``` + +πŸ‘ Examples of **correct** code for this rule: + +```html + +``` + +## πŸ”§ Options + +Nothing. + +## πŸ‘« Related rules + +- [no-parsing-error] + + +[no-parsing-error]: no-parsing-error.md diff --git a/docs/rules/no-invalid-v-text.md b/docs/rules/no-invalid-v-text.md new file mode 100644 index 000000000..39e966202 --- /dev/null +++ b/docs/rules/no-invalid-v-text.md @@ -0,0 +1,46 @@ +# Disallow invalid v-text directives (no-invalid-v-text) + +This rule checks whether every `v-text` directive is valid. + +## πŸ“– Rule Details + +This rule reports `v-text` directives if the following cases: + +- The directive has that argument. E.g. `
` +- The directive has that modifier. E.g. `
` +- The directive does not have that attribute value. E.g. `
` + +This rule does not check syntax errors in directives because it's checked by [no-parsing-error] rule. + +πŸ‘Ž Examples of **incorrect** code for this rule: + +```html + +``` + +πŸ‘ Examples of **correct** code for this rule: + +```html + +``` + +## πŸ”§ Options + +Nothing. + +## πŸ‘« Related rules + +- [no-parsing-error] + + +[no-parsing-error]: no-parsing-error.md diff --git a/docs/rules/no-parsing-error.md b/docs/rules/no-parsing-error.md new file mode 100644 index 000000000..8294de388 --- /dev/null +++ b/docs/rules/no-parsing-error.md @@ -0,0 +1,28 @@ +# Disallow parsing errors in `