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
12 changes: 6 additions & 6 deletions crates/oxc_linter/src/rules/react/no_array_index_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ fn find_index_param_name<'a>(node: &'a AstNode, ctx: &'a LintContext) -> Option<
return None;
};

if SECOND_INDEX_METHODS.contains(expr.property.name.as_str()) {
if SECOND_INDEX_METHODS.contains(&expr.property.name.as_str()) {
return find_index_param_name_by_position(call_expr, 1);
}

if THIRD_INDEX_METHODS.contains(expr.property.name.as_str()) {
if THIRD_INDEX_METHODS.contains(&expr.property.name.as_str()) {
return find_index_param_name_by_position(call_expr, 2);
}
}
Expand All @@ -156,7 +156,7 @@ fn find_index_param_name_by_position<'a>(
})
}

const SECOND_INDEX_METHODS: phf::Set<&'static str> = phf::phf_set! {
const SECOND_INDEX_METHODS: [&str; 8] = [
// things.map((thing, index) => (<Hello key={index} />));
"map",
// things.forEach((thing, index) => {otherThings.push(<Hello key={index} />);});
Expand All @@ -173,14 +173,14 @@ const SECOND_INDEX_METHODS: phf::Set<&'static str> = phf::phf_set! {
"findIndex",
// things.flatMap((thing, index) => (<Hello key={index} />));
"flatMap",
};
];

const THIRD_INDEX_METHODS: phf::Set<&'static str> = phf::phf_set! {
const THIRD_INDEX_METHODS: [&str; 2] = [
// things.reduce((collection, thing, index) => (collection.concat(<Hello key={index} />)), []);
"reduce",
// things.reduceRight((collection, thing, index) => (collection.concat(<Hello key={index} />)), []);
"reduceRight",
};
];

impl Rule for NoArrayIndexKey {
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
Expand Down
Loading