Skip to content
Closed
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
49 changes: 32 additions & 17 deletions crates/oxc_linter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,30 +238,45 @@ impl Linter {
}
} else {
for (rule, ref ctx) in rules {
rule.run_once(ctx);

for symbol in semantic.scoping().symbol_ids() {
rule.run_on_symbol(symbol, ctx);
}
let (ast_types, all_types, only_runs_on_nodes) = rule.types_info();

// For smaller files, benchmarking showed it was faster to iterate over all rules and just check the
// node types as we go, rather than pre-bucketing rules by AST node type and doing extra allocations.
let (ast_types, all_types, _) = rule.types_info();
if all_types {
for node in semantic.nodes() {
rule.run(node, ctx);
if only_runs_on_nodes {
if all_types {
for node in semantic.nodes() {
rule.run(node, ctx);
}
} else {
for node in semantic.nodes() {
if ast_types.has(node.kind().ty()) {
rule.run(node, ctx);
}
}
}
} else {
for node in semantic.nodes() {
if ast_types.has(node.kind().ty()) {
rule.run_once(ctx);

for symbol in semantic.scoping().symbol_ids() {
rule.run_on_symbol(symbol, ctx);
}

// For smaller files, benchmarking showed it was faster to iterate over all rules and just check the
// node types as we go, rather than pre-bucketing rules by AST node type and doing extra allocations.
if all_types {
for node in semantic.nodes() {
rule.run(node, ctx);
}
} else {
for node in semantic.nodes() {
if ast_types.has(node.kind().ty()) {
rule.run(node, ctx);
}
}
}
}

if should_run_on_jest_node {
for jest_node in iter_possible_jest_call_node(semantic) {
rule.run_on_jest_node(&jest_node, ctx);
if should_run_on_jest_node {
for jest_node in iter_possible_jest_call_node(semantic) {
rule.run_on_jest_node(&jest_node, ctx);
}
}
}
}
Expand Down
Loading