Skip to content

Commit

Permalink
fix(linter): fix panic in react/no-array-index-key
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Nov 21, 2024
1 parent c34d649 commit 9fefc34
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions crates/oxc_linter/src/rules/react/no_array_index_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.get(0).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! {
Expand Down

0 comments on commit 9fefc34

Please sign in to comment.