Skip to content

Commit 0aeaedd

Browse files
authored
refactor(linter): support loose options for eslint/eqeqeq (#8790)
closes #8773
1 parent d4eee50 commit 0aeaedd

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

crates/oxc_linter/src/rules/eslint/eqeqeq.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,18 @@ declare_oxc_lint!(
4242

4343
impl Rule for Eqeqeq {
4444
fn from_configuration(value: serde_json::Value) -> Self {
45-
let obj1 = value.get(0);
46-
let obj2 = value.get(1);
45+
let first_arg = value.get(0).and_then(serde_json::Value::as_str).map(CompareType::from);
4746

48-
Self {
49-
compare_type: obj1
50-
.and_then(serde_json::Value::as_str)
51-
.map(CompareType::from)
52-
.unwrap_or_default(),
53-
null_type: obj2
54-
.and_then(|v| v.get("null"))
55-
.and_then(serde_json::Value::as_str)
56-
.map(NullType::from)
57-
.unwrap_or_default(),
58-
}
47+
let null_type = value
48+
.get(usize::from(first_arg.is_some()))
49+
.and_then(|v| v.get("null"))
50+
.and_then(serde_json::Value::as_str)
51+
.map(NullType::from)
52+
.unwrap_or_default();
53+
54+
let compare_type = first_arg.unwrap_or_default();
55+
56+
Self { compare_type, null_type }
5957
}
6058

6159
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
@@ -227,6 +225,8 @@ fn test() {
227225
("null == null", Some(json!(["always", {"null": "never"}]))),
228226
// Do not apply this rule to `null`.
229227
("null == null", Some(json!(["smart", {"null": "ignore"}]))),
228+
// Issue: <https://github.com/oxc-project/oxc/issues/8773>
229+
("href != null", Some(json!([{"null": "ignore"}]))),
230230
];
231231

232232
let fail = vec![

0 commit comments

Comments
 (0)