Skip to content

test(linter/plugins): tokens test report each token individually#16811

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-13-test_linter_plugins_tokens_test_report_each_token_individually
Dec 13, 2025
Merged

test(linter/plugins): tokens test report each token individually#16811
graphite-app[bot] merged 1 commit intomainfrom
12-13-test_linter_plugins_tokens_test_report_each_token_individually

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented Dec 13, 2025

Improve tokens test fixture.

  1. Clearer formatting of totals list.
  2. Report every tokens and comment individually so you can see each token's location visually, and verify the results.

Copy link
Copy Markdown
Member Author

overlookmotel commented Dec 13, 2025


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-test Category - Testing. Code is missing test cases, or a PR is adding them labels Dec 13, 2025
@overlookmotel overlookmotel force-pushed the 12-13-test_linter_plugins_tokens_test_report_each_token_individually branch from 5bc92ed to b1f0033 Compare December 13, 2025 22:12
@overlookmotel overlookmotel force-pushed the 12-13-perf_linter_plugins_use_start_and_end_instead_of_range_in_tokens_methods branch from 32ddb16 to 9b6667a Compare December 13, 2025 22:12
@overlookmotel overlookmotel self-assigned this Dec 13, 2025
@overlookmotel overlookmotel marked this pull request as ready for review December 13, 2025 22:14
Copilot AI review requested due to automatic review settings December 13, 2025 22:14
Copy link
Copy Markdown

@charliecreates charliecreates bot left a comment

Choose a reason for hiding this comment

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

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 for ast.tokens, once for tokensAndComments) 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 as loc= <start> - <end> and uses a wider padEnd.
    • range= now prints as range= <start>-<end> and uses a wider padEnd.
  • Added a new loop that calls context.report() once per token/comment in tokensAndComments, emitting messages like ${token.type} ("${token.value}") and using node: token for 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 errors to 16 errors (one per token/comment reported).

Copy link
Copy Markdown
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

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.

@overlookmotel overlookmotel force-pushed the 12-13-test_linter_plugins_tokens_test_report_each_token_individually branch from b1f0033 to ce7c6f4 Compare December 13, 2025 22:20
@overlookmotel overlookmotel force-pushed the 12-13-perf_linter_plugins_use_start_and_end_instead_of_range_in_tokens_methods branch from 9b6667a to cf8e0a1 Compare December 13, 2025 22:20
@overlookmotel overlookmotel force-pushed the 12-13-test_linter_plugins_tokens_test_report_each_token_individually branch from ce7c6f4 to 2cf754b Compare December 13, 2025 22:27
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Dec 13, 2025
Copy link
Copy Markdown
Member Author

overlookmotel commented Dec 13, 2025

Merge activity

)

Improve tokens test fixture.

1. Clearer formatting of totals list.
2. Report every tokens and comment individually so you can see each token's location visually, and verify the results.
@graphite-app graphite-app bot force-pushed the 12-13-perf_linter_plugins_use_start_and_end_instead_of_range_in_tokens_methods branch from cf8e0a1 to 3b7d345 Compare December 13, 2025 22:57
@graphite-app graphite-app bot force-pushed the 12-13-test_linter_plugins_tokens_test_report_each_token_individually branch from 2cf754b to dfc3e42 Compare December 13, 2025 22:57
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 13, 2025
Base automatically changed from 12-13-perf_linter_plugins_use_start_and_end_instead_of_range_in_tokens_methods to main December 13, 2025 23:03
@graphite-app graphite-app bot merged commit dfc3e42 into main Dec 13, 2025
19 checks passed
@graphite-app graphite-app bot deleted the 12-13-test_linter_plugins_tokens_test_report_each_token_individually branch December 13, 2025 23:04
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-test Category - Testing. Code is missing test cases, or a PR is adding them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants