Skip to content

Comments

perf(linter): add should_run based on node types (batch 2)#12229

Closed
camchenry wants to merge 1 commit into07-11-perf_linter_add_should_run_based_on_node_types_batch_1_from
07-11-perf_linter_add_should_run_based_on_node_types_batch_2_
Closed

perf(linter): add should_run based on node types (batch 2)#12229
camchenry wants to merge 1 commit into07-11-perf_linter_add_should_run_based_on_node_types_batch_1_from
07-11-perf_linter_add_should_run_based_on_node_types_batch_2_

Conversation

@camchenry
Copy link
Member

@camchenry camchenry commented Jul 11, 2025

+1-3% performance improvement on lint benchmarks:

Screenshot 2025-07-11 at 1 13 23 PM

@github-actions github-actions bot added the A-linter Area - Linter label Jul 11, 2025
@github-actions github-actions bot added the C-performance Category - Solution not expected to change functional behavior, only performance label Jul 11, 2025
Copy link
Member Author

camchenry commented Jul 11, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codspeed-hq
Copy link

codspeed-hq bot commented Jul 11, 2025

CodSpeed Instrumentation Performance Report

Merging #12229 will not alter performance

Comparing 07-11-perf_linter_add_should_run_based_on_node_types_batch_2_ (d4b3a3c) with 07-11-perf_linter_add_should_run_based_on_node_types_batch_1_ (f353586)

Summary

✅ 34 untouched benchmarks

@camchenry camchenry marked this pull request as ready for review July 11, 2025 17:14
@camchenry camchenry requested a review from camc314 as a code owner July 11, 2025 17:14
fn should_run(&self, ctx: &crate::context::ContextHost) -> bool {
ctx.semantic()
.nodes()
.contains_all(&[oxc_ast::AstType::BinaryExpression, oxc_ast::AstType::UnaryExpression])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The contains_all check here is too restrictive - it requires both BinaryExpression AND UnaryExpression to be present in the AST for the rule to run. However, the rule is designed to detect unsafe negation patterns in binary expressions, which may or may not contain unary expressions.

Consider changing this to contains(oxc_ast::AstType::BinaryExpression) instead, as this would correctly run the rule whenever binary expressions exist in the code, regardless of whether unary expressions are also present.

Suggested change
.contains_all(&[oxc_ast::AstType::BinaryExpression, oxc_ast::AstType::UnaryExpression])
.contains(oxc_ast::AstType::BinaryExpression)

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

@camchenry camchenry closed this Jul 13, 2025
@camchenry camchenry deleted the 07-11-perf_linter_add_should_run_based_on_node_types_batch_2_ branch August 17, 2025 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant