From 9f3063ef030d853d9de083903b5631a93b3248a6 Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Sat, 14 Mar 2020 17:22:01 +0900 Subject: [PATCH] Add the ruleset for Vue.js 3 - Add `plugin:vue/vue3-essential` config - Add `plugin:vue/vue3-strongly-recommended` config - Add `plugin:vue/vue3-recommended` config --- .eslintrc.js | 1 + docs/.vuepress/config.js | 46 +++++- docs/rules/README.md | 121 ++++++++++++-- docs/rules/attribute-hyphenation.md | 2 +- docs/rules/attributes-order.md | 2 +- .../rules/component-definition-name-casing.md | 2 +- docs/rules/component-tags-order.md | 2 +- docs/rules/html-closing-bracket-newline.md | 2 +- docs/rules/html-closing-bracket-spacing.md | 2 +- docs/rules/html-end-tags.md | 2 +- docs/rules/html-indent.md | 2 +- docs/rules/html-quotes.md | 2 +- docs/rules/html-self-closing.md | 2 +- docs/rules/max-attributes-per-line.md | 2 +- .../multiline-html-element-content-newline.md | 2 +- docs/rules/mustache-interpolation-spacing.md | 2 +- docs/rules/no-async-in-computed-properties.md | 2 +- docs/rules/no-deprecated-filter.md | 1 + docs/rules/no-deprecated-scope-attribute.md | 1 + docs/rules/no-deprecated-slot-attribute.md | 1 + .../no-deprecated-slot-scope-attribute.md | 1 + docs/rules/no-deprecated-v-bind-sync.md | 1 + docs/rules/no-dupe-keys.md | 2 +- docs/rules/no-duplicate-attributes.md | 2 +- docs/rules/no-lifecycle-after-await.md | 2 + docs/rules/no-multi-spaces.md | 2 +- docs/rules/no-parsing-error.md | 2 +- docs/rules/no-ref-as-operand.md | 2 + docs/rules/no-reserved-keys.md | 2 +- docs/rules/no-setup-props-destructure.md | 2 + docs/rules/no-shared-component-data.md | 2 +- .../no-side-effects-in-computed-properties.md | 2 +- ...-spaces-around-equal-signs-in-attribute.md | 2 +- docs/rules/no-template-key.md | 2 +- docs/rules/no-template-shadow.md | 2 +- docs/rules/no-textarea-mustache.md | 2 +- docs/rules/no-unused-components.md | 2 +- docs/rules/no-unused-vars.md | 2 +- docs/rules/no-use-v-if-with-v-for.md | 2 +- docs/rules/no-v-html.md | 2 +- docs/rules/order-in-components.md | 2 +- docs/rules/prop-name-casing.md | 2 +- docs/rules/require-component-is.md | 2 +- docs/rules/require-default-prop.md | 2 +- docs/rules/require-prop-type-constructor.md | 2 +- docs/rules/require-prop-types.md | 2 +- docs/rules/require-render-return.md | 2 +- docs/rules/require-v-for-key.md | 2 +- docs/rules/require-valid-default-prop.md | 2 +- docs/rules/return-in-computed-property.md | 2 +- ...singleline-html-element-content-newline.md | 2 +- docs/rules/this-in-template.md | 2 +- docs/rules/use-v-on-exact.md | 2 +- docs/rules/v-bind-style.md | 2 +- docs/rules/v-on-style.md | 2 +- docs/rules/v-slot-style.md | 2 +- docs/rules/valid-template-root.md | 2 +- docs/rules/valid-v-bind.md | 2 +- docs/rules/valid-v-cloak.md | 2 +- docs/rules/valid-v-else-if.md | 2 +- docs/rules/valid-v-else.md | 2 +- docs/rules/valid-v-for.md | 2 +- docs/rules/valid-v-html.md | 2 +- docs/rules/valid-v-if.md | 2 +- docs/rules/valid-v-model.md | 2 +- docs/rules/valid-v-on.md | 2 +- docs/rules/valid-v-once.md | 2 +- docs/rules/valid-v-pre.md | 2 +- docs/rules/valid-v-show.md | 2 +- docs/rules/valid-v-slot.md | 2 +- docs/rules/valid-v-text.md | 2 +- docs/user-guide/README.md | 4 +- .../consistent-docs-description.js | 2 +- .../no-invalid-meta-docs-categories.js | 147 ++++++++++++++++++ eslint-internal-rules/no-invalid-meta.js | 10 +- .../require-meta-docs-url.js | 2 +- lib/configs/vue3-essential.js | 52 +++++++ lib/configs/vue3-recommended.js | 15 ++ lib/configs/vue3-strongly-recommended.js | 31 ++++ lib/index.js | 7 +- lib/rules/array-bracket-spacing.js | 2 +- lib/rules/attribute-hyphenation.js | 2 +- lib/rules/attributes-order.js | 2 +- lib/rules/block-spacing.js | 2 +- lib/rules/brace-style.js | 2 +- lib/rules/comment-directive.js | 2 +- lib/rules/component-definition-name-casing.js | 2 +- .../component-name-in-template-casing.js | 2 +- lib/rules/component-tags-order.js | 2 +- lib/rules/html-closing-bracket-newline.js | 2 +- lib/rules/html-closing-bracket-spacing.js | 2 +- lib/rules/html-end-tags.js | 2 +- lib/rules/html-indent.js | 2 +- lib/rules/html-quotes.js | 2 +- lib/rules/html-self-closing.js | 2 +- lib/rules/jsx-uses-vars.js | 2 +- lib/rules/key-spacing.js | 2 +- lib/rules/keyword-spacing.js | 2 +- lib/rules/match-component-file-name.js | 2 +- lib/rules/max-attributes-per-line.js | 2 +- lib/rules/max-len.js | 2 +- .../multiline-html-element-content-newline.js | 2 +- lib/rules/mustache-interpolation-spacing.js | 2 +- lib/rules/name-property-casing.js | 2 +- lib/rules/no-async-in-computed-properties.js | 2 +- lib/rules/no-boolean-default.js | 2 +- lib/rules/no-confusing-v-for-v-if.js | 2 +- lib/rules/no-custom-modifiers-on-v-model.js | 2 +- lib/rules/no-deprecated-filter.js | 2 +- lib/rules/no-deprecated-scope-attribute.js | 2 +- lib/rules/no-deprecated-slot-attribute.js | 2 +- .../no-deprecated-slot-scope-attribute.js | 2 +- lib/rules/no-deprecated-v-bind-sync.js | 2 +- lib/rules/no-dupe-keys.js | 2 +- lib/rules/no-duplicate-attributes.js | 2 +- lib/rules/no-irregular-whitespace.js | 2 +- lib/rules/no-lifecycle-after-await.js | 2 +- lib/rules/no-multi-spaces.js | 2 +- lib/rules/no-multiple-template-root.js | 2 +- lib/rules/no-parsing-error.js | 2 +- lib/rules/no-ref-as-operand.js | 2 +- lib/rules/no-reserved-component-names.js | 2 +- lib/rules/no-reserved-keys.js | 2 +- lib/rules/no-setup-props-destructure.js | 2 +- lib/rules/no-shared-component-data.js | 2 +- .../no-side-effects-in-computed-properties.js | 2 +- ...-spaces-around-equal-signs-in-attribute.js | 2 +- lib/rules/no-static-inline-styles.js | 2 +- lib/rules/no-template-key.js | 2 +- lib/rules/no-template-shadow.js | 2 +- lib/rules/no-textarea-mustache.js | 2 +- lib/rules/no-unsupported-features.js | 2 +- lib/rules/no-unused-components.js | 2 +- lib/rules/no-unused-vars.js | 2 +- lib/rules/no-use-v-if-with-v-for.js | 2 +- lib/rules/no-v-html.js | 2 +- lib/rules/no-v-model-argument.js | 2 +- lib/rules/object-curly-spacing.js | 2 +- lib/rules/order-in-components.js | 2 +- lib/rules/padding-line-between-blocks.js | 2 +- lib/rules/prop-name-casing.js | 2 +- lib/rules/require-component-is.js | 2 +- lib/rules/require-default-prop.js | 2 +- lib/rules/require-direct-export.js | 2 +- lib/rules/require-name-property.js | 2 +- lib/rules/require-prop-type-constructor.js | 2 +- lib/rules/require-prop-types.js | 2 +- lib/rules/require-render-return.js | 2 +- lib/rules/require-v-for-key.js | 2 +- lib/rules/require-valid-default-prop.js | 2 +- lib/rules/return-in-computed-property.js | 2 +- lib/rules/script-indent.js | 2 +- ...singleline-html-element-content-newline.js | 2 +- lib/rules/sort-keys.js | 2 +- lib/rules/space-infix-ops.js | 2 +- lib/rules/space-unary-ops.js | 2 +- lib/rules/static-class-names-order.js | 2 +- lib/rules/this-in-template.js | 2 +- lib/rules/use-v-on-exact.js | 2 +- lib/rules/v-bind-style.js | 2 +- lib/rules/v-on-function-call.js | 2 +- lib/rules/v-on-style.js | 2 +- lib/rules/v-slot-style.js | 2 +- lib/rules/valid-template-root.js | 2 +- lib/rules/valid-v-bind-sync.js | 2 +- lib/rules/valid-v-bind.js | 2 +- lib/rules/valid-v-cloak.js | 2 +- lib/rules/valid-v-else-if.js | 2 +- lib/rules/valid-v-else.js | 2 +- lib/rules/valid-v-for.js | 2 +- lib/rules/valid-v-html.js | 2 +- lib/rules/valid-v-if.js | 2 +- lib/rules/valid-v-model.js | 2 +- lib/rules/valid-v-on.js | 2 +- lib/rules/valid-v-once.js | 2 +- lib/rules/valid-v-pre.js | 2 +- lib/rules/valid-v-show.js | 2 +- lib/rules/valid-v-slot.js | 2 +- lib/rules/valid-v-text.js | 2 +- package.json | 1 + tools/lib/categories.js | 57 +++++-- tools/lib/rules.js | 18 ++- tools/update-docs-rules-index.js | 4 +- tools/update-docs.js | 36 ++++- tools/update-lib-configs.js | 33 ++-- 185 files changed, 696 insertions(+), 220 deletions(-) create mode 100644 eslint-internal-rules/no-invalid-meta-docs-categories.js create mode 100644 lib/configs/vue3-essential.js create mode 100644 lib/configs/vue3-recommended.js create mode 100644 lib/configs/vue3-strongly-recommended.js diff --git a/.eslintrc.js b/.eslintrc.js index eade1e93d..2693499d0 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -29,6 +29,7 @@ module.exports = { rules: { "consistent-docs-description": "error", "no-invalid-meta": "error", + "no-invalid-meta-docs-categories": "error", 'eslint-plugin/require-meta-type': 'error', "require-meta-docs-url": ["error", { "pattern": `https://eslint.vuejs.org/rules/{{name}}.html` diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 3f8282598..0b78e7eba 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -5,11 +5,47 @@ 'use strict' const rules = require('../../tools/lib/rules') -const categories = require('../../tools/lib/categories') -const uncategorizedRules = rules.filter(rule => !rule.meta.docs.category && !rule.meta.deprecated) +const uncategorizedRules = rules.filter(rule => !rule.meta.docs.categories && !rule.meta.deprecated) const deprecatedRules = rules.filter(rule => rule.meta.deprecated) +const sidebarCategories = [ + { title: 'Base Rules', categoryIds: ['base'] }, + { title: 'Priority A: Essential', categoryIds: ['vue3-essential', 'essential'] }, + { title: 'Priority A: Essential for Vue.js 3.x', categoryIds: ['vue3-essential'] }, + { title: 'Priority A: Essential for Vue.js 2.x', categoryIds: ['essential'] }, + { title: 'Priority B: Strongly Recommended', categoryIds: ['vue3-strongly-recommended', 'strongly-recommended'] }, + { title: 'Priority B: Strongly Recommended for Vue.js 3.x', categoryIds: ['vue3-strongly-recommended'] }, + { title: 'Priority B: Strongly Recommended for Vue.js 2.x', categoryIds: ['strongly-recommended'] }, + { title: 'Priority C: Recommended', categoryIds: ['vue3-recommended', 'recommended'] }, + { title: 'Priority C: Recommended for Vue.js 3.x', categoryIds: ['vue3-recommended'] }, + { title: 'Priority C: Recommended for Vue.js 2.x', categoryIds: ['recommended'] } +] + +const categorizedRules = [] +for (const { title, categoryIds } of sidebarCategories) { + const categoryRules = rules + .filter(rule => rule.meta.docs.categories && !rule.meta.deprecated) + .filter(rule => categoryIds + .every(categoryId => rule.meta.docs.categories.includes(categoryId)) + ) + const children = categoryRules + .filter(({ ruleId }) => { + const exists = categorizedRules.some(({ children }) => children.some(([, alreadyRuleId]) => alreadyRuleId === ruleId)) + return !exists + }) + .map(({ ruleId, name }) => [`/rules/${name}`, ruleId]) + + if (children.length === 0) { + continue + } + categorizedRules.push({ + title, + collapsable: false, + children + }) +} + const extraCategories = [] if (uncategorizedRules.length > 0) { extraCategories.push({ @@ -59,11 +95,7 @@ module.exports = { '/rules/', // Rules in each category. - ...categories.map(({ title, rules }) => ({ - title: title.replace(/ \(.+?\)/, ''), - collapsable: false, - children: rules.map(({ ruleId, name }) => [`/rules/${name}`, ruleId]) - })), + ...categorizedRules, // Rules in no category. ...extraCategories diff --git a/docs/rules/README.md b/docs/rules/README.md index 5b21a0840..e184873e5 100644 --- a/docs/rules/README.md +++ b/docs/rules/README.md @@ -26,7 +26,114 @@ Enforce all the rules in this category, as well as all higher priority rules, wi | [vue/comment-directive](./comment-directive.md) | support comment-directives in `