perf(linter): add should_run based on node types (batch 2)#12229
Conversation
|
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.
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
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 Instrumentation Performance ReportMerging #12229 will not alter performanceComparing Summary
|
| fn should_run(&self, ctx: &crate::context::ContextHost) -> bool { | ||
| ctx.semantic() | ||
| .nodes() | ||
| .contains_all(&[oxc_ast::AstType::BinaryExpression, oxc_ast::AstType::UnaryExpression]) |
There was a problem hiding this comment.
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.
| .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.

+1-3% performance improvement on lint benchmarks: