Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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