From efb2832c1be577ec268cedcf773a01924ba95d54 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Tue, 15 Jul 2025 12:41:01 +1200 Subject: [PATCH 01/10] feat: support using `error` instead of `warn` for rules in config --- tools/update-lib-configs.js | 8 +++++++- tools/update-lib-flat-configs.js | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/update-lib-configs.js b/tools/update-lib-configs.js index 0c2845e45..384e4ac1d 100644 --- a/tools/update-lib-configs.js +++ b/tools/update-lib-configs.js @@ -44,7 +44,9 @@ function formatRules(rules, categoryId) { return [rule.ruleId, options] }) ) - return JSON.stringify(obj, null, 2) + // use the ruleLevel variable for rules set to warn so that they can + // be made to error with an env variable if desired + return JSON.stringify(obj, null, 2).replaceAll('"warn"', 'ruleLevel') } function formatCategory(category) { @@ -55,6 +57,8 @@ function formatCategory(category) { * This file has been automatically generated, * in order to update its content execute "npm run update" */ +const ruleLevel = process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' + module.exports = { parserOptions: { ecmaVersion: 'latest', @@ -78,6 +82,8 @@ module.exports = { * This file has been automatically generated, * in order to update its content execute "npm run update" */ +const ruleLevel = process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' + module.exports = { extends: require.resolve('./${extendsCategoryId}'), rules: ${formatRules(category.rules, category.categoryId)} diff --git a/tools/update-lib-flat-configs.js b/tools/update-lib-flat-configs.js index e55fb2d01..7d81b3842 100644 --- a/tools/update-lib-flat-configs.js +++ b/tools/update-lib-flat-configs.js @@ -44,7 +44,9 @@ function formatRules(rules, categoryId) { return [rule.ruleId, options] }) ) - return JSON.stringify(obj, null, 2) + // use the ruleLevel variable for rules set to warn so that they can + // be made to error with an env variable if desired + return JSON.stringify(obj, null, 2).replaceAll('"warn"', 'ruleLevel') } function formatCategory(category) { @@ -55,6 +57,8 @@ function formatCategory(category) { * This file has been automatically generated, * in order to update its content execute "npm run update" */ +const ruleLevel = process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' + module.exports = [ { name: 'vue/base/setup', @@ -93,6 +97,8 @@ module.exports = [ 'use strict' const config = require('./${extendsCategoryId}.js') +const ruleLevel = process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' + module.exports = [ ...config, { From a379d772e7a31849c8af25b2a28df13639719346 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Tue, 15 Jul 2025 12:41:12 +1200 Subject: [PATCH 02/10] feat: regenerate configs --- lib/configs/base.js | 3 ++ lib/configs/flat/base.js | 3 ++ lib/configs/flat/vue2-essential.js | 3 ++ lib/configs/flat/vue2-recommended.js | 19 ++++--- lib/configs/flat/vue2-strongly-recommended.js | 49 +++++++++-------- lib/configs/flat/vue3-essential.js | 3 ++ lib/configs/flat/vue3-recommended.js | 19 ++++--- lib/configs/flat/vue3-strongly-recommended.js | 53 ++++++++++--------- lib/configs/vue2-essential.js | 3 ++ lib/configs/vue2-recommended.js | 19 ++++--- lib/configs/vue2-strongly-recommended.js | 49 +++++++++-------- lib/configs/vue3-essential.js | 3 ++ lib/configs/vue3-recommended.js | 19 ++++--- lib/configs/vue3-strongly-recommended.js | 53 ++++++++++--------- 14 files changed, 170 insertions(+), 128 deletions(-) diff --git a/lib/configs/base.js b/lib/configs/base.js index c7189fbca..99ad64a2f 100644 --- a/lib/configs/base.js +++ b/lib/configs/base.js @@ -3,6 +3,9 @@ * This file has been automatically generated, * in order to update its content execute "npm run update" */ +const ruleLevel = + process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' + module.exports = { parserOptions: { ecmaVersion: 'latest', diff --git a/lib/configs/flat/base.js b/lib/configs/flat/base.js index 22386f377..90ff3ff0b 100644 --- a/lib/configs/flat/base.js +++ b/lib/configs/flat/base.js @@ -3,6 +3,9 @@ * This file has been automatically generated, * in order to update its content execute "npm run update" */ +const ruleLevel = + process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' + module.exports = [ { name: 'vue/base/setup', diff --git a/lib/configs/flat/vue2-essential.js b/lib/configs/flat/vue2-essential.js index 0d0920413..dd267d0b3 100644 --- a/lib/configs/flat/vue2-essential.js +++ b/lib/configs/flat/vue2-essential.js @@ -6,6 +6,9 @@ 'use strict' const config = require('./base.js') +const ruleLevel = + process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' + module.exports = [ ...config, { diff --git a/lib/configs/flat/vue2-recommended.js b/lib/configs/flat/vue2-recommended.js index 8a972bf3d..8dfcec9dd 100644 --- a/lib/configs/flat/vue2-recommended.js +++ b/lib/configs/flat/vue2-recommended.js @@ -6,19 +6,22 @@ 'use strict' const config = require('./vue2-strongly-recommended.js') +const ruleLevel = + process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' + module.exports = [ ...config, { name: 'vue/vue2-recommended/rules', rules: { - 'vue/attributes-order': 'warn', - 'vue/block-order': 'warn', - 'vue/no-lone-template': 'warn', - 'vue/no-multiple-slot-args': 'warn', - 'vue/no-required-prop-with-default': 'warn', - 'vue/no-v-html': 'warn', - 'vue/order-in-components': 'warn', - 'vue/this-in-template': 'warn' + 'vue/attributes-order': ruleLevel, + 'vue/block-order': ruleLevel, + 'vue/no-lone-template': ruleLevel, + 'vue/no-multiple-slot-args': ruleLevel, + 'vue/no-required-prop-with-default': ruleLevel, + 'vue/no-v-html': ruleLevel, + 'vue/order-in-components': ruleLevel, + 'vue/this-in-template': ruleLevel } } ] diff --git a/lib/configs/flat/vue2-strongly-recommended.js b/lib/configs/flat/vue2-strongly-recommended.js index e4913f40c..d05f5feb6 100644 --- a/lib/configs/flat/vue2-strongly-recommended.js +++ b/lib/configs/flat/vue2-strongly-recommended.js @@ -6,34 +6,37 @@ 'use strict' const config = require('./vue2-essential.js') +const ruleLevel = + process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' + module.exports = [ ...config, { name: 'vue/vue2-strongly-recommended/rules', rules: { - 'vue/attribute-hyphenation': 'warn', - 'vue/component-definition-name-casing': 'warn', - 'vue/first-attribute-linebreak': 'warn', - 'vue/html-closing-bracket-newline': 'warn', - 'vue/html-closing-bracket-spacing': 'warn', - 'vue/html-end-tags': 'warn', - 'vue/html-indent': 'warn', - 'vue/html-quotes': 'warn', - 'vue/html-self-closing': 'warn', - 'vue/max-attributes-per-line': 'warn', - 'vue/multiline-html-element-content-newline': 'warn', - 'vue/mustache-interpolation-spacing': 'warn', - 'vue/no-multi-spaces': 'warn', - 'vue/no-spaces-around-equal-signs-in-attribute': 'warn', - 'vue/no-template-shadow': 'warn', - 'vue/one-component-per-file': 'warn', - 'vue/prop-name-casing': 'warn', - 'vue/require-default-prop': 'warn', - 'vue/require-prop-types': 'warn', - 'vue/singleline-html-element-content-newline': 'warn', - 'vue/v-bind-style': 'warn', - 'vue/v-on-style': 'warn', - 'vue/v-slot-style': 'warn' + 'vue/attribute-hyphenation': ruleLevel, + 'vue/component-definition-name-casing': ruleLevel, + 'vue/first-attribute-linebreak': ruleLevel, + 'vue/html-closing-bracket-newline': ruleLevel, + 'vue/html-closing-bracket-spacing': ruleLevel, + 'vue/html-end-tags': ruleLevel, + 'vue/html-indent': ruleLevel, + 'vue/html-quotes': ruleLevel, + 'vue/html-self-closing': ruleLevel, + 'vue/max-attributes-per-line': ruleLevel, + 'vue/multiline-html-element-content-newline': ruleLevel, + 'vue/mustache-interpolation-spacing': ruleLevel, + 'vue/no-multi-spaces': ruleLevel, + 'vue/no-spaces-around-equal-signs-in-attribute': ruleLevel, + 'vue/no-template-shadow': ruleLevel, + 'vue/one-component-per-file': ruleLevel, + 'vue/prop-name-casing': ruleLevel, + 'vue/require-default-prop': ruleLevel, + 'vue/require-prop-types': ruleLevel, + 'vue/singleline-html-element-content-newline': ruleLevel, + 'vue/v-bind-style': ruleLevel, + 'vue/v-on-style': ruleLevel, + 'vue/v-slot-style': ruleLevel } } ] diff --git a/lib/configs/flat/vue3-essential.js b/lib/configs/flat/vue3-essential.js index ff8b5b4a6..cc2acc613 100644 --- a/lib/configs/flat/vue3-essential.js +++ b/lib/configs/flat/vue3-essential.js @@ -6,6 +6,9 @@ 'use strict' const config = require('./base.js') +const ruleLevel = + process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' + module.exports = [ ...config, { diff --git a/lib/configs/flat/vue3-recommended.js b/lib/configs/flat/vue3-recommended.js index 21be71a8d..f46bc901a 100644 --- a/lib/configs/flat/vue3-recommended.js +++ b/lib/configs/flat/vue3-recommended.js @@ -6,19 +6,22 @@ 'use strict' const config = require('./vue3-strongly-recommended.js') +const ruleLevel = + process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' + module.exports = [ ...config, { name: 'vue/recommended/rules', rules: { - 'vue/attributes-order': 'warn', - 'vue/block-order': 'warn', - 'vue/no-lone-template': 'warn', - 'vue/no-multiple-slot-args': 'warn', - 'vue/no-required-prop-with-default': 'warn', - 'vue/no-v-html': 'warn', - 'vue/order-in-components': 'warn', - 'vue/this-in-template': 'warn' + 'vue/attributes-order': ruleLevel, + 'vue/block-order': ruleLevel, + 'vue/no-lone-template': ruleLevel, + 'vue/no-multiple-slot-args': ruleLevel, + 'vue/no-required-prop-with-default': ruleLevel, + 'vue/no-v-html': ruleLevel, + 'vue/order-in-components': ruleLevel, + 'vue/this-in-template': ruleLevel } } ] diff --git a/lib/configs/flat/vue3-strongly-recommended.js b/lib/configs/flat/vue3-strongly-recommended.js index fee1d3bb8..48db1aa90 100644 --- a/lib/configs/flat/vue3-strongly-recommended.js +++ b/lib/configs/flat/vue3-strongly-recommended.js @@ -6,42 +6,45 @@ 'use strict' const config = require('./vue3-essential.js') +const ruleLevel = + process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' + module.exports = [ ...config, { name: 'vue/strongly-recommended/rules', rules: { - 'vue/attribute-hyphenation': 'warn', - 'vue/component-definition-name-casing': 'warn', - 'vue/first-attribute-linebreak': 'warn', - 'vue/html-closing-bracket-newline': 'warn', - 'vue/html-closing-bracket-spacing': 'warn', - 'vue/html-end-tags': 'warn', - 'vue/html-indent': 'warn', - 'vue/html-quotes': 'warn', - 'vue/html-self-closing': 'warn', - 'vue/max-attributes-per-line': 'warn', - 'vue/multiline-html-element-content-newline': 'warn', - 'vue/mustache-interpolation-spacing': 'warn', - 'vue/no-multi-spaces': 'warn', - 'vue/no-spaces-around-equal-signs-in-attribute': 'warn', - 'vue/no-template-shadow': 'warn', - 'vue/one-component-per-file': 'warn', - 'vue/prop-name-casing': 'warn', - 'vue/require-default-prop': 'warn', - 'vue/require-explicit-emits': 'warn', - 'vue/require-prop-types': 'warn', - 'vue/singleline-html-element-content-newline': 'warn', - 'vue/v-bind-style': 'warn', + 'vue/attribute-hyphenation': ruleLevel, + 'vue/component-definition-name-casing': ruleLevel, + 'vue/first-attribute-linebreak': ruleLevel, + 'vue/html-closing-bracket-newline': ruleLevel, + 'vue/html-closing-bracket-spacing': ruleLevel, + 'vue/html-end-tags': ruleLevel, + 'vue/html-indent': ruleLevel, + 'vue/html-quotes': ruleLevel, + 'vue/html-self-closing': ruleLevel, + 'vue/max-attributes-per-line': ruleLevel, + 'vue/multiline-html-element-content-newline': ruleLevel, + 'vue/mustache-interpolation-spacing': ruleLevel, + 'vue/no-multi-spaces': ruleLevel, + 'vue/no-spaces-around-equal-signs-in-attribute': ruleLevel, + 'vue/no-template-shadow': ruleLevel, + 'vue/one-component-per-file': ruleLevel, + 'vue/prop-name-casing': ruleLevel, + 'vue/require-default-prop': ruleLevel, + 'vue/require-explicit-emits': ruleLevel, + 'vue/require-prop-types': ruleLevel, + 'vue/singleline-html-element-content-newline': ruleLevel, + 'vue/v-bind-style': ruleLevel, 'vue/v-on-event-hyphenation': [ - 'warn', + ruleLevel, 'always', { autofix: true } ], - 'vue/v-on-style': 'warn', - 'vue/v-slot-style': 'warn' + 'vue/v-on-style': ruleLevel, + 'vue/v-slot-style': ruleLevel } } ] diff --git a/lib/configs/vue2-essential.js b/lib/configs/vue2-essential.js index e2c66ceba..12191cf1d 100644 --- a/lib/configs/vue2-essential.js +++ b/lib/configs/vue2-essential.js @@ -3,6 +3,9 @@ * This file has been automatically generated, * in order to update its content execute "npm run update" */ +const ruleLevel = + process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' + module.exports = { extends: require.resolve('./base'), rules: { diff --git a/lib/configs/vue2-recommended.js b/lib/configs/vue2-recommended.js index 9892867c1..a9957d27d 100644 --- a/lib/configs/vue2-recommended.js +++ b/lib/configs/vue2-recommended.js @@ -3,16 +3,19 @@ * This file has been automatically generated, * in order to update its content execute "npm run update" */ +const ruleLevel = + process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' + module.exports = { extends: require.resolve('./vue2-strongly-recommended'), rules: { - 'vue/attributes-order': 'warn', - 'vue/block-order': 'warn', - 'vue/no-lone-template': 'warn', - 'vue/no-multiple-slot-args': 'warn', - 'vue/no-required-prop-with-default': 'warn', - 'vue/no-v-html': 'warn', - 'vue/order-in-components': 'warn', - 'vue/this-in-template': 'warn' + 'vue/attributes-order': ruleLevel, + 'vue/block-order': ruleLevel, + 'vue/no-lone-template': ruleLevel, + 'vue/no-multiple-slot-args': ruleLevel, + 'vue/no-required-prop-with-default': ruleLevel, + 'vue/no-v-html': ruleLevel, + 'vue/order-in-components': ruleLevel, + 'vue/this-in-template': ruleLevel } } diff --git a/lib/configs/vue2-strongly-recommended.js b/lib/configs/vue2-strongly-recommended.js index e7b0f3dc7..47ca2ca7f 100644 --- a/lib/configs/vue2-strongly-recommended.js +++ b/lib/configs/vue2-strongly-recommended.js @@ -3,31 +3,34 @@ * This file has been automatically generated, * in order to update its content execute "npm run update" */ +const ruleLevel = + process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' + module.exports = { extends: require.resolve('./vue2-essential'), rules: { - 'vue/attribute-hyphenation': 'warn', - 'vue/component-definition-name-casing': 'warn', - 'vue/first-attribute-linebreak': 'warn', - 'vue/html-closing-bracket-newline': 'warn', - 'vue/html-closing-bracket-spacing': 'warn', - 'vue/html-end-tags': 'warn', - 'vue/html-indent': 'warn', - 'vue/html-quotes': 'warn', - 'vue/html-self-closing': 'warn', - 'vue/max-attributes-per-line': 'warn', - 'vue/multiline-html-element-content-newline': 'warn', - 'vue/mustache-interpolation-spacing': 'warn', - 'vue/no-multi-spaces': 'warn', - 'vue/no-spaces-around-equal-signs-in-attribute': 'warn', - 'vue/no-template-shadow': 'warn', - 'vue/one-component-per-file': 'warn', - 'vue/prop-name-casing': 'warn', - 'vue/require-default-prop': 'warn', - 'vue/require-prop-types': 'warn', - 'vue/singleline-html-element-content-newline': 'warn', - 'vue/v-bind-style': 'warn', - 'vue/v-on-style': 'warn', - 'vue/v-slot-style': 'warn' + 'vue/attribute-hyphenation': ruleLevel, + 'vue/component-definition-name-casing': ruleLevel, + 'vue/first-attribute-linebreak': ruleLevel, + 'vue/html-closing-bracket-newline': ruleLevel, + 'vue/html-closing-bracket-spacing': ruleLevel, + 'vue/html-end-tags': ruleLevel, + 'vue/html-indent': ruleLevel, + 'vue/html-quotes': ruleLevel, + 'vue/html-self-closing': ruleLevel, + 'vue/max-attributes-per-line': ruleLevel, + 'vue/multiline-html-element-content-newline': ruleLevel, + 'vue/mustache-interpolation-spacing': ruleLevel, + 'vue/no-multi-spaces': ruleLevel, + 'vue/no-spaces-around-equal-signs-in-attribute': ruleLevel, + 'vue/no-template-shadow': ruleLevel, + 'vue/one-component-per-file': ruleLevel, + 'vue/prop-name-casing': ruleLevel, + 'vue/require-default-prop': ruleLevel, + 'vue/require-prop-types': ruleLevel, + 'vue/singleline-html-element-content-newline': ruleLevel, + 'vue/v-bind-style': ruleLevel, + 'vue/v-on-style': ruleLevel, + 'vue/v-slot-style': ruleLevel } } diff --git a/lib/configs/vue3-essential.js b/lib/configs/vue3-essential.js index 34b3229b1..991dc5a27 100644 --- a/lib/configs/vue3-essential.js +++ b/lib/configs/vue3-essential.js @@ -3,6 +3,9 @@ * This file has been automatically generated, * in order to update its content execute "npm run update" */ +const ruleLevel = + process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' + module.exports = { extends: require.resolve('./base'), rules: { diff --git a/lib/configs/vue3-recommended.js b/lib/configs/vue3-recommended.js index 083f6c65b..1346a6da3 100644 --- a/lib/configs/vue3-recommended.js +++ b/lib/configs/vue3-recommended.js @@ -3,16 +3,19 @@ * This file has been automatically generated, * in order to update its content execute "npm run update" */ +const ruleLevel = + process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' + module.exports = { extends: require.resolve('./vue3-strongly-recommended'), rules: { - 'vue/attributes-order': 'warn', - 'vue/block-order': 'warn', - 'vue/no-lone-template': 'warn', - 'vue/no-multiple-slot-args': 'warn', - 'vue/no-required-prop-with-default': 'warn', - 'vue/no-v-html': 'warn', - 'vue/order-in-components': 'warn', - 'vue/this-in-template': 'warn' + 'vue/attributes-order': ruleLevel, + 'vue/block-order': ruleLevel, + 'vue/no-lone-template': ruleLevel, + 'vue/no-multiple-slot-args': ruleLevel, + 'vue/no-required-prop-with-default': ruleLevel, + 'vue/no-v-html': ruleLevel, + 'vue/order-in-components': ruleLevel, + 'vue/this-in-template': ruleLevel } } diff --git a/lib/configs/vue3-strongly-recommended.js b/lib/configs/vue3-strongly-recommended.js index a3f854fc4..6b984eb4f 100644 --- a/lib/configs/vue3-strongly-recommended.js +++ b/lib/configs/vue3-strongly-recommended.js @@ -3,39 +3,42 @@ * This file has been automatically generated, * in order to update its content execute "npm run update" */ +const ruleLevel = + process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' + module.exports = { extends: require.resolve('./vue3-essential'), rules: { - 'vue/attribute-hyphenation': 'warn', - 'vue/component-definition-name-casing': 'warn', - 'vue/first-attribute-linebreak': 'warn', - 'vue/html-closing-bracket-newline': 'warn', - 'vue/html-closing-bracket-spacing': 'warn', - 'vue/html-end-tags': 'warn', - 'vue/html-indent': 'warn', - 'vue/html-quotes': 'warn', - 'vue/html-self-closing': 'warn', - 'vue/max-attributes-per-line': 'warn', - 'vue/multiline-html-element-content-newline': 'warn', - 'vue/mustache-interpolation-spacing': 'warn', - 'vue/no-multi-spaces': 'warn', - 'vue/no-spaces-around-equal-signs-in-attribute': 'warn', - 'vue/no-template-shadow': 'warn', - 'vue/one-component-per-file': 'warn', - 'vue/prop-name-casing': 'warn', - 'vue/require-default-prop': 'warn', - 'vue/require-explicit-emits': 'warn', - 'vue/require-prop-types': 'warn', - 'vue/singleline-html-element-content-newline': 'warn', - 'vue/v-bind-style': 'warn', + 'vue/attribute-hyphenation': ruleLevel, + 'vue/component-definition-name-casing': ruleLevel, + 'vue/first-attribute-linebreak': ruleLevel, + 'vue/html-closing-bracket-newline': ruleLevel, + 'vue/html-closing-bracket-spacing': ruleLevel, + 'vue/html-end-tags': ruleLevel, + 'vue/html-indent': ruleLevel, + 'vue/html-quotes': ruleLevel, + 'vue/html-self-closing': ruleLevel, + 'vue/max-attributes-per-line': ruleLevel, + 'vue/multiline-html-element-content-newline': ruleLevel, + 'vue/mustache-interpolation-spacing': ruleLevel, + 'vue/no-multi-spaces': ruleLevel, + 'vue/no-spaces-around-equal-signs-in-attribute': ruleLevel, + 'vue/no-template-shadow': ruleLevel, + 'vue/one-component-per-file': ruleLevel, + 'vue/prop-name-casing': ruleLevel, + 'vue/require-default-prop': ruleLevel, + 'vue/require-explicit-emits': ruleLevel, + 'vue/require-prop-types': ruleLevel, + 'vue/singleline-html-element-content-newline': ruleLevel, + 'vue/v-bind-style': ruleLevel, 'vue/v-on-event-hyphenation': [ - 'warn', + ruleLevel, 'always', { autofix: true } ], - 'vue/v-on-style': 'warn', - 'vue/v-slot-style': 'warn' + 'vue/v-on-style': ruleLevel, + 'vue/v-slot-style': ruleLevel } } From be3db8df23f48673c5b46120d572ebf59f95a0c6 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Tue, 15 Jul 2025 12:54:49 +1200 Subject: [PATCH 03/10] feat: only define variable if it is needed --- tools/update-lib-configs.js | 13 +++++++++---- tools/update-lib-flat-configs.js | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/tools/update-lib-configs.js b/tools/update-lib-configs.js index 384e4ac1d..bebd8691a 100644 --- a/tools/update-lib-configs.js +++ b/tools/update-lib-configs.js @@ -51,13 +51,18 @@ function formatRules(rules, categoryId) { function formatCategory(category) { const extendsCategoryId = extendsCategories[category.categoryId] + const formattedRules = formatRules(category.rules, category.categoryId) + const ruleLevelVariable = formattedRules.includes('ruleLevel') + ? "const ruleLevel = process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn'" + : '' + if (extendsCategoryId == null) { return `/* * IMPORTANT! * This file has been automatically generated, * in order to update its content execute "npm run update" */ -const ruleLevel = process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' +${ruleLevelVariable} module.exports = { parserOptions: { @@ -67,7 +72,7 @@ module.exports = { plugins: [ 'vue' ], - rules: ${formatRules(category.rules, category.categoryId)}, + rules: ${formattedRules}, overrides: [ { files: '*.vue', @@ -82,11 +87,11 @@ module.exports = { * This file has been automatically generated, * in order to update its content execute "npm run update" */ -const ruleLevel = process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' +${ruleLevelVariable} module.exports = { extends: require.resolve('./${extendsCategoryId}'), - rules: ${formatRules(category.rules, category.categoryId)} + rules: ${formattedRules} } ` } diff --git a/tools/update-lib-flat-configs.js b/tools/update-lib-flat-configs.js index 7d81b3842..ef7b136b3 100644 --- a/tools/update-lib-flat-configs.js +++ b/tools/update-lib-flat-configs.js @@ -51,13 +51,18 @@ function formatRules(rules, categoryId) { function formatCategory(category) { const extendsCategoryId = extendsCategories[category.categoryId] + const formattedRules = formatRules(category.rules, category.categoryId) + const ruleLevelVariable = formattedRules.includes('ruleLevel') + ? "const ruleLevel = process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn'" + : '' + if (category.categoryId === 'base') { return `/* * IMPORTANT! * This file has been automatically generated, * in order to update its content execute "npm run update" */ -const ruleLevel = process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' +${ruleLevelVariable} module.exports = [ { @@ -83,7 +88,7 @@ module.exports = [ parser: require('vue-eslint-parser'), sourceType: 'module', }, - rules: ${formatRules(category.rules, category.categoryId)}, + rules: ${formattedRules}, processor: 'vue/vue' } ] @@ -97,13 +102,13 @@ module.exports = [ 'use strict' const config = require('./${extendsCategoryId}.js') -const ruleLevel = process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' +${ruleLevelVariable} module.exports = [ ...config, { name: 'vue/${category.categoryId.replace(/^vue3-/u, '')}/rules', - rules: ${formatRules(category.rules, category.categoryId)}, + rules: ${formattedRules}, } ] ` From 98888a6def05a23e7e3e3f501aaad93bbd111b86 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Tue, 15 Jul 2025 12:56:48 +1200 Subject: [PATCH 04/10] feat: regenerate rules --- lib/configs/base.js | 2 -- lib/configs/flat/base.js | 2 -- lib/configs/flat/vue2-essential.js | 3 --- lib/configs/flat/vue3-essential.js | 3 --- lib/configs/vue2-essential.js | 2 -- lib/configs/vue3-essential.js | 2 -- 6 files changed, 14 deletions(-) diff --git a/lib/configs/base.js b/lib/configs/base.js index 99ad64a2f..2b63dc1f3 100644 --- a/lib/configs/base.js +++ b/lib/configs/base.js @@ -3,8 +3,6 @@ * This file has been automatically generated, * in order to update its content execute "npm run update" */ -const ruleLevel = - process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' module.exports = { parserOptions: { diff --git a/lib/configs/flat/base.js b/lib/configs/flat/base.js index 90ff3ff0b..84957aae4 100644 --- a/lib/configs/flat/base.js +++ b/lib/configs/flat/base.js @@ -3,8 +3,6 @@ * This file has been automatically generated, * in order to update its content execute "npm run update" */ -const ruleLevel = - process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' module.exports = [ { diff --git a/lib/configs/flat/vue2-essential.js b/lib/configs/flat/vue2-essential.js index dd267d0b3..0d0920413 100644 --- a/lib/configs/flat/vue2-essential.js +++ b/lib/configs/flat/vue2-essential.js @@ -6,9 +6,6 @@ 'use strict' const config = require('./base.js') -const ruleLevel = - process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' - module.exports = [ ...config, { diff --git a/lib/configs/flat/vue3-essential.js b/lib/configs/flat/vue3-essential.js index cc2acc613..ff8b5b4a6 100644 --- a/lib/configs/flat/vue3-essential.js +++ b/lib/configs/flat/vue3-essential.js @@ -6,9 +6,6 @@ 'use strict' const config = require('./base.js') -const ruleLevel = - process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' - module.exports = [ ...config, { diff --git a/lib/configs/vue2-essential.js b/lib/configs/vue2-essential.js index 12191cf1d..13b0c5f67 100644 --- a/lib/configs/vue2-essential.js +++ b/lib/configs/vue2-essential.js @@ -3,8 +3,6 @@ * This file has been automatically generated, * in order to update its content execute "npm run update" */ -const ruleLevel = - process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' module.exports = { extends: require.resolve('./base'), diff --git a/lib/configs/vue3-essential.js b/lib/configs/vue3-essential.js index 991dc5a27..da13f0ad2 100644 --- a/lib/configs/vue3-essential.js +++ b/lib/configs/vue3-essential.js @@ -3,8 +3,6 @@ * This file has been automatically generated, * in order to update its content execute "npm run update" */ -const ruleLevel = - process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' module.exports = { extends: require.resolve('./base'), From 3dd94e3907afe6edfc9fa70ccf6c7e0ab188dec6 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Tue, 15 Jul 2025 12:58:21 +1200 Subject: [PATCH 05/10] docs: add note to user guide --- docs/user-guide/index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/user-guide/index.md b/docs/user-guide/index.md index 103471f61..4d8e40b24 100644 --- a/docs/user-guide/index.md +++ b/docs/user-guide/index.md @@ -73,6 +73,8 @@ You can use the following configs by adding them to `eslint.config.js`. :::warning Reporting rules By default, all rules from **base** and **essential** categories report ESLint errors. Other rules - because they're not covering potential bugs in the application - report warnings. What does it mean? By default - nothing, but if you want - you can set up a threshold and break the build after a certain amount of warnings, instead of any. More information [here](https://eslint.org/docs/user-guide/command-line-interface#handling-warnings). + +Alternatively, you can set `process.env.VUE_ESLINT_ALWAYS_ERROR` to `true` in your configuration file to have `error` be used by all rules. ::: #### Specifying Globals (`eslint.config.js`) From d7990e927ca5b4e71007b99055b68df2fc3860e2 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Fri, 1 Aug 2025 08:10:42 +1200 Subject: [PATCH 06/10] fix: avoid unneeded blank line --- lib/configs/base.js | 1 - lib/configs/flat/base.js | 1 - lib/configs/vue2-essential.js | 1 - lib/configs/vue3-essential.js | 1 - tools/update-lib-configs.js | 10 +++------- tools/update-lib-flat-configs.js | 6 ++---- 6 files changed, 5 insertions(+), 15 deletions(-) diff --git a/lib/configs/base.js b/lib/configs/base.js index 2b63dc1f3..c7189fbca 100644 --- a/lib/configs/base.js +++ b/lib/configs/base.js @@ -3,7 +3,6 @@ * This file has been automatically generated, * in order to update its content execute "npm run update" */ - module.exports = { parserOptions: { ecmaVersion: 'latest', diff --git a/lib/configs/flat/base.js b/lib/configs/flat/base.js index 84957aae4..22386f377 100644 --- a/lib/configs/flat/base.js +++ b/lib/configs/flat/base.js @@ -3,7 +3,6 @@ * This file has been automatically generated, * in order to update its content execute "npm run update" */ - module.exports = [ { name: 'vue/base/setup', diff --git a/lib/configs/vue2-essential.js b/lib/configs/vue2-essential.js index 13b0c5f67..e2c66ceba 100644 --- a/lib/configs/vue2-essential.js +++ b/lib/configs/vue2-essential.js @@ -3,7 +3,6 @@ * This file has been automatically generated, * in order to update its content execute "npm run update" */ - module.exports = { extends: require.resolve('./base'), rules: { diff --git a/lib/configs/vue3-essential.js b/lib/configs/vue3-essential.js index da13f0ad2..34b3229b1 100644 --- a/lib/configs/vue3-essential.js +++ b/lib/configs/vue3-essential.js @@ -3,7 +3,6 @@ * This file has been automatically generated, * in order to update its content execute "npm run update" */ - module.exports = { extends: require.resolve('./base'), rules: { diff --git a/tools/update-lib-configs.js b/tools/update-lib-configs.js index bebd8691a..d7e857e50 100644 --- a/tools/update-lib-configs.js +++ b/tools/update-lib-configs.js @@ -53,7 +53,7 @@ function formatCategory(category) { const extendsCategoryId = extendsCategories[category.categoryId] const formattedRules = formatRules(category.rules, category.categoryId) const ruleLevelVariable = formattedRules.includes('ruleLevel') - ? "const ruleLevel = process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn'" + ? "\nconst ruleLevel = process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn'\n" : '' if (extendsCategoryId == null) { @@ -61,9 +61,7 @@ function formatCategory(category) { * IMPORTANT! * This file has been automatically generated, * in order to update its content execute "npm run update" - */ -${ruleLevelVariable} - + */${ruleLevelVariable} module.exports = { parserOptions: { ecmaVersion: 'latest', @@ -86,9 +84,7 @@ module.exports = { * IMPORTANT! * This file has been automatically generated, * in order to update its content execute "npm run update" - */ -${ruleLevelVariable} - + */${ruleLevelVariable} module.exports = { extends: require.resolve('./${extendsCategoryId}'), rules: ${formattedRules} diff --git a/tools/update-lib-flat-configs.js b/tools/update-lib-flat-configs.js index ef7b136b3..6894f00d6 100644 --- a/tools/update-lib-flat-configs.js +++ b/tools/update-lib-flat-configs.js @@ -53,7 +53,7 @@ function formatCategory(category) { const extendsCategoryId = extendsCategories[category.categoryId] const formattedRules = formatRules(category.rules, category.categoryId) const ruleLevelVariable = formattedRules.includes('ruleLevel') - ? "const ruleLevel = process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn'" + ? "\nconst ruleLevel = process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn'\n" : '' if (category.categoryId === 'base') { @@ -61,9 +61,7 @@ function formatCategory(category) { * IMPORTANT! * This file has been automatically generated, * in order to update its content execute "npm run update" - */ -${ruleLevelVariable} - + */${ruleLevelVariable} module.exports = [ { name: 'vue/base/setup', From 1b8f18f4b2c573f585646114c2d953974aea50ba Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Fri, 1 Aug 2025 08:13:33 +1200 Subject: [PATCH 07/10] chore: add changeset entry --- .changeset/brown-eels-care.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/brown-eels-care.md diff --git a/.changeset/brown-eels-care.md b/.changeset/brown-eels-care.md new file mode 100644 index 000000000..6d26027f0 --- /dev/null +++ b/.changeset/brown-eels-care.md @@ -0,0 +1,5 @@ +--- +"eslint-plugin-vue": minor +--- + +Use `error` instead of `warn` in configs when `VUE_ESLINT_ALWAYS_ERROR` env variable is `"true"` From 2929ceb0ca1c64b5b59eb6816b60d0cd3e3195dc Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Fri, 8 Aug 2025 15:49:20 +1200 Subject: [PATCH 08/10] revert: don't use an env variable Revert "feat: support using `error` instead of `warn` for rules in config" This reverts commit efb2832c1be577ec268cedcf773a01924ba95d54. Revert "feat: regenerate configs" This reverts commit a379d772e7a31849c8af25b2a28df13639719346. Revert "feat: only define variable if it is needed" This reverts commit be3db8df23f48673c5b46120d572ebf59f95a0c6. Revert "feat: regenerate rules" This reverts commit 98888a6def05a23e7e3e3f501aaad93bbd111b86. Revert "docs: add note to user guide" This reverts commit 3dd94e3907afe6edfc9fa70ccf6c7e0ab188dec6. Revert "fix: avoid unneeded blank line" This reverts commit d7990e927ca5b4e71007b99055b68df2fc3860e2. --- docs/user-guide/index.md | 2 - lib/configs/flat/vue2-recommended.js | 19 +++---- lib/configs/flat/vue2-strongly-recommended.js | 49 ++++++++--------- lib/configs/flat/vue3-recommended.js | 19 +++---- lib/configs/flat/vue3-strongly-recommended.js | 53 +++++++++---------- lib/configs/vue2-recommended.js | 19 +++---- lib/configs/vue2-strongly-recommended.js | 49 ++++++++--------- lib/configs/vue3-recommended.js | 19 +++---- lib/configs/vue3-strongly-recommended.js | 53 +++++++++---------- tools/update-lib-configs.js | 17 ++---- tools/update-lib-flat-configs.js | 17 ++---- 11 files changed, 137 insertions(+), 179 deletions(-) diff --git a/docs/user-guide/index.md b/docs/user-guide/index.md index 4d8e40b24..103471f61 100644 --- a/docs/user-guide/index.md +++ b/docs/user-guide/index.md @@ -73,8 +73,6 @@ You can use the following configs by adding them to `eslint.config.js`. :::warning Reporting rules By default, all rules from **base** and **essential** categories report ESLint errors. Other rules - because they're not covering potential bugs in the application - report warnings. What does it mean? By default - nothing, but if you want - you can set up a threshold and break the build after a certain amount of warnings, instead of any. More information [here](https://eslint.org/docs/user-guide/command-line-interface#handling-warnings). - -Alternatively, you can set `process.env.VUE_ESLINT_ALWAYS_ERROR` to `true` in your configuration file to have `error` be used by all rules. ::: #### Specifying Globals (`eslint.config.js`) diff --git a/lib/configs/flat/vue2-recommended.js b/lib/configs/flat/vue2-recommended.js index 8dfcec9dd..8a972bf3d 100644 --- a/lib/configs/flat/vue2-recommended.js +++ b/lib/configs/flat/vue2-recommended.js @@ -6,22 +6,19 @@ 'use strict' const config = require('./vue2-strongly-recommended.js') -const ruleLevel = - process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' - module.exports = [ ...config, { name: 'vue/vue2-recommended/rules', rules: { - 'vue/attributes-order': ruleLevel, - 'vue/block-order': ruleLevel, - 'vue/no-lone-template': ruleLevel, - 'vue/no-multiple-slot-args': ruleLevel, - 'vue/no-required-prop-with-default': ruleLevel, - 'vue/no-v-html': ruleLevel, - 'vue/order-in-components': ruleLevel, - 'vue/this-in-template': ruleLevel + 'vue/attributes-order': 'warn', + 'vue/block-order': 'warn', + 'vue/no-lone-template': 'warn', + 'vue/no-multiple-slot-args': 'warn', + 'vue/no-required-prop-with-default': 'warn', + 'vue/no-v-html': 'warn', + 'vue/order-in-components': 'warn', + 'vue/this-in-template': 'warn' } } ] diff --git a/lib/configs/flat/vue2-strongly-recommended.js b/lib/configs/flat/vue2-strongly-recommended.js index d05f5feb6..e4913f40c 100644 --- a/lib/configs/flat/vue2-strongly-recommended.js +++ b/lib/configs/flat/vue2-strongly-recommended.js @@ -6,37 +6,34 @@ 'use strict' const config = require('./vue2-essential.js') -const ruleLevel = - process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' - module.exports = [ ...config, { name: 'vue/vue2-strongly-recommended/rules', rules: { - 'vue/attribute-hyphenation': ruleLevel, - 'vue/component-definition-name-casing': ruleLevel, - 'vue/first-attribute-linebreak': ruleLevel, - 'vue/html-closing-bracket-newline': ruleLevel, - 'vue/html-closing-bracket-spacing': ruleLevel, - 'vue/html-end-tags': ruleLevel, - 'vue/html-indent': ruleLevel, - 'vue/html-quotes': ruleLevel, - 'vue/html-self-closing': ruleLevel, - 'vue/max-attributes-per-line': ruleLevel, - 'vue/multiline-html-element-content-newline': ruleLevel, - 'vue/mustache-interpolation-spacing': ruleLevel, - 'vue/no-multi-spaces': ruleLevel, - 'vue/no-spaces-around-equal-signs-in-attribute': ruleLevel, - 'vue/no-template-shadow': ruleLevel, - 'vue/one-component-per-file': ruleLevel, - 'vue/prop-name-casing': ruleLevel, - 'vue/require-default-prop': ruleLevel, - 'vue/require-prop-types': ruleLevel, - 'vue/singleline-html-element-content-newline': ruleLevel, - 'vue/v-bind-style': ruleLevel, - 'vue/v-on-style': ruleLevel, - 'vue/v-slot-style': ruleLevel + 'vue/attribute-hyphenation': 'warn', + 'vue/component-definition-name-casing': 'warn', + 'vue/first-attribute-linebreak': 'warn', + 'vue/html-closing-bracket-newline': 'warn', + 'vue/html-closing-bracket-spacing': 'warn', + 'vue/html-end-tags': 'warn', + 'vue/html-indent': 'warn', + 'vue/html-quotes': 'warn', + 'vue/html-self-closing': 'warn', + 'vue/max-attributes-per-line': 'warn', + 'vue/multiline-html-element-content-newline': 'warn', + 'vue/mustache-interpolation-spacing': 'warn', + 'vue/no-multi-spaces': 'warn', + 'vue/no-spaces-around-equal-signs-in-attribute': 'warn', + 'vue/no-template-shadow': 'warn', + 'vue/one-component-per-file': 'warn', + 'vue/prop-name-casing': 'warn', + 'vue/require-default-prop': 'warn', + 'vue/require-prop-types': 'warn', + 'vue/singleline-html-element-content-newline': 'warn', + 'vue/v-bind-style': 'warn', + 'vue/v-on-style': 'warn', + 'vue/v-slot-style': 'warn' } } ] diff --git a/lib/configs/flat/vue3-recommended.js b/lib/configs/flat/vue3-recommended.js index f46bc901a..21be71a8d 100644 --- a/lib/configs/flat/vue3-recommended.js +++ b/lib/configs/flat/vue3-recommended.js @@ -6,22 +6,19 @@ 'use strict' const config = require('./vue3-strongly-recommended.js') -const ruleLevel = - process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' - module.exports = [ ...config, { name: 'vue/recommended/rules', rules: { - 'vue/attributes-order': ruleLevel, - 'vue/block-order': ruleLevel, - 'vue/no-lone-template': ruleLevel, - 'vue/no-multiple-slot-args': ruleLevel, - 'vue/no-required-prop-with-default': ruleLevel, - 'vue/no-v-html': ruleLevel, - 'vue/order-in-components': ruleLevel, - 'vue/this-in-template': ruleLevel + 'vue/attributes-order': 'warn', + 'vue/block-order': 'warn', + 'vue/no-lone-template': 'warn', + 'vue/no-multiple-slot-args': 'warn', + 'vue/no-required-prop-with-default': 'warn', + 'vue/no-v-html': 'warn', + 'vue/order-in-components': 'warn', + 'vue/this-in-template': 'warn' } } ] diff --git a/lib/configs/flat/vue3-strongly-recommended.js b/lib/configs/flat/vue3-strongly-recommended.js index 48db1aa90..fee1d3bb8 100644 --- a/lib/configs/flat/vue3-strongly-recommended.js +++ b/lib/configs/flat/vue3-strongly-recommended.js @@ -6,45 +6,42 @@ 'use strict' const config = require('./vue3-essential.js') -const ruleLevel = - process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' - module.exports = [ ...config, { name: 'vue/strongly-recommended/rules', rules: { - 'vue/attribute-hyphenation': ruleLevel, - 'vue/component-definition-name-casing': ruleLevel, - 'vue/first-attribute-linebreak': ruleLevel, - 'vue/html-closing-bracket-newline': ruleLevel, - 'vue/html-closing-bracket-spacing': ruleLevel, - 'vue/html-end-tags': ruleLevel, - 'vue/html-indent': ruleLevel, - 'vue/html-quotes': ruleLevel, - 'vue/html-self-closing': ruleLevel, - 'vue/max-attributes-per-line': ruleLevel, - 'vue/multiline-html-element-content-newline': ruleLevel, - 'vue/mustache-interpolation-spacing': ruleLevel, - 'vue/no-multi-spaces': ruleLevel, - 'vue/no-spaces-around-equal-signs-in-attribute': ruleLevel, - 'vue/no-template-shadow': ruleLevel, - 'vue/one-component-per-file': ruleLevel, - 'vue/prop-name-casing': ruleLevel, - 'vue/require-default-prop': ruleLevel, - 'vue/require-explicit-emits': ruleLevel, - 'vue/require-prop-types': ruleLevel, - 'vue/singleline-html-element-content-newline': ruleLevel, - 'vue/v-bind-style': ruleLevel, + 'vue/attribute-hyphenation': 'warn', + 'vue/component-definition-name-casing': 'warn', + 'vue/first-attribute-linebreak': 'warn', + 'vue/html-closing-bracket-newline': 'warn', + 'vue/html-closing-bracket-spacing': 'warn', + 'vue/html-end-tags': 'warn', + 'vue/html-indent': 'warn', + 'vue/html-quotes': 'warn', + 'vue/html-self-closing': 'warn', + 'vue/max-attributes-per-line': 'warn', + 'vue/multiline-html-element-content-newline': 'warn', + 'vue/mustache-interpolation-spacing': 'warn', + 'vue/no-multi-spaces': 'warn', + 'vue/no-spaces-around-equal-signs-in-attribute': 'warn', + 'vue/no-template-shadow': 'warn', + 'vue/one-component-per-file': 'warn', + 'vue/prop-name-casing': 'warn', + 'vue/require-default-prop': 'warn', + 'vue/require-explicit-emits': 'warn', + 'vue/require-prop-types': 'warn', + 'vue/singleline-html-element-content-newline': 'warn', + 'vue/v-bind-style': 'warn', 'vue/v-on-event-hyphenation': [ - ruleLevel, + 'warn', 'always', { autofix: true } ], - 'vue/v-on-style': ruleLevel, - 'vue/v-slot-style': ruleLevel + 'vue/v-on-style': 'warn', + 'vue/v-slot-style': 'warn' } } ] diff --git a/lib/configs/vue2-recommended.js b/lib/configs/vue2-recommended.js index a9957d27d..9892867c1 100644 --- a/lib/configs/vue2-recommended.js +++ b/lib/configs/vue2-recommended.js @@ -3,19 +3,16 @@ * This file has been automatically generated, * in order to update its content execute "npm run update" */ -const ruleLevel = - process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' - module.exports = { extends: require.resolve('./vue2-strongly-recommended'), rules: { - 'vue/attributes-order': ruleLevel, - 'vue/block-order': ruleLevel, - 'vue/no-lone-template': ruleLevel, - 'vue/no-multiple-slot-args': ruleLevel, - 'vue/no-required-prop-with-default': ruleLevel, - 'vue/no-v-html': ruleLevel, - 'vue/order-in-components': ruleLevel, - 'vue/this-in-template': ruleLevel + 'vue/attributes-order': 'warn', + 'vue/block-order': 'warn', + 'vue/no-lone-template': 'warn', + 'vue/no-multiple-slot-args': 'warn', + 'vue/no-required-prop-with-default': 'warn', + 'vue/no-v-html': 'warn', + 'vue/order-in-components': 'warn', + 'vue/this-in-template': 'warn' } } diff --git a/lib/configs/vue2-strongly-recommended.js b/lib/configs/vue2-strongly-recommended.js index 47ca2ca7f..e7b0f3dc7 100644 --- a/lib/configs/vue2-strongly-recommended.js +++ b/lib/configs/vue2-strongly-recommended.js @@ -3,34 +3,31 @@ * This file has been automatically generated, * in order to update its content execute "npm run update" */ -const ruleLevel = - process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' - module.exports = { extends: require.resolve('./vue2-essential'), rules: { - 'vue/attribute-hyphenation': ruleLevel, - 'vue/component-definition-name-casing': ruleLevel, - 'vue/first-attribute-linebreak': ruleLevel, - 'vue/html-closing-bracket-newline': ruleLevel, - 'vue/html-closing-bracket-spacing': ruleLevel, - 'vue/html-end-tags': ruleLevel, - 'vue/html-indent': ruleLevel, - 'vue/html-quotes': ruleLevel, - 'vue/html-self-closing': ruleLevel, - 'vue/max-attributes-per-line': ruleLevel, - 'vue/multiline-html-element-content-newline': ruleLevel, - 'vue/mustache-interpolation-spacing': ruleLevel, - 'vue/no-multi-spaces': ruleLevel, - 'vue/no-spaces-around-equal-signs-in-attribute': ruleLevel, - 'vue/no-template-shadow': ruleLevel, - 'vue/one-component-per-file': ruleLevel, - 'vue/prop-name-casing': ruleLevel, - 'vue/require-default-prop': ruleLevel, - 'vue/require-prop-types': ruleLevel, - 'vue/singleline-html-element-content-newline': ruleLevel, - 'vue/v-bind-style': ruleLevel, - 'vue/v-on-style': ruleLevel, - 'vue/v-slot-style': ruleLevel + 'vue/attribute-hyphenation': 'warn', + 'vue/component-definition-name-casing': 'warn', + 'vue/first-attribute-linebreak': 'warn', + 'vue/html-closing-bracket-newline': 'warn', + 'vue/html-closing-bracket-spacing': 'warn', + 'vue/html-end-tags': 'warn', + 'vue/html-indent': 'warn', + 'vue/html-quotes': 'warn', + 'vue/html-self-closing': 'warn', + 'vue/max-attributes-per-line': 'warn', + 'vue/multiline-html-element-content-newline': 'warn', + 'vue/mustache-interpolation-spacing': 'warn', + 'vue/no-multi-spaces': 'warn', + 'vue/no-spaces-around-equal-signs-in-attribute': 'warn', + 'vue/no-template-shadow': 'warn', + 'vue/one-component-per-file': 'warn', + 'vue/prop-name-casing': 'warn', + 'vue/require-default-prop': 'warn', + 'vue/require-prop-types': 'warn', + 'vue/singleline-html-element-content-newline': 'warn', + 'vue/v-bind-style': 'warn', + 'vue/v-on-style': 'warn', + 'vue/v-slot-style': 'warn' } } diff --git a/lib/configs/vue3-recommended.js b/lib/configs/vue3-recommended.js index 1346a6da3..083f6c65b 100644 --- a/lib/configs/vue3-recommended.js +++ b/lib/configs/vue3-recommended.js @@ -3,19 +3,16 @@ * This file has been automatically generated, * in order to update its content execute "npm run update" */ -const ruleLevel = - process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' - module.exports = { extends: require.resolve('./vue3-strongly-recommended'), rules: { - 'vue/attributes-order': ruleLevel, - 'vue/block-order': ruleLevel, - 'vue/no-lone-template': ruleLevel, - 'vue/no-multiple-slot-args': ruleLevel, - 'vue/no-required-prop-with-default': ruleLevel, - 'vue/no-v-html': ruleLevel, - 'vue/order-in-components': ruleLevel, - 'vue/this-in-template': ruleLevel + 'vue/attributes-order': 'warn', + 'vue/block-order': 'warn', + 'vue/no-lone-template': 'warn', + 'vue/no-multiple-slot-args': 'warn', + 'vue/no-required-prop-with-default': 'warn', + 'vue/no-v-html': 'warn', + 'vue/order-in-components': 'warn', + 'vue/this-in-template': 'warn' } } diff --git a/lib/configs/vue3-strongly-recommended.js b/lib/configs/vue3-strongly-recommended.js index 6b984eb4f..a3f854fc4 100644 --- a/lib/configs/vue3-strongly-recommended.js +++ b/lib/configs/vue3-strongly-recommended.js @@ -3,42 +3,39 @@ * This file has been automatically generated, * in order to update its content execute "npm run update" */ -const ruleLevel = - process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn' - module.exports = { extends: require.resolve('./vue3-essential'), rules: { - 'vue/attribute-hyphenation': ruleLevel, - 'vue/component-definition-name-casing': ruleLevel, - 'vue/first-attribute-linebreak': ruleLevel, - 'vue/html-closing-bracket-newline': ruleLevel, - 'vue/html-closing-bracket-spacing': ruleLevel, - 'vue/html-end-tags': ruleLevel, - 'vue/html-indent': ruleLevel, - 'vue/html-quotes': ruleLevel, - 'vue/html-self-closing': ruleLevel, - 'vue/max-attributes-per-line': ruleLevel, - 'vue/multiline-html-element-content-newline': ruleLevel, - 'vue/mustache-interpolation-spacing': ruleLevel, - 'vue/no-multi-spaces': ruleLevel, - 'vue/no-spaces-around-equal-signs-in-attribute': ruleLevel, - 'vue/no-template-shadow': ruleLevel, - 'vue/one-component-per-file': ruleLevel, - 'vue/prop-name-casing': ruleLevel, - 'vue/require-default-prop': ruleLevel, - 'vue/require-explicit-emits': ruleLevel, - 'vue/require-prop-types': ruleLevel, - 'vue/singleline-html-element-content-newline': ruleLevel, - 'vue/v-bind-style': ruleLevel, + 'vue/attribute-hyphenation': 'warn', + 'vue/component-definition-name-casing': 'warn', + 'vue/first-attribute-linebreak': 'warn', + 'vue/html-closing-bracket-newline': 'warn', + 'vue/html-closing-bracket-spacing': 'warn', + 'vue/html-end-tags': 'warn', + 'vue/html-indent': 'warn', + 'vue/html-quotes': 'warn', + 'vue/html-self-closing': 'warn', + 'vue/max-attributes-per-line': 'warn', + 'vue/multiline-html-element-content-newline': 'warn', + 'vue/mustache-interpolation-spacing': 'warn', + 'vue/no-multi-spaces': 'warn', + 'vue/no-spaces-around-equal-signs-in-attribute': 'warn', + 'vue/no-template-shadow': 'warn', + 'vue/one-component-per-file': 'warn', + 'vue/prop-name-casing': 'warn', + 'vue/require-default-prop': 'warn', + 'vue/require-explicit-emits': 'warn', + 'vue/require-prop-types': 'warn', + 'vue/singleline-html-element-content-newline': 'warn', + 'vue/v-bind-style': 'warn', 'vue/v-on-event-hyphenation': [ - ruleLevel, + 'warn', 'always', { autofix: true } ], - 'vue/v-on-style': ruleLevel, - 'vue/v-slot-style': ruleLevel + 'vue/v-on-style': 'warn', + 'vue/v-slot-style': 'warn' } } diff --git a/tools/update-lib-configs.js b/tools/update-lib-configs.js index d7e857e50..0c2845e45 100644 --- a/tools/update-lib-configs.js +++ b/tools/update-lib-configs.js @@ -44,24 +44,17 @@ function formatRules(rules, categoryId) { return [rule.ruleId, options] }) ) - // use the ruleLevel variable for rules set to warn so that they can - // be made to error with an env variable if desired - return JSON.stringify(obj, null, 2).replaceAll('"warn"', 'ruleLevel') + return JSON.stringify(obj, null, 2) } function formatCategory(category) { const extendsCategoryId = extendsCategories[category.categoryId] - const formattedRules = formatRules(category.rules, category.categoryId) - const ruleLevelVariable = formattedRules.includes('ruleLevel') - ? "\nconst ruleLevel = process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn'\n" - : '' - if (extendsCategoryId == null) { return `/* * IMPORTANT! * This file has been automatically generated, * in order to update its content execute "npm run update" - */${ruleLevelVariable} + */ module.exports = { parserOptions: { ecmaVersion: 'latest', @@ -70,7 +63,7 @@ module.exports = { plugins: [ 'vue' ], - rules: ${formattedRules}, + rules: ${formatRules(category.rules, category.categoryId)}, overrides: [ { files: '*.vue', @@ -84,10 +77,10 @@ module.exports = { * IMPORTANT! * This file has been automatically generated, * in order to update its content execute "npm run update" - */${ruleLevelVariable} + */ module.exports = { extends: require.resolve('./${extendsCategoryId}'), - rules: ${formattedRules} + rules: ${formatRules(category.rules, category.categoryId)} } ` } diff --git a/tools/update-lib-flat-configs.js b/tools/update-lib-flat-configs.js index 6894f00d6..e55fb2d01 100644 --- a/tools/update-lib-flat-configs.js +++ b/tools/update-lib-flat-configs.js @@ -44,24 +44,17 @@ function formatRules(rules, categoryId) { return [rule.ruleId, options] }) ) - // use the ruleLevel variable for rules set to warn so that they can - // be made to error with an env variable if desired - return JSON.stringify(obj, null, 2).replaceAll('"warn"', 'ruleLevel') + return JSON.stringify(obj, null, 2) } function formatCategory(category) { const extendsCategoryId = extendsCategories[category.categoryId] - const formattedRules = formatRules(category.rules, category.categoryId) - const ruleLevelVariable = formattedRules.includes('ruleLevel') - ? "\nconst ruleLevel = process.env.VUE_ESLINT_ALWAYS_ERROR === 'true' ? 'error' : 'warn'\n" - : '' - if (category.categoryId === 'base') { return `/* * IMPORTANT! * This file has been automatically generated, * in order to update its content execute "npm run update" - */${ruleLevelVariable} + */ module.exports = [ { name: 'vue/base/setup', @@ -86,7 +79,7 @@ module.exports = [ parser: require('vue-eslint-parser'), sourceType: 'module', }, - rules: ${formattedRules}, + rules: ${formatRules(category.rules, category.categoryId)}, processor: 'vue/vue' } ] @@ -100,13 +93,11 @@ module.exports = [ 'use strict' const config = require('./${extendsCategoryId}.js') -${ruleLevelVariable} - module.exports = [ ...config, { name: 'vue/${category.categoryId.replace(/^vue3-/u, '')}/rules', - rules: ${formattedRules}, + rules: ${formatRules(category.rules, category.categoryId)}, } ] ` From 3825a4016493acb5a55cdace080660e3c057814c Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Fri, 8 Aug 2025 16:15:49 +1200 Subject: [PATCH 09/10] feat: generate new error-based configs --- lib/configs/flat/vue2-recommended-error.js | 24 ++++++++++ .../flat/vue2-strongly-recommended-error.js | 39 +++++++++++++++ lib/configs/flat/vue3-recommended-error.js | 24 ++++++++++ .../flat/vue3-strongly-recommended-error.js | 47 +++++++++++++++++++ lib/configs/vue2-recommended-error.js | 18 +++++++ .../vue2-strongly-recommended-error.js | 33 +++++++++++++ lib/configs/vue3-recommended-error.js | 18 +++++++ .../vue3-strongly-recommended-error.js | 41 ++++++++++++++++ tools/update-lib-configs.js | 32 ++++++++++--- tools/update-lib-flat-configs.js | 34 +++++++++++--- 10 files changed, 298 insertions(+), 12 deletions(-) create mode 100644 lib/configs/flat/vue2-recommended-error.js create mode 100644 lib/configs/flat/vue2-strongly-recommended-error.js create mode 100644 lib/configs/flat/vue3-recommended-error.js create mode 100644 lib/configs/flat/vue3-strongly-recommended-error.js create mode 100644 lib/configs/vue2-recommended-error.js create mode 100644 lib/configs/vue2-strongly-recommended-error.js create mode 100644 lib/configs/vue3-recommended-error.js create mode 100644 lib/configs/vue3-strongly-recommended-error.js diff --git a/lib/configs/flat/vue2-recommended-error.js b/lib/configs/flat/vue2-recommended-error.js new file mode 100644 index 000000000..f9bc69c0a --- /dev/null +++ b/lib/configs/flat/vue2-recommended-error.js @@ -0,0 +1,24 @@ +/* + * IMPORTANT! + * This file has been automatically generated, + * in order to update its content execute "npm run update" + */ +'use strict' +const config = require('./vue2-strongly-recommended-error.js') + +module.exports = [ + ...config, + { + name: 'vue/vue2-recommended/rules', + rules: { + 'vue/attributes-order': 'error', + 'vue/block-order': 'error', + 'vue/no-lone-template': 'error', + 'vue/no-multiple-slot-args': 'error', + 'vue/no-required-prop-with-default': 'error', + 'vue/no-v-html': 'error', + 'vue/order-in-components': 'error', + 'vue/this-in-template': 'error' + } + } +] diff --git a/lib/configs/flat/vue2-strongly-recommended-error.js b/lib/configs/flat/vue2-strongly-recommended-error.js new file mode 100644 index 000000000..176afa681 --- /dev/null +++ b/lib/configs/flat/vue2-strongly-recommended-error.js @@ -0,0 +1,39 @@ +/* + * IMPORTANT! + * This file has been automatically generated, + * in order to update its content execute "npm run update" + */ +'use strict' +const config = require('./vue2-essential.js') + +module.exports = [ + ...config, + { + name: 'vue/vue2-strongly-recommended/rules', + rules: { + 'vue/attribute-hyphenation': 'error', + 'vue/component-definition-name-casing': 'error', + 'vue/first-attribute-linebreak': 'error', + 'vue/html-closing-bracket-newline': 'error', + 'vue/html-closing-bracket-spacing': 'error', + 'vue/html-end-tags': 'error', + 'vue/html-indent': 'error', + 'vue/html-quotes': 'error', + 'vue/html-self-closing': 'error', + 'vue/max-attributes-per-line': 'error', + 'vue/multiline-html-element-content-newline': 'error', + 'vue/mustache-interpolation-spacing': 'error', + 'vue/no-multi-spaces': 'error', + 'vue/no-spaces-around-equal-signs-in-attribute': 'error', + 'vue/no-template-shadow': 'error', + 'vue/one-component-per-file': 'error', + 'vue/prop-name-casing': 'error', + 'vue/require-default-prop': 'error', + 'vue/require-prop-types': 'error', + 'vue/singleline-html-element-content-newline': 'error', + 'vue/v-bind-style': 'error', + 'vue/v-on-style': 'error', + 'vue/v-slot-style': 'error' + } + } +] diff --git a/lib/configs/flat/vue3-recommended-error.js b/lib/configs/flat/vue3-recommended-error.js new file mode 100644 index 000000000..232e6b838 --- /dev/null +++ b/lib/configs/flat/vue3-recommended-error.js @@ -0,0 +1,24 @@ +/* + * IMPORTANT! + * This file has been automatically generated, + * in order to update its content execute "npm run update" + */ +'use strict' +const config = require('./vue3-strongly-recommended-error.js') + +module.exports = [ + ...config, + { + name: 'vue/recommended/rules', + rules: { + 'vue/attributes-order': 'error', + 'vue/block-order': 'error', + 'vue/no-lone-template': 'error', + 'vue/no-multiple-slot-args': 'error', + 'vue/no-required-prop-with-default': 'error', + 'vue/no-v-html': 'error', + 'vue/order-in-components': 'error', + 'vue/this-in-template': 'error' + } + } +] diff --git a/lib/configs/flat/vue3-strongly-recommended-error.js b/lib/configs/flat/vue3-strongly-recommended-error.js new file mode 100644 index 000000000..883fc5501 --- /dev/null +++ b/lib/configs/flat/vue3-strongly-recommended-error.js @@ -0,0 +1,47 @@ +/* + * IMPORTANT! + * This file has been automatically generated, + * in order to update its content execute "npm run update" + */ +'use strict' +const config = require('./vue3-essential.js') + +module.exports = [ + ...config, + { + name: 'vue/strongly-recommended/rules', + rules: { + 'vue/attribute-hyphenation': 'error', + 'vue/component-definition-name-casing': 'error', + 'vue/first-attribute-linebreak': 'error', + 'vue/html-closing-bracket-newline': 'error', + 'vue/html-closing-bracket-spacing': 'error', + 'vue/html-end-tags': 'error', + 'vue/html-indent': 'error', + 'vue/html-quotes': 'error', + 'vue/html-self-closing': 'error', + 'vue/max-attributes-per-line': 'error', + 'vue/multiline-html-element-content-newline': 'error', + 'vue/mustache-interpolation-spacing': 'error', + 'vue/no-multi-spaces': 'error', + 'vue/no-spaces-around-equal-signs-in-attribute': 'error', + 'vue/no-template-shadow': 'error', + 'vue/one-component-per-file': 'error', + 'vue/prop-name-casing': 'error', + 'vue/require-default-prop': 'error', + 'vue/require-explicit-emits': 'error', + 'vue/require-prop-types': 'error', + 'vue/singleline-html-element-content-newline': 'error', + 'vue/v-bind-style': 'error', + 'vue/v-on-event-hyphenation': [ + 'error', + 'always', + { + autofix: true + } + ], + 'vue/v-on-style': 'error', + 'vue/v-slot-style': 'error' + } + } +] diff --git a/lib/configs/vue2-recommended-error.js b/lib/configs/vue2-recommended-error.js new file mode 100644 index 000000000..eb7c624fd --- /dev/null +++ b/lib/configs/vue2-recommended-error.js @@ -0,0 +1,18 @@ +/* + * IMPORTANT! + * This file has been automatically generated, + * in order to update its content execute "npm run update" + */ +module.exports = { + extends: require.resolve('./vue2-strongly-recommended-error'), + rules: { + 'vue/attributes-order': 'error', + 'vue/block-order': 'error', + 'vue/no-lone-template': 'error', + 'vue/no-multiple-slot-args': 'error', + 'vue/no-required-prop-with-default': 'error', + 'vue/no-v-html': 'error', + 'vue/order-in-components': 'error', + 'vue/this-in-template': 'error' + } +} diff --git a/lib/configs/vue2-strongly-recommended-error.js b/lib/configs/vue2-strongly-recommended-error.js new file mode 100644 index 000000000..482914c8c --- /dev/null +++ b/lib/configs/vue2-strongly-recommended-error.js @@ -0,0 +1,33 @@ +/* + * IMPORTANT! + * This file has been automatically generated, + * in order to update its content execute "npm run update" + */ +module.exports = { + extends: require.resolve('./vue2-essential'), + rules: { + 'vue/attribute-hyphenation': 'error', + 'vue/component-definition-name-casing': 'error', + 'vue/first-attribute-linebreak': 'error', + 'vue/html-closing-bracket-newline': 'error', + 'vue/html-closing-bracket-spacing': 'error', + 'vue/html-end-tags': 'error', + 'vue/html-indent': 'error', + 'vue/html-quotes': 'error', + 'vue/html-self-closing': 'error', + 'vue/max-attributes-per-line': 'error', + 'vue/multiline-html-element-content-newline': 'error', + 'vue/mustache-interpolation-spacing': 'error', + 'vue/no-multi-spaces': 'error', + 'vue/no-spaces-around-equal-signs-in-attribute': 'error', + 'vue/no-template-shadow': 'error', + 'vue/one-component-per-file': 'error', + 'vue/prop-name-casing': 'error', + 'vue/require-default-prop': 'error', + 'vue/require-prop-types': 'error', + 'vue/singleline-html-element-content-newline': 'error', + 'vue/v-bind-style': 'error', + 'vue/v-on-style': 'error', + 'vue/v-slot-style': 'error' + } +} diff --git a/lib/configs/vue3-recommended-error.js b/lib/configs/vue3-recommended-error.js new file mode 100644 index 000000000..23a3c21a2 --- /dev/null +++ b/lib/configs/vue3-recommended-error.js @@ -0,0 +1,18 @@ +/* + * IMPORTANT! + * This file has been automatically generated, + * in order to update its content execute "npm run update" + */ +module.exports = { + extends: require.resolve('./vue3-strongly-recommended-error'), + rules: { + 'vue/attributes-order': 'error', + 'vue/block-order': 'error', + 'vue/no-lone-template': 'error', + 'vue/no-multiple-slot-args': 'error', + 'vue/no-required-prop-with-default': 'error', + 'vue/no-v-html': 'error', + 'vue/order-in-components': 'error', + 'vue/this-in-template': 'error' + } +} diff --git a/lib/configs/vue3-strongly-recommended-error.js b/lib/configs/vue3-strongly-recommended-error.js new file mode 100644 index 000000000..b48e0deec --- /dev/null +++ b/lib/configs/vue3-strongly-recommended-error.js @@ -0,0 +1,41 @@ +/* + * IMPORTANT! + * This file has been automatically generated, + * in order to update its content execute "npm run update" + */ +module.exports = { + extends: require.resolve('./vue3-essential'), + rules: { + 'vue/attribute-hyphenation': 'error', + 'vue/component-definition-name-casing': 'error', + 'vue/first-attribute-linebreak': 'error', + 'vue/html-closing-bracket-newline': 'error', + 'vue/html-closing-bracket-spacing': 'error', + 'vue/html-end-tags': 'error', + 'vue/html-indent': 'error', + 'vue/html-quotes': 'error', + 'vue/html-self-closing': 'error', + 'vue/max-attributes-per-line': 'error', + 'vue/multiline-html-element-content-newline': 'error', + 'vue/mustache-interpolation-spacing': 'error', + 'vue/no-multi-spaces': 'error', + 'vue/no-spaces-around-equal-signs-in-attribute': 'error', + 'vue/no-template-shadow': 'error', + 'vue/one-component-per-file': 'error', + 'vue/prop-name-casing': 'error', + 'vue/require-default-prop': 'error', + 'vue/require-explicit-emits': 'error', + 'vue/require-prop-types': 'error', + 'vue/singleline-html-element-content-newline': 'error', + 'vue/v-bind-style': 'error', + 'vue/v-on-event-hyphenation': [ + 'error', + 'always', + { + autofix: true + } + ], + 'vue/v-on-style': 'error', + 'vue/v-slot-style': 'error' + } +} diff --git a/tools/update-lib-configs.js b/tools/update-lib-configs.js index 0c2845e45..a97f19cd2 100644 --- a/tools/update-lib-configs.js +++ b/tools/update-lib-configs.js @@ -28,10 +28,11 @@ const extendsCategories = { 'vue3-use-with-caution': 'vue3-recommended' } -function formatRules(rules, categoryId) { +function formatRules(rules, categoryId, alwaysError) { const obj = Object.fromEntries( rules.map((rule) => { - let options = errorCategories.has(categoryId) ? 'error' : 'warn' + let options = + alwaysError || errorCategories.has(categoryId) ? 'error' : 'warn' const defaultOptions = rule.meta && rule.meta.docs && rule.meta.docs.defaultOptions if (defaultOptions) { @@ -47,8 +48,16 @@ function formatRules(rules, categoryId) { return JSON.stringify(obj, null, 2) } -function formatCategory(category) { - const extendsCategoryId = extendsCategories[category.categoryId] +function hasWarningRules(categoryId) { + return ( + categoryId !== 'base' && + categoryId !== 'vue3-essential' && + categoryId !== 'vue2-essential' + ) +} + +function formatCategory(category, alwaysError = false) { + let extendsCategoryId = extendsCategories[category.categoryId] if (extendsCategoryId == null) { return `/* * IMPORTANT! @@ -63,7 +72,7 @@ module.exports = { plugins: [ 'vue' ], - rules: ${formatRules(category.rules, category.categoryId)}, + rules: ${formatRules(category.rules, category.categoryId, alwaysError)}, overrides: [ { files: '*.vue', @@ -73,6 +82,10 @@ module.exports = { } ` } + if (alwaysError && hasWarningRules(extendsCategoryId)) { + extendsCategoryId += '-error' + } + return `/* * IMPORTANT! * This file has been automatically generated, @@ -80,7 +93,7 @@ module.exports = { */ module.exports = { extends: require.resolve('./${extendsCategoryId}'), - rules: ${formatRules(category.rules, category.categoryId)} + rules: ${formatRules(category.rules, category.categoryId, alwaysError)} } ` } @@ -92,6 +105,13 @@ for (const category of categories) { const content = formatCategory(category) fs.writeFileSync(filePath, content) + + if (hasWarningRules(category.categoryId)) { + fs.writeFileSync( + path.join(ROOT, `${category.categoryId}-error.js`), + formatCategory(category, true) + ) + } } // Format files. diff --git a/tools/update-lib-flat-configs.js b/tools/update-lib-flat-configs.js index e55fb2d01..619f72653 100644 --- a/tools/update-lib-flat-configs.js +++ b/tools/update-lib-flat-configs.js @@ -28,10 +28,11 @@ const extendsCategories = { 'vue3-use-with-caution': 'vue3-recommended' } -function formatRules(rules, categoryId) { +function formatRules(rules, categoryId, alwaysError) { const obj = Object.fromEntries( rules.map((rule) => { - let options = errorCategories.has(categoryId) ? 'error' : 'warn' + let options = + alwaysError || errorCategories.has(categoryId) ? 'error' : 'warn' const defaultOptions = rule.meta && rule.meta.docs && rule.meta.docs.defaultOptions if (defaultOptions) { @@ -47,8 +48,17 @@ function formatRules(rules, categoryId) { return JSON.stringify(obj, null, 2) } -function formatCategory(category) { - const extendsCategoryId = extendsCategories[category.categoryId] +function hasWarningRules(categoryId) { + return ( + categoryId !== 'base' && + categoryId !== 'vue3-essential' && + categoryId !== 'vue2-essential' + ) +} + +function formatCategory(category, alwaysError = false) { + let extendsCategoryId = extendsCategories[category.categoryId] + if (category.categoryId === 'base') { return `/* * IMPORTANT! @@ -79,12 +89,17 @@ module.exports = [ parser: require('vue-eslint-parser'), sourceType: 'module', }, - rules: ${formatRules(category.rules, category.categoryId)}, + rules: ${formatRules(category.rules, category.categoryId, alwaysError)}, processor: 'vue/vue' } ] ` } + + if (alwaysError && hasWarningRules(extendsCategoryId)) { + extendsCategoryId += '-error' + } + return `/* * IMPORTANT! * This file has been automatically generated, @@ -97,7 +112,7 @@ module.exports = [ ...config, { name: 'vue/${category.categoryId.replace(/^vue3-/u, '')}/rules', - rules: ${formatRules(category.rules, category.categoryId)}, + rules: ${formatRules(category.rules, category.categoryId, alwaysError)}, } ] ` @@ -110,6 +125,13 @@ for (const category of categories) { const content = formatCategory(category) fs.writeFileSync(filePath, content) + + if (hasWarningRules(category.categoryId)) { + fs.writeFileSync( + path.join(ROOT, `${category.categoryId}-error.js`), + formatCategory(category, true) + ) + } } // Format files. From 168cf660a88bc51b1e92049cf6e5ac439336fbde Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Fri, 8 Aug 2025 16:32:36 +1200 Subject: [PATCH 10/10] docs: update documentation --- docs/user-guide/index.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/user-guide/index.md b/docs/user-guide/index.md index 103471f61..85acc40b9 100644 --- a/docs/user-guide/index.md +++ b/docs/user-guide/index.md @@ -187,14 +187,20 @@ You can use the following configs by adding them to `extends`. - Configurations for using Vue.js 3.x: - `"plugin:vue/essential"` ... `base`, plus rules to prevent errors or unintended behavior. - `"plugin:vue/strongly-recommended"` ... Above, plus rules to considerably improve code readability and/or dev experience. + - `"plugin:vue/strongly-recommended-error"` ... Above, except with all rules configured to error instead of warn. - `"plugin:vue/recommended"` ... Above, plus rules to enforce subjective community defaults to ensure consistency. + - `"plugin:vue/recommended-error"` ... Above, except with all rules configured to error instead of warn. - Configurations for using Vue.js 2.x: - `"plugin:vue/vue2-essential"` ... `base`, plus rules to prevent errors or unintended behavior. - `"plugin:vue/vue2-strongly-recommended"` ... Above, plus rules to considerably improve code readability and/or dev experience. + - `"plugin:vue/vue2-strongly-recommended-error"` ... Above, except with all rules configured to error instead of warn. - `"plugin:vue/vue2-recommended"` ... Above, plus rules to enforce subjective community defaults to ensure consistency. + - `"plugin:vue/vue2-recommended-error"` ... Above, except with all rules configured to error instead of warn. :::warning Reporting rules By default, all rules from **base** and **essential** categories report ESLint errors. Other rules - because they're not covering potential bugs in the application - report warnings. What does it mean? By default - nothing, but if you want - you can set up a threshold and break the build after a certain amount of warnings, instead of any. More information [here](https://eslint.org/docs/user-guide/command-line-interface#handling-warnings). + +Alternatively, there are versions of the configs with all rules set to error suffixed with `-error` that you can use. ::: :::warning Status of Vue.js 3.x supports