From f4e52b991c19f8e1f515383c792effd72838ded8 Mon Sep 17 00:00:00 2001 From: Guz013 <43732358+Guz013@users.noreply.github.com> Date: Mon, 4 Sep 2023 17:12:43 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20`default`=20variant=20for?= =?UTF-8?q?=20the=20configs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/shy-steaks-report.md | 5 +++++ configs/js/src/configs/index.d.ts | 13 +++++++++++++ configs/js/src/lib/rule-variations.js | 7 ++++++- configs/js/src/presets/recommended.js | 12 ++++++------ configs/js/src/presets/strict.js | 12 ++++++------ 5 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 .changeset/shy-steaks-report.md diff --git a/.changeset/shy-steaks-report.md b/.changeset/shy-steaks-report.md new file mode 100644 index 0000000..ea867cb --- /dev/null +++ b/.changeset/shy-steaks-report.md @@ -0,0 +1,5 @@ +--- +"@eslegant/js": minor +--- + +Configs now export a `default` variation, where rule leves aren't overriden. diff --git a/configs/js/src/configs/index.d.ts b/configs/js/src/configs/index.d.ts index 0e2f2b3..da32f2f 100644 --- a/configs/js/src/configs/index.d.ts +++ b/configs/js/src/configs/index.d.ts @@ -9,6 +9,19 @@ import type { Linter } from 'eslint'; interface ConfigVariations { + /** + * @summary + * Enable rules with the predefined levels of the package. + * @description + * Most of the rules in ESLegant are on `error` level. This + * was preferred so it is harder to ignore them. But it has + * some small exceptions where rules will be at `warn` level, + * being more as a "reminder" than a actual rule. + * + * If you want to **every** rule in the config to have an + * `error` or `warn` level, you can use the other variants. + */ + default: Linter.FlatConfig, /** * @description * Enable all rules with `error` level. diff --git a/configs/js/src/lib/rule-variations.js b/configs/js/src/lib/rule-variations.js index 076e4a1..382820b 100644 --- a/configs/js/src/lib/rule-variations.js +++ b/configs/js/src/lib/rule-variations.js @@ -91,7 +91,12 @@ function createVariations(config) { ), }; - return { error: configError, off: configDisabled, warn: configWarning }; + return { + default: config, + error: configError, + off: configDisabled, + warn: configWarning, + }; } export { createVariations, iterateRules }; diff --git a/configs/js/src/presets/recommended.js b/configs/js/src/presets/recommended.js index 78b561b..dd02165 100644 --- a/configs/js/src/presets/recommended.js +++ b/configs/js/src/presets/recommended.js @@ -12,11 +12,11 @@ import configs from '../configs/index.js'; /** @type {import('eslint').Linter.FlatConfig[]} */ const recommended = [ configs.core, - configs.problems.recommended.error, - configs.suggestions.recommended.error, - configs['suggestions-typescript'].recommended.error, - configs.formatting.recommended.error, - configs.naming.recommended.error, - configs.documentation.recommended.error, + configs.problems.recommended.default, + configs.suggestions.recommended.default, + configs['suggestions-typescript'].recommended.default, + configs.formatting.recommended.default, + configs.naming.recommended.default, + configs.documentation.recommended.default, ]; export default recommended; diff --git a/configs/js/src/presets/strict.js b/configs/js/src/presets/strict.js index 1e752df..2534742 100644 --- a/configs/js/src/presets/strict.js +++ b/configs/js/src/presets/strict.js @@ -12,11 +12,11 @@ import configs from '../configs/index.js'; /** @type {import('eslint').Linter.FlatConfig[]} */ const strict = [ configs.core, - configs.problems.strict.error, - configs.suggestions.strict.error, - configs['suggestions-typescript'].strict.error, - configs.formatting.strict.error, - configs.naming.strict.error, - configs.documentation.recommended.error, + configs.problems.strict.default, + configs.suggestions.strict.default, + configs['suggestions-typescript'].strict.default, + configs.formatting.strict.default, + configs.naming.strict.default, + configs.documentation.recommended.default, ]; export default strict;