From fe7ad105c35bc0b1d591baf22a99e2fa0b2d94db 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 1/5] 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 ae3feb1f2ce7e192d74985c8090076db78e5fd98 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 2/5] 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 b723efa6fcb6e87926461859db5d88b148569b9f 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 3/5] 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 371d402f3968536db2581393744f4c6aa7023fbc 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 4/5] 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 0e94e6dda9fb3a3400ab626959165ab8e8c75ad7 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 5/5] 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`)