Skip to content

Commit

Permalink
refactor(linter): support loose options for eslint/eqeqeq (#8790)
Browse files Browse the repository at this point in the history
closes #8773
  • Loading branch information
shulaoda authored Jan 31, 2025
1 parent d4eee50 commit 0aeaedd
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions crates/oxc_linter/src/rules/eslint/eqeqeq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,18 @@ declare_oxc_lint!(

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

Self {
compare_type: obj1
.and_then(serde_json::Value::as_str)
.map(CompareType::from)
.unwrap_or_default(),
null_type: obj2
.and_then(|v| v.get("null"))
.and_then(serde_json::Value::as_str)
.map(NullType::from)
.unwrap_or_default(),
}
let null_type = value
.get(usize::from(first_arg.is_some()))
.and_then(|v| v.get("null"))
.and_then(serde_json::Value::as_str)
.map(NullType::from)
.unwrap_or_default();

let compare_type = first_arg.unwrap_or_default();

Self { compare_type, null_type }
}

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

let fail = vec![
Expand Down

0 comments on commit 0aeaedd

Please sign in to comment.