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" }`.
This commit is contained in:
dalaoshu 2025-01-31 11:47:45 +08:00 committed by GitHub
parent b3bf205c3d
commit c2fdfc4a62
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 }
}