@@ -59,29 +59,30 @@ declare_oxc_lint!(
5959
6060impl Rule for NoInvalidFetchOptions {
6161 fn run < ' a > ( & self , node : & AstNode < ' a > , ctx : & LintContext < ' a > ) {
62- let arg = match node. kind ( ) {
62+ match node. kind ( ) {
6363 AstKind :: CallExpression ( call_expr) => {
6464 if !call_expr. callee . is_specific_id ( "fetch" ) || call_expr. arguments . len ( ) < 2 {
6565 return ;
6666 }
6767
68- & call_expr. arguments [ 1 ]
68+ if let Argument :: ObjectExpression ( expr) = & call_expr. arguments [ 1 ]
69+ && let Some ( ( method_name, body_span) ) = is_invalid_fetch_options ( expr, ctx)
70+ {
71+ ctx. diagnostic ( no_invalid_fetch_options_diagnostic ( body_span, & method_name) ) ;
72+ }
6973 }
7074 AstKind :: NewExpression ( new_expr) => {
7175 if !is_new_expression ( new_expr, & [ "Request" ] , Some ( 2 ) , None ) {
7276 return ;
7377 }
7478
75- & new_expr. arguments [ 1 ]
79+ if let Argument :: ObjectExpression ( expr) = & new_expr. arguments [ 1 ]
80+ && let Some ( ( method_name, body_span) ) = is_invalid_fetch_options ( expr, ctx)
81+ {
82+ ctx. diagnostic ( no_invalid_fetch_options_diagnostic ( body_span, & method_name) ) ;
83+ }
7684 }
77- _ => return ,
78- } ;
79-
80- let Argument :: ObjectExpression ( expr) = arg else { return } ;
81- let result = is_invalid_fetch_options ( expr, ctx) ;
82-
83- if let Some ( ( method_name, body_span) ) = result {
84- ctx. diagnostic ( no_invalid_fetch_options_diagnostic ( body_span, & method_name) ) ;
85+ _ => { }
8586 }
8687 }
8788}
0 commit comments