test(linter/plugins): tokens test report each token individually#16811
Conversation
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. |
5bc92ed to
b1f0033
Compare
32ddb16 to
9b6667a
Compare
There was a problem hiding this comment.
The per-token context.report() loop is useful for visual verification, but it significantly increases output volume and snapshot brittleness by turning every token/comment into an error. The per-token message also embeds raw values, which can include newlines/long strings and destabilize snapshots. Lastly, token-line formatting is duplicated and should be centralized to avoid future drift.
Additional notes (1)
- Maintainability |
apps/oxlint/test/fixtures/tokens/plugin.ts:25-25
The token formatting logic is duplicated twice (once forast.tokens, once fortokensAndComments) with identical string construction. Since this fixture is being expanded, keeping that formatting in one helper will reduce the chance of future drift and make changes easier.
This is especially relevant now that the column widths (padEnd(18) / padEnd(15)) are somewhat magic-number-y and likely to be tweaked again.
Summary of changes
What changed
apps/oxlint/test/fixtures/tokens/plugin.ts
- Adjusted token table formatting to align fields with added spacing:
loc=now prints asloc= <start> - <end>and uses a widerpadEnd.range=now prints asrange= <start>-<end>and uses a widerpadEnd.
- Added a new loop that calls
context.report()once per token/comment intokensAndComments, emitting messages like${token.type} ("${token.value}")and usingnode: tokenfor pinpoint locations.
apps/oxlint/test/fixtures/tokens/output.snap.md
- Updated snapshots to reflect:
- The new aligned
loc=/range=formatting. - New per-token/per-comment reports with individual source snippets and carets.
- Updated totals from
2 errorsto16 errors(one per token/comment reported).
- The new aligned
There was a problem hiding this comment.
Pull request overview
This PR enhances the tokens test fixture to improve the readability and debuggability of token test output. The changes make it easier to visually verify token locations by providing clearer formatting and individual reports for each token.
Key Changes:
- Improved formatting of token location and range information with added whitespace for clarity
- Added individual reporting for each token/comment to visualize their exact locations in the source code
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
apps/oxlint/test/fixtures/tokens/plugin.ts |
Updated formatting strings to add spaces around separators and adjusted padding; added loop to report each token individually |
apps/oxlint/test/fixtures/tokens/output.snap.md |
Updated snapshot to reflect new formatting and added individual token/comment reports with visual location indicators |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b1f0033 to
ce7c6f4
Compare
9b6667a to
cf8e0a1
Compare
ce7c6f4 to
2cf754b
Compare
Merge activity
|
cf8e0a1 to
3b7d345
Compare
2cf754b to
dfc3e42
Compare

Improve tokens test fixture.