Skip to content

Commit

Permalink
chore: sync with main - rename ancestors and iter_parents
Browse files Browse the repository at this point in the history
  • Loading branch information
no-yan committed Nov 9, 2024
1 parent 40475e1 commit c42d5ed
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions crates/oxc_linter/src/rules/oxc/only_used_in_recursion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ fn create_diagnostic_jsx(

// search for references to the function and remove the property
for reference in ctx.semantic().symbol_references(property_symbol_id) {
let mut ancestors = ctx.nodes().ancestors(reference.node_id());
let mut ancestor_ids = ctx.nodes().ancestor_ids(reference.node_id());

let Some(attr) =
ancestors.find_map(|node| match ctx.nodes().get_node(node).kind() {
ancestor_ids.find_map(|node| match ctx.nodes().get_node(node).kind() {
AstKind::JSXAttributeItem(attr) => Some(attr),
_ => None,
})
Expand All @@ -266,7 +266,7 @@ fn create_diagnostic_jsx(
}

fn used_with_spread_attribute(node_id: NodeId, ctx: &LintContext) -> bool {
ctx.nodes().iter_parents(node_id).any(|node| match node.kind() {
ctx.nodes().ancestors(node_id).any(|node| match node.kind() {
AstKind::JSXOpeningElement(opening_element) => opening_element
.attributes
.iter()
Expand Down Expand Up @@ -350,7 +350,7 @@ fn is_property_only_used_in_recursion_jsx(
return false;
};

let Some(attr) = ctx.nodes().iter_parents(may_jsx_expr_container.id()).find_map(|node| {
let Some(attr) = ctx.nodes().ancestors(may_jsx_expr_container.id()).find_map(|node| {
if let AstKind::JSXAttributeItem(attr) = node.kind() {
Some(attr)
} else {
Expand All @@ -370,13 +370,15 @@ fn is_property_only_used_in_recursion_jsx(
return false;
}

let Some(opening_element) = ctx.nodes().ancestors(reference.node_id()).find_map(|node| {
if let AstKind::JSXOpeningElement(elem) = ctx.nodes().get_node(node).kind() {
Some(elem)
} else {
None
}
}) else {
let Some(opening_element) =
ctx.nodes().ancestor_ids(reference.node_id()).find_map(|node| {
if let AstKind::JSXOpeningElement(elem) = ctx.nodes().get_node(node).kind() {
Some(elem)
} else {
None
}
})
else {
return false;
};

Expand Down

0 comments on commit c42d5ed

Please sign in to comment.