From 793112d2ffaab146bd7d5315c738a9d9d3bafd48 Mon Sep 17 00:00:00 2001 From: IWANABETHATGUY <974153916@qq.com> Date: Sat, 29 May 2021 09:51:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20https://github.com/vuejs?= =?UTF-8?q?/eslint-plugin-vue/issues/1492=20(#1493)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 🎸 https://github.com/vuejs/eslint-plugin-vue/issues/1492 * docs: ✏️ update doc * fix: 🐛 fix eslint --- .../components/eslint-code-block.vue | 15 +-- docs/rules/README.md | 4 +- docs/rules/this-in-template.md | 5 +- lib/rules/attributes-order.js | 6 +- lib/rules/component-definition-name-casing.js | 3 +- .../component-name-in-template-casing.js | 3 +- lib/rules/experimental-script-setup-vars.js | 5 +- lib/rules/html-self-closing.js | 6 +- lib/rules/max-attributes-per-line.js | 9 +- lib/rules/max-len.js | 3 +- .../multiline-html-element-content-newline.js | 17 +-- .../new-line-between-multi-line-property.js | 3 +- .../no-deprecated-data-object-declaration.js | 3 +- .../no-deprecated-destroyed-lifecycle.js | 3 +- .../no-deprecated-dollar-listeners-api.js | 3 +- .../no-deprecated-dollar-scopedslots-api.js | 3 +- .../no-deprecated-functional-template.js | 3 +- lib/rules/no-deprecated-props-default-this.js | 3 +- lib/rules/no-deprecated-scope-attribute.js | 5 +- .../no-deprecated-slot-scope-attribute.js | 3 +- .../no-deprecated-v-on-native-modifier.js | 3 +- .../no-deprecated-v-on-number-modifiers.js | 3 +- .../no-deprecated-vue-config-keycodes.js | 3 +- lib/rules/no-extra-parens.js | 3 +- lib/rules/no-irregular-whitespace.js | 9 +- .../no-potential-component-option-typo.js | 3 +- lib/rules/no-restricted-v-bind.js | 5 +- .../no-side-effects-in-computed-properties.js | 9 +- ...-spaces-around-equal-signs-in-attribute.js | 3 +- lib/rules/no-useless-mustaches.js | 7 +- lib/rules/no-useless-v-bind.js | 3 +- lib/rules/require-explicit-emits.js | 42 +++--- lib/rules/require-toggle-inside-transition.js | 3 +- ...singleline-html-element-content-newline.js | 17 +-- .../syntaxes/dynamic-directive-arguments.js | 3 +- lib/rules/syntaxes/scope-attribute.js | 3 +- lib/rules/syntaxes/slot-attribute.js | 3 +- .../v-bind-prop-modifier-shorthand.js | 3 +- lib/rules/this-in-template.js | 11 +- lib/rules/v-for-delimiter-style.js | 14 +- lib/rules/v-slot-style.js | 5 +- lib/utils/indent-common.js | 96 ++++++-------- lib/utils/index.js | 42 +++--- tests/lib/rules/attribute-hyphenation.js | 30 ++--- tests/lib/rules/attributes-order.js | 21 +-- tests/lib/rules/block-spacing.js | 6 +- tests/lib/rules/block-tag-newline.js | 21 +-- tests/lib/rules/brace-style.js | 3 +- .../component-name-in-template-casing.js | 3 +- tests/lib/rules/component-tags-order.js | 9 +- tests/lib/rules/html-button-has-type.js | 6 +- .../rules/mustache-interpolation-spacing.js | 6 +- tests/lib/rules/no-confusing-v-for-v-if.js | 18 +-- tests/lib/rules/no-deprecated-filter.js | 6 +- .../rules/no-deprecated-inline-template.js | 15 +-- tests/lib/rules/no-deprecated-v-bind-sync.js | 39 ++---- .../no-deprecated-v-on-number-modifiers.js | 9 +- tests/lib/rules/no-dupe-v-else-if.js | 123 ++++++------------ tests/lib/rules/no-duplicate-attributes.js | 3 +- tests/lib/rules/no-extra-parens.js | 6 +- tests/lib/rules/no-irregular-whitespace.js | 7 +- tests/lib/rules/no-multi-spaces.js | 3 +- tests/lib/rules/no-multiple-template-root.js | 9 +- tests/lib/rules/no-parsing-error.js | 3 +- .../rules/no-restricted-static-attribute.js | 3 +- tests/lib/rules/no-restricted-v-bind.js | 3 +- tests/lib/rules/no-template-key.js | 21 +-- tests/lib/rules/no-template-shadow.js | 3 +- tests/lib/rules/no-template-target-blank.js | 27 ++-- tests/lib/rules/no-textarea-mustache.js | 6 +- tests/lib/rules/no-unused-vars.js | 48 +++---- tests/lib/rules/no-use-v-if-with-v-for.js | 42 ++---- .../rules/no-v-for-template-key-on-child.js | 30 ++--- tests/lib/rules/no-v-for-template-key.js | 21 +-- tests/lib/rules/no-v-model-argument.js | 6 +- tests/lib/rules/require-explicit-emits.js | 42 ++---- .../rules/require-toggle-inside-transition.js | 30 ++--- tests/lib/rules/require-v-for-key.js | 57 +++----- tests/lib/rules/this-in-template.js | 44 +++++++ tests/lib/rules/valid-template-root.js | 9 +- tests/lib/rules/valid-v-bind-sync.js | 42 ++---- tests/lib/rules/valid-v-else-if.js | 42 ++---- tests/lib/rules/valid-v-else.js | 30 ++--- tests/lib/rules/valid-v-for.js | 120 ++++++----------- tests/lib/rules/valid-v-if.js | 3 +- tests/lib/rules/valid-v-model.js | 60 +++------ tests/lib/rules/valid-v-slot.js | 12 +- tools/lib/categories.js | 18 +-- 88 files changed, 575 insertions(+), 888 deletions(-) diff --git a/docs/.vuepress/components/eslint-code-block.vue b/docs/.vuepress/components/eslint-code-block.vue index 00b694825..381d9985f 100644 --- a/docs/.vuepress/components/eslint-code-block.vue +++ b/docs/.vuepress/components/eslint-code-block.vue @@ -122,15 +122,12 @@ export default { async mounted() { // Load linter. - const [ - { default: Linter }, - { default: coreRules }, - { parseForESLint } - ] = await Promise.all([ - import('eslint4b/dist/linter'), - import('eslint4b/dist/core-rules'), - import('espree').then(() => import('vue-eslint-parser')) - ]) + const [{ default: Linter }, { default: coreRules }, { parseForESLint }] = + await Promise.all([ + import('eslint4b/dist/linter'), + import('eslint4b/dist/core-rules'), + import('espree').then(() => import('vue-eslint-parser')) + ]) const linter = (this.linter = new Linter()) diff --git a/docs/rules/README.md b/docs/rules/README.md index e34e4ca2b..9717d49ae 100644 --- a/docs/rules/README.md +++ b/docs/rules/README.md @@ -157,7 +157,7 @@ Enforce all the rules in this category, as well as all higher priority rules, wi | [vue/no-multiple-slot-args](./no-multiple-slot-args.md) | disallow to pass multiple arguments to scoped slots | | | [vue/no-v-html](./no-v-html.md) | disallow use of v-html to prevent XSS attack | | | [vue/order-in-components](./order-in-components.md) | enforce order of properties in components | :wrench: | -| [vue/this-in-template](./this-in-template.md) | disallow usage of `this` in template | | +| [vue/this-in-template](./this-in-template.md) | disallow usage of `this` in template | :wrench: | ## Priority A: Essential (Error Prevention) for Vue.js 2.x @@ -267,7 +267,7 @@ Enforce all the rules in this category, as well as all higher priority rules, wi | [vue/no-multiple-slot-args](./no-multiple-slot-args.md) | disallow to pass multiple arguments to scoped slots | | | [vue/no-v-html](./no-v-html.md) | disallow use of v-html to prevent XSS attack | | | [vue/order-in-components](./order-in-components.md) | enforce order of properties in components | :wrench: | -| [vue/this-in-template](./this-in-template.md) | disallow usage of `this` in template | | +| [vue/this-in-template](./this-in-template.md) | disallow usage of `this` in template | :wrench: | ## Uncategorized diff --git a/docs/rules/this-in-template.md b/docs/rules/this-in-template.md index 7924ad3b5..f193e7e37 100644 --- a/docs/rules/this-in-template.md +++ b/docs/rules/this-in-template.md @@ -10,12 +10,13 @@ since: v3.13.0 > disallow usage of `this` in template - :gear: This rule is included in `"plugin:vue/vue3-recommended"` and `"plugin:vue/recommended"`. +- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule. ## :book: Rule Details This rule aims at preventing usage of `this` in Vue templates. - + ```vue