From c2fdfc4a6240370f1e4ee1b037371e0a133760b2 Mon Sep 17 00:00:00 2001 From: dalaoshu Date: Fri, 31 Jan 2025 11:47:45 +0800 Subject: [PATCH] refactor(linter): correctly handle loose options for `eslint/eqeqeq` (#8798) Related to #8790 For the configuration `"eqeqeq": ["warn", "alw", { "null": "ignore" }]`, we should default `"alw"` to `"always"` and correctly handle the option `{ "null": "ignore" }`. --- crates/oxc_linter/src/rules/eslint/eqeqeq.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/oxc_linter/src/rules/eslint/eqeqeq.rs b/crates/oxc_linter/src/rules/eslint/eqeqeq.rs index 265edce0c4580..804320c40271d 100644 --- a/crates/oxc_linter/src/rules/eslint/eqeqeq.rs +++ b/crates/oxc_linter/src/rules/eslint/eqeqeq.rs @@ -42,7 +42,7 @@ declare_oxc_lint!( impl Rule for Eqeqeq { fn from_configuration(value: serde_json::Value) -> Self { - let first_arg = value.get(0).and_then(serde_json::Value::as_str).map(CompareType::from); + let first_arg = value.get(0).and_then(serde_json::Value::as_str); let null_type = value .get(usize::from(first_arg.is_some())) @@ -51,7 +51,7 @@ impl Rule for Eqeqeq { .map(NullType::from) .unwrap_or_default(); - let compare_type = first_arg.unwrap_or_default(); + let compare_type = first_arg.map(CompareType::from).unwrap_or_default(); Self { compare_type, null_type } }