refactor(linter/plugins): reuse shared binary search function for comments methods#20311
Merged
graphite-app[bot] merged 1 commit intomainfrom Mar 13, 2026
Conversation
Member
Author
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. |
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the comment-related SourceCode helpers in apps/oxlint/src-js/plugins to reuse the existing shared binary-search utility used throughout token APIs.
Changes:
- Export
firstTokenAtOrAfterfromtokens_methods.tsso it can be reused outside token-specific helpers. - Replace duplicated inline binary-search logic in
comments.tswith calls tofirstTokenAtOrAfter.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apps/oxlint/src-js/plugins/tokens_methods.ts | Exports the shared binary-search helper for reuse across modules. |
| apps/oxlint/src-js/plugins/comments.ts | Simplifies comment searches by delegating to the shared binary-search helper. |
Contributor
Merge activity
|
32b0578 to
405e741
Compare
93760a7 to
6c24a84
Compare
graphite-app bot
pushed a commit
that referenced
this pull request
Mar 13, 2026
…20312) #20310 and #20311 reduce code size and complexity by moving binary search routine which is used in all tokens and comments methods into a shared function `firstTokenAtOrAfter`. However, as noted in #20310, the downside of that change is a perf hit due to the cost of function calls. This PR fixes that regression by adding a TSDown plugin to the build which inlines the body of `firstTokenAtOrAfter` into all the call sites in tokens and comments methods. The net result is that the final code in bundled output is almost identical to before #20310, but the source code is much shorter and easier to understand. This unlocks a large optimization which will follow in a future PR (see #20310 for more details).
Base automatically changed from
om/03-12-refactor_linter_plugins_add_shared_binary_search_function_for_tokens_methods
to
main
March 13, 2026 00:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Continuation of #20310. Use the same binary search function
firstTokenAtOrAfter(introduced in that PR) for comments methods.