Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions crates/oxc_linter/src/ast_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use oxc_ast::{
ast::{BindingIdentifier, *},
};
use oxc_ecmascript::{ToBoolean, is_global_reference::WithoutGlobalReferenceInformation};
use oxc_semantic::{AstNode, IsGlobalReference, NodeId, ReferenceId, Semantic, SymbolId};
use oxc_semantic::{AstNode, AstNodes, IsGlobalReference, NodeId, ReferenceId, Semantic, SymbolId};
use oxc_span::{GetSpan, Span};
use oxc_syntax::operator::{AssignmentOperator, BinaryOperator, LogicalOperator, UnaryOperator};

Expand Down Expand Up @@ -259,10 +259,10 @@ pub fn nth_outermost_paren_parent<'a, 'b>(
/// Iterate over parents of `node`, skipping nodes that are also ignored by
/// [`Expression::get_inner_expression`].
pub fn iter_outer_expressions<'a, 's>(
semantic: &'s Semantic<'a>,
nodes: &'s AstNodes<'a>,
node_id: NodeId,
) -> impl Iterator<Item = AstKind<'a>> + 's {
semantic.nodes().ancestor_kinds(node_id).filter(|parent| {
nodes.ancestor_kinds(node_id).filter(|parent| {
!matches!(
parent,
AstKind::ParenthesizedExpression(_)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ impl Rule for MaxLinesPerFunction {
}

fn is_iife<'a>(node: &AstNode<'a>, semantic: &Semantic<'a>) -> bool {
let Some(AstKind::CallExpression(call)) = iter_outer_expressions(semantic, node.id()).next()
let Some(AstKind::CallExpression(call)) =
iter_outer_expressions(semantic.nodes(), node.id()).next()
else {
return false;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ impl Rule for MaxNestedCallbacks {

fn is_callback<'a>(node: &AstNode<'a>, semantic: &Semantic<'a>) -> bool {
is_function_node(node)
&& matches!(iter_outer_expressions(semantic, node.id()).next(), Some(AstKind::Argument(_)))
&& matches!(
iter_outer_expressions(semantic.nodes(), node.id()).next(),
Some(AstKind::Argument(_))
)
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,7 @@ impl ExplicitFunctionReturnType {

// check function is IIFE (Immediately Invoked Function Expression)
fn is_iife<'a>(node: &AstNode<'a>, ctx: &LintContext<'a>) -> bool {
let Some(AstKind::CallExpression(call)) =
iter_outer_expressions(ctx.semantic(), node.id()).next()
let Some(AstKind::CallExpression(call)) = iter_outer_expressions(ctx.nodes(), node.id()).next()
else {
return false;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ fn is_top_expr(ctx: &LintContext, node: &AstNode) -> bool {
return false;
}

let parent = ast_util::iter_outer_expressions(ctx, node.id()).next();
let parent = ast_util::iter_outer_expressions(ctx.nodes(), node.id()).next();
matches!(parent, Some(AstKind::ExpressionStatement(_)))
}

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/unicorn/no_null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl Rule for NoNull {
return;
};

let mut parents = iter_outer_expressions(ctx, node.id());
let mut parents = iter_outer_expressions(ctx.nodes(), node.id());
let Some(parent_kind) = parents.next() else {
ctx.diagnostic_with_fix(no_null_diagnostic(null_literal.span), |fixer| {
fix_null(fixer, null_literal)
Expand Down
Loading