Skip to content

refactor(linter/plugins): reuse shared binary search function for comments methods#20311

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/03-12-refactor_linter_plugins_reuse_shared_binary_search_function_for_comments_methods
Mar 13, 2026
Merged

refactor(linter/plugins): reuse shared binary search function for comments methods#20311
graphite-app[bot] merged 1 commit intomainfrom
om/03-12-refactor_linter_plugins_reuse_shared_binary_search_function_for_comments_methods

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Mar 13, 2026

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

Copy link
Member Author

overlookmotel commented Mar 13, 2026


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 changes, fast-track this PR to the front of 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.

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI A-linter-plugins Area - Linter JS plugins labels Mar 13, 2026
@github-actions github-actions bot added the C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior label Mar 13, 2026
@overlookmotel overlookmotel marked this pull request as ready for review March 13, 2026 00:12
@overlookmotel overlookmotel requested a review from camc314 as a code owner March 13, 2026 00:12
Copilot AI review requested due to automatic review settings March 13, 2026 00:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 firstTokenAtOrAfter from tokens_methods.ts so it can be reused outside token-specific helpers.
  • Replace duplicated inline binary-search logic in comments.ts with calls to firstTokenAtOrAfter.

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.

@overlookmotel overlookmotel self-assigned this Mar 13, 2026
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Mar 13, 2026
@graphite-app
Copy link
Contributor

graphite-app bot commented Mar 13, 2026

Merge activity

…ments methods (#20311)

Continuation of #20310. Use the same binary search function `firstTokenAtOrAfter` (introduced in that PR) for comments methods.
@graphite-app graphite-app bot force-pushed the om/03-12-refactor_linter_plugins_add_shared_binary_search_function_for_tokens_methods branch from 32b0578 to 405e741 Compare March 13, 2026 00:25
@graphite-app graphite-app bot force-pushed the om/03-12-refactor_linter_plugins_reuse_shared_binary_search_function_for_comments_methods branch from 93760a7 to 6c24a84 Compare March 13, 2026 00:26
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
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 13, 2026
@graphite-app graphite-app bot merged commit 6c24a84 into main Mar 13, 2026
20 checks passed
@graphite-app graphite-app bot deleted the om/03-12-refactor_linter_plugins_reuse_shared_binary_search_function_for_comments_methods branch March 13, 2026 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-linter Area - Linter A-linter-plugins Area - Linter JS plugins C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants