Skip to content

refactor(linter/plugins): split tokens initialization from tokens methods#19981

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/03-02-refactor_linter_plugins_split_tokens_initialization_from_tokens_methods
Mar 3, 2026
Merged

refactor(linter/plugins): split tokens initialization from tokens methods#19981
graphite-app[bot] merged 1 commit intomainfrom
om/03-02-refactor_linter_plugins_split_tokens_initialization_from_tokens_methods

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Mar 3, 2026

Pure refactor. tokens.ts was getting too large. Split it into 2 files:

  • tokens.ts: Tokens lifecycle methods - initialization, deserialization, and reset.
  • tokens_methods.ts: Public methods on SourceCode e.g. sourceCode.getFirstToken.

Copy link
Member Author

overlookmotel commented Mar 3, 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 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.

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI A-linter-plugins Area - Linter JS plugins C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Mar 3, 2026
@overlookmotel overlookmotel marked this pull request as ready for review March 3, 2026 21:27
@overlookmotel overlookmotel requested a review from camc314 as a code owner March 3, 2026 21:27
Copilot AI review requested due to automatic review settings March 3, 2026 21:27
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 oxlint JS plugin token utilities by separating token lifecycle/initialization concerns from SourceCode token-query methods, reducing tokens.ts size and clarifying responsibilities.

Changes:

  • Added tokens_methods.ts to host SourceCode-style token query helpers (e.g. getFirstToken, getTokensBetween, isSpaceBetween).
  • Trimmed tokens.ts down to token types + lazy initialization/deserialization/reset state.
  • Updated SourceCode wiring and tests to import token methods from the new module.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
apps/oxlint/src-js/plugins/tokens_methods.ts New module containing token-related SourceCode public methods.
apps/oxlint/src-js/plugins/tokens.ts Removes token-method exports; keeps token types and initialization/reset logic.
apps/oxlint/src-js/plugins/source_code.ts Re-points SourceCode token method mapping to tokens_methods.ts.
apps/oxlint/src-js/plugins.ts Moves exported option-type re-exports (SkipOptions, etc.) to tokens_methods.ts.
apps/oxlint/test/tokens.test.ts Updates imports to pull token methods from tokens_methods.ts.
apps/oxlint/test/isSpaceBetween.test.ts Updates imports to pull spacing helpers from tokens_methods.ts.

@overlookmotel overlookmotel force-pushed the om/03-02-perf_linter_plugins_make_tokens_class_instances branch from 8d4fb15 to 0501477 Compare March 3, 2026 22:42
@overlookmotel overlookmotel force-pushed the om/03-02-refactor_linter_plugins_split_tokens_initialization_from_tokens_methods branch from f54116a to 2adbf6e Compare March 3, 2026 22:42
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Mar 3, 2026
Copy link
Member Author

overlookmotel commented Mar 3, 2026

Merge activity

…hods (#19981)

Pure refactor. `tokens.ts` was getting too large. Split it into 2 files:

* `tokens.ts`: Tokens lifecycle methods - initialization, deserialization, and reset.
* `tokens_methods.ts`: Public methods on `SourceCode` e.g. `sourceCode.getFirstToken`.
@graphite-app graphite-app bot force-pushed the om/03-02-perf_linter_plugins_make_tokens_class_instances branch from 0501477 to 77f1c71 Compare March 3, 2026 23:25
@graphite-app graphite-app bot force-pushed the om/03-02-refactor_linter_plugins_split_tokens_initialization_from_tokens_methods branch from 2adbf6e to 5e4df80 Compare March 3, 2026 23:25
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 3, 2026
Base automatically changed from om/03-02-perf_linter_plugins_make_tokens_class_instances to main March 3, 2026 23:33
@graphite-app graphite-app bot merged commit 5e4df80 into main Mar 3, 2026
20 checks passed
@graphite-app graphite-app bot deleted the om/03-02-refactor_linter_plugins_split_tokens_initialization_from_tokens_methods branch March 3, 2026 23:33
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