Skip to content

fix(linter/plugins): include loc when call JSON.stringify on Tokens and Comments#20512

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/03-19-fix_linter_plugins_include_loc_when_call_json.stringify_on_token_s_and_comment_s
Mar 21, 2026
Merged

fix(linter/plugins): include loc when call JSON.stringify on Tokens and Comments#20512
graphite-app[bot] merged 1 commit intomainfrom
om/03-19-fix_linter_plugins_include_loc_when_call_json.stringify_on_token_s_and_comment_s

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Mar 19, 2026

loc property of Tokens and Comments is a getter on these classes' prototypes. Add a toJSON method to both classes so JSON.stringify includes loc in the generated JSON.

Copy link
Member Author

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

@overlookmotel overlookmotel self-assigned this Mar 19, 2026
@overlookmotel overlookmotel marked this pull request as ready for review March 19, 2026 01:14
@overlookmotel overlookmotel requested a review from camc314 as a code owner March 19, 2026 01:14
Copilot AI review requested due to automatic review settings March 19, 2026 01:14
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

This PR ensures loc is included when JSON.stringify is called on runtime Token and Comment instances (where loc is implemented as a prototype getter), and updates fixture-based snapshot coverage accordingly.

Changes:

  • Add toJSON() to Token and Comment so JSON.stringify includes loc.
  • Extend the tokens/comments fixture plugins to report a JSON.stringify rendering for the first token/comment.
  • Update snapshot outputs to reflect the new serialized shape (including loc) and updated error counts.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
apps/oxlint/src-js/plugins/tokens.ts Adds Token.toJSON() to include loc in JSON serialization.
apps/oxlint/src-js/plugins/comments.ts Adds Comment.toJSON() to include loc in JSON serialization.
apps/oxlint/test/fixtures/tokens/plugin.ts Fixture plugin emits JSON.stringify output for a token to validate serialization.
apps/oxlint/test/fixtures/tokens/output.snap.md Snapshot updated to include token loc in JSON output and adjusted totals.
apps/oxlint/test/fixtures/comments/plugin.ts Fixture plugin emits JSON.stringify output for a comment to validate serialization.
apps/oxlint/test/fixtures/comments/output.snap.md Snapshot updated to include comment loc in JSON output and adjusted totals.

@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Mar 20, 2026
Copy link
Member Author

overlookmotel commented Mar 20, 2026

Merge activity

  • Mar 20, 10:45 PM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 20, 10:50 PM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 21, 12:25 PM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 21, 1:04 PM UTC: overlookmotel added this pull request to the Graphite merge queue.
  • Mar 21, 1:13 PM UTC: Merged by the Graphite merge queue.

@overlookmotel overlookmotel removed the 0-merge Merge with Graphite Merge Queue label Mar 20, 2026
@overlookmotel overlookmotel changed the base branch from om/03-18-perf_linter_plugins_grow_uint32array_s_by_doubling to graphite-base/20512 March 21, 2026 12:19
@overlookmotel overlookmotel changed the base branch from graphite-base/20512 to om/03-18-perf_linter_plugins_grow_uint32array_s_by_doubling March 21, 2026 12:19
@overlookmotel overlookmotel changed the base branch from om/03-18-perf_linter_plugins_grow_uint32array_s_by_doubling to graphite-base/20512 March 21, 2026 12:20
@overlookmotel overlookmotel changed the base branch from graphite-base/20512 to om/03-18-perf_linter_plugins_grow_uint32array_s_by_doubling March 21, 2026 12:20
@overlookmotel overlookmotel changed the base branch from om/03-18-perf_linter_plugins_grow_uint32array_s_by_doubling to graphite-base/20512 March 21, 2026 12:21
@overlookmotel overlookmotel force-pushed the om/03-19-fix_linter_plugins_include_loc_when_call_json.stringify_on_token_s_and_comment_s branch from 157ae2b to 3512af4 Compare March 21, 2026 12:21
@overlookmotel overlookmotel added 0-merge Merge with Graphite Merge Queue labels Mar 21, 2026
@overlookmotel overlookmotel force-pushed the om/03-19-fix_linter_plugins_include_loc_when_call_json.stringify_on_token_s_and_comment_s branch from 3512af4 to 0216572 Compare March 21, 2026 12:33
@graphite-app graphite-app bot force-pushed the graphite-base/20512 branch from 4c2b69a to e233fae Compare March 21, 2026 12:55
@graphite-app graphite-app bot force-pushed the om/03-19-fix_linter_plugins_include_loc_when_call_json.stringify_on_token_s_and_comment_s branch from 0216572 to 89d4f42 Compare March 21, 2026 12:55
@graphite-app graphite-app bot changed the base branch from graphite-base/20512 to om/03-18-perf_linter_plugins_share_empty_uint32array_across_multiple_places March 21, 2026 12:56
@graphite-app graphite-app bot force-pushed the om/03-19-fix_linter_plugins_include_loc_when_call_json.stringify_on_token_s_and_comment_s branch from 89d4f42 to ac2c37c Compare March 21, 2026 12:56
@graphite-app graphite-app bot changed the base branch from om/03-18-perf_linter_plugins_share_empty_uint32array_across_multiple_places to graphite-base/20512 March 21, 2026 13:03
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 21, 2026
@graphite-app graphite-app bot changed the base branch from graphite-base/20512 to main March 21, 2026 13:09
…en`s and `Comment`s (#20512)

`loc` property of `Token`s and `Comment`s is a getter on these classes' prototypes. Add a `toJSON` method to both classes so `JSON.stringify` includes `loc` in the generated JSON.
@graphite-app graphite-app bot force-pushed the om/03-19-fix_linter_plugins_include_loc_when_call_json.stringify_on_token_s_and_comment_s branch from ac2c37c to 532c921 Compare March 21, 2026 13:10
@graphite-app graphite-app bot merged commit 532c921 into main Mar 21, 2026
23 checks passed
@graphite-app graphite-app bot deleted the om/03-19-fix_linter_plugins_include_loc_when_call_json.stringify_on_token_s_and_comment_s branch March 21, 2026 13:13
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-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants