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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/oxc_linter/src/rules/eslint/getter_return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl GetterReturn {
&cfg.graph,
node.cfg_id(),
&|edge| match edge {
EdgeType::Normal => None,
EdgeType::Jump | EdgeType::Normal => None,
// We don't need to handle backedges because we would have already visited
// them on the forward pass
| EdgeType::Backedge
Expand Down Expand Up @@ -269,6 +269,7 @@ impl GetterReturn {
}
// Ignore irrelevant elements.
| InstructionKind::Break(_)
| InstructionKind::Continue(_)
| InstructionKind::Statement => {}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl Rule for NoThisBeforeSuper {
&cfg.graph,
node.cfg_id(),
&|edge| match edge {
EdgeType::Normal => None,
EdgeType::Jump | EdgeType::Normal => None,
EdgeType::Unreachable | EdgeType::Backedge | EdgeType::NewFunction => {
Some(DefinitelyCallsThisBeforeSuper::No)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn contains_return_statement<'a>(node: &AstNode<'a>, ctx: &LintContext<'a>) -> b
node.cfg_id(),
&|edge| match edge {
// We only care about normal edges having a return statement.
EdgeType::Normal => None,
EdgeType::Jump | EdgeType::Normal => None,
// For these two type, we flag it as not found.
EdgeType::Unreachable | EdgeType::NewFunction | EdgeType::Backedge => {
Some(FoundReturn::No)
Expand All @@ -122,6 +122,7 @@ fn contains_return_statement<'a>(node: &AstNode<'a>, ctx: &LintContext<'a>) -> b
}
InstructionKind::Return(ReturnInstructionKind::ImplicitUndefined)
| InstructionKind::Break(_)
| InstructionKind::Continue(_)
| InstructionKind::Statement => {}
}
}
Expand Down
8 changes: 5 additions & 3 deletions crates/oxc_linter/src/rules/react/rules_of_hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl RulesOfHooks {
// All nodes should be reachable from our hook, Otherwise we have a conditional/branching flow.
petgraph::algo::dijkstra(graph, func_cfg_id, Some(node_cfg_id), |e| match e.weight() {
EdgeType::NewFunction => 1,
EdgeType::Unreachable | EdgeType::Backedge | EdgeType::Normal => 0,
EdgeType::Jump | EdgeType::Unreachable | EdgeType::Backedge | EdgeType::Normal => 0,
})
.into_iter()
.filter(|(_, val)| *val == 0)
Expand All @@ -305,7 +305,7 @@ impl RulesOfHooks {
&cfg.graph,
func_cfg_id,
&|e| match e {
EdgeType::Normal => None,
EdgeType::Jump | EdgeType::Normal => None,
EdgeType::Unreachable | EdgeType::Backedge | EdgeType::NewFunction => {
Some(State::default())
}
Expand All @@ -324,7 +324,9 @@ impl RulesOfHooks {
InstructionKind::Unreachable
| InstructionKind::Throw
| InstructionKind::Return(_) => FoldWhile::Continue((acc.0, false)),
InstructionKind::Statement => FoldWhile::Continue(acc),
InstructionKind::Statement | InstructionKind::Continue(_) => {
FoldWhile::Continue(acc)
}
})
.into_inner();

Expand Down
1 change: 1 addition & 0 deletions crates/oxc_semantic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ rustc-hash = { workspace = true }
serde = { workspace = true, features = ["derive"], optional = true }
petgraph = { workspace = true }
itertools = { workspace = true }
bitflags = { workspace = true }

tsify = { workspace = true, optional = true }
wasm-bindgen = { workspace = true, optional = true }
Expand Down
Loading