@@ -42,20 +42,18 @@ declare_oxc_lint!(
42
42
43
43
impl Rule for Eqeqeq {
44
44
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) ;
47
46
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 }
59
57
}
60
58
61
59
fn run < ' a > ( & self , node : & AstNode < ' a > , ctx : & LintContext < ' a > ) {
@@ -227,6 +225,8 @@ fn test() {
227
225
( "null == null" , Some ( json!( [ "always" , { "null" : "never" } ] ) ) ) ,
228
226
// Do not apply this rule to `null`.
229
227
( "null == null" , Some ( json!( [ "smart" , { "null" : "ignore" } ] ) ) ) ,
228
+ // Issue: <https://github.com/oxc-project/oxc/issues/8773>
229
+ ( "href != null" , Some ( json!( [ { "null" : "ignore" } ] ) ) ) ,
230
230
] ;
231
231
232
232
let fail = vec ! [
0 commit comments