diff --git a/crates/oxc_linter/src/rules/react/no_array_index_key.rs b/crates/oxc_linter/src/rules/react/no_array_index_key.rs index 3dd9581667c60..1a48790911fb6 100644 --- a/crates/oxc_linter/src/rules/react/no_array_index_key.rs +++ b/crates/oxc_linter/src/rules/react/no_array_index_key.rs @@ -144,23 +144,15 @@ fn find_index_param_name_by_position<'a>( call_expr: &'a CallExpression, position: usize, ) -> Option<&'a str> { - match &call_expr.arguments[0] { + call_expr.arguments.first().and_then(|argument| match argument { Argument::ArrowFunctionExpression(arrow_fn_expr) => { - return Some( - arrow_fn_expr.params.items.get(position)?.pattern.get_identifier()?.as_str(), - ); + Some(arrow_fn_expr.params.items.get(position)?.pattern.get_identifier()?.as_str()) } - Argument::FunctionExpression(regular_fn_expr) => { - return Some( - regular_fn_expr.params.items.get(position)?.pattern.get_identifier()?.as_str(), - ); + Some(regular_fn_expr.params.items.get(position)?.pattern.get_identifier()?.as_str()) } - - _ => (), - } - - None + _ => None, + }) } const SECOND_INDEX_METHODS: phf::Set<&'static str> = phf::phf_set! {