From c6c5c462e4e55d31552b4e1cb7ed524c7efc07c7 Mon Sep 17 00:00:00 2001 From: Yosuke Ota Date: Mon, 25 Mar 2024 19:49:18 +0900 Subject: [PATCH] Change flat config to an array to accept `*.vue` (#2436) Co-authored-by: Flo Edelmann --- docs/.vitepress/vite-plugin.mts | 4 +- docs/rules/attribute-hyphenation.md | 2 +- docs/rules/attributes-order.md | 2 +- docs/rules/comment-directive.md | 2 +- .../rules/component-definition-name-casing.md | 2 +- docs/rules/component-tags-order.md | 2 +- docs/rules/first-attribute-linebreak.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/index.md | 12 +- docs/rules/jsx-uses-vars.md | 2 +- docs/rules/max-attributes-per-line.md | 2 +- docs/rules/multi-word-component-names.md | 2 +- .../multiline-html-element-content-newline.md | 2 +- docs/rules/mustache-interpolation-spacing.md | 2 +- docs/rules/no-arrow-functions-in-watch.md | 2 +- docs/rules/no-async-in-computed-properties.md | 2 +- docs/rules/no-child-content.md | 2 +- docs/rules/no-computed-properties-in-data.md | 2 +- docs/rules/no-custom-modifiers-on-v-model.md | 2 +- .../no-deprecated-data-object-declaration.md | 2 +- .../no-deprecated-destroyed-lifecycle.md | 2 +- .../no-deprecated-dollar-listeners-api.md | 2 +- .../no-deprecated-dollar-scopedslots-api.md | 2 +- docs/rules/no-deprecated-events-api.md | 2 +- docs/rules/no-deprecated-filter.md | 2 +- .../no-deprecated-functional-template.md | 2 +- docs/rules/no-deprecated-html-element-is.md | 2 +- docs/rules/no-deprecated-inline-template.md | 2 +- .../rules/no-deprecated-props-default-this.md | 2 +- .../no-deprecated-router-link-tag-prop.md | 2 +- docs/rules/no-deprecated-scope-attribute.md | 2 +- docs/rules/no-deprecated-slot-attribute.md | 2 +- .../no-deprecated-slot-scope-attribute.md | 2 +- docs/rules/no-deprecated-v-bind-sync.md | 2 +- docs/rules/no-deprecated-v-is.md | 2 +- .../no-deprecated-v-on-native-modifier.md | 2 +- .../no-deprecated-v-on-number-modifiers.md | 2 +- .../no-deprecated-vue-config-keycodes.md | 2 +- docs/rules/no-dupe-keys.md | 2 +- docs/rules/no-dupe-v-else-if.md | 2 +- docs/rules/no-duplicate-attributes.md | 2 +- docs/rules/no-export-in-script-setup.md | 2 +- docs/rules/no-expose-after-await.md | 2 +- docs/rules/no-lifecycle-after-await.md | 2 +- docs/rules/no-lone-template.md | 2 +- docs/rules/no-multi-spaces.md | 2 +- docs/rules/no-multiple-slot-args.md | 2 +- docs/rules/no-multiple-template-root.md | 2 +- docs/rules/no-mutating-props.md | 2 +- docs/rules/no-parsing-error.md | 2 +- docs/rules/no-ref-as-operand.md | 2 +- docs/rules/no-reserved-component-names.md | 2 +- docs/rules/no-reserved-keys.md | 2 +- docs/rules/no-reserved-props.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 +- .../no-use-computed-property-like-method.md | 2 +- docs/rules/no-use-v-if-with-v-for.md | 2 +- docs/rules/no-useless-template-attributes.md | 2 +- docs/rules/no-v-for-template-key-on-child.md | 2 +- docs/rules/no-v-for-template-key.md | 2 +- docs/rules/no-v-html.md | 2 +- docs/rules/no-v-model-argument.md | 2 +- docs/rules/no-v-text-v-html-on-component.md | 2 +- docs/rules/no-watch-after-await.md | 2 +- docs/rules/one-component-per-file.md | 2 +- docs/rules/order-in-components.md | 2 +- docs/rules/prefer-import-from-vue.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-explicit-emits.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-slots-as-functions.md | 2 +- .../rules/require-toggle-inside-transition.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 +- docs/rules/return-in-emits-validator.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-event-hyphenation.md | 2 +- docs/rules/v-on-style.md | 2 +- docs/rules/v-slot-style.md | 2 +- docs/rules/valid-attribute-name.md | 2 +- docs/rules/valid-define-emits.md | 2 +- docs/rules/valid-define-props.md | 2 +- docs/rules/valid-model-definition.md | 2 +- docs/rules/valid-next-tick.md | 2 +- docs/rules/valid-template-root.md | 2 +- docs/rules/valid-v-bind-sync.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-is.md | 2 +- docs/rules/valid-v-memo.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/index.md | 58 ++++- lib/configs/flat/base.js | 38 ++- lib/configs/flat/vue2-essential.js | 136 +++++----- lib/configs/flat/vue2-recommended.js | 26 +- lib/configs/flat/vue2-strongly-recommended.js | 58 +++-- lib/configs/flat/vue3-essential.js | 172 +++++++------ lib/configs/flat/vue3-recommended.js | 26 +- lib/configs/flat/vue3-strongly-recommended.js | 72 +++--- lib/index.js | 74 ++---- lib/utils/config-helpers.js | 19 -- package.json | 1 + tests/eslint-compat.js | 9 + tests/integrations/flat-config.js | 42 +++ tests/integrations/flat-config/.npmrc | 1 + tests/integrations/flat-config/a.vue | 12 + .../integrations/flat-config/eslint.config.js | 9 + tests/integrations/flat-config/package.json | 13 + tests/lib/configs/flat.js | 243 ++++++++++++++++-- tools/lib/categories.js | 45 +++- tools/update-docs-rules-index.js | 7 +- tools/update-docs.js | 7 +- tools/update-lib-configs.js | 2 +- tools/update-lib-flat-configs.js | 49 +++- tools/update-lib-index.js | 50 ++-- 146 files changed, 894 insertions(+), 531 deletions(-) delete mode 100644 lib/utils/config-helpers.js create mode 100644 tests/integrations/flat-config.js create mode 100644 tests/integrations/flat-config/.npmrc create mode 100644 tests/integrations/flat-config/a.vue create mode 100644 tests/integrations/flat-config/eslint.config.js create mode 100644 tests/integrations/flat-config/package.json diff --git a/docs/.vitepress/vite-plugin.mts b/docs/.vitepress/vite-plugin.mts index fd0644ed5..ba1ca7db0 100644 --- a/docs/.vitepress/vite-plugin.mts +++ b/docs/.vitepress/vite-plugin.mts @@ -65,7 +65,7 @@ function transformRequire(code: string) { id += Math.random().toString(32).substring(2) } modules.set(id, moduleString) - return id + return id + '()' } ) @@ -73,7 +73,7 @@ function transformRequire(code: string) { [...modules] .map(([id, moduleString]) => { return `import * as __temp_${id} from ${moduleString}; -const ${id} = __temp_${id}.default || __temp_${id}; +const ${id} = () => __temp_${id}.default || __temp_${id}; ` }) .join('') + diff --git a/docs/rules/attribute-hyphenation.md b/docs/rules/attribute-hyphenation.md index 5c2de0027..d5fba2e31 100644 --- a/docs/rules/attribute-hyphenation.md +++ b/docs/rules/attribute-hyphenation.md @@ -10,7 +10,7 @@ since: v3.9.0 > enforce attribute naming style on custom components in template -- :gear: This rule is included in all of `"plugin:vue/vue3-strongly-recommended"`, `"plugin:vue/strongly-recommended"`, `"plugin:vue/vue3-recommended"` and `"plugin:vue/recommended"`. +- :gear: This rule is included in all of `"plugin:vue/vue3-strongly-recommended"`, `*.configs["flat/strongly-recommended"]`, `"plugin:vue/strongly-recommended"`, `*.configs["flat/vue2-strongly-recommended"]`, `"plugin:vue/vue3-recommended"`, `*.configs["flat/recommended"]`, `"plugin:vue/recommended"` and `*.configs["flat/vue2-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 diff --git a/docs/rules/attributes-order.md b/docs/rules/attributes-order.md index a9cf47288..366f134b8 100644 --- a/docs/rules/attributes-order.md +++ b/docs/rules/attributes-order.md @@ -10,7 +10,7 @@ since: v4.3.0 > enforce order of attributes -- :gear: This rule is included in `"plugin:vue/vue3-recommended"` and `"plugin:vue/recommended"`. +- :gear: This rule is included in all of `"plugin:vue/vue3-recommended"`, `*.configs["flat/recommended"]`, `"plugin:vue/recommended"` and `*.configs["flat/vue2-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 diff --git a/docs/rules/comment-directive.md b/docs/rules/comment-directive.md index b95f31668..9bc227a6f 100644 --- a/docs/rules/comment-directive.md +++ b/docs/rules/comment-directive.md @@ -10,7 +10,7 @@ since: v4.1.0 > support comment-directives in `