Skip to content

refactor(linter/plugins): pass fix/suggestion offsets to Rust as i64s#19159

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/02-08-refactor_linter_plugins_pass_fix_suggestion_offsets_to_rust_as_i64_s
Feb 8, 2026
Merged

refactor(linter/plugins): pass fix/suggestion offsets to Rust as i64s#19159
graphite-app[bot] merged 1 commit intomainfrom
om/02-08-refactor_linter_plugins_pass_fix_suggestion_offsets_to_rust_as_i64_s

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Feb 8, 2026

Follow-on after #19092.

That PR added 1 to offsets of fixes before sending them to Rust side, to support offset -1 (legal when fix is to remove a BOM).

Upon reflection, I think that solution is too complicated and confusing. Instead, represent start and end offsets of fixes as i64s in JsFix. This supports -1 as an offset, and also the full range of valid u32 values. Check on Rust side that the values are in range before converting to u32s.

This also makes for better error messages for invalid offsets - no more inexplicable "Failed to deserialize JSON returned by lintFile" errors.

Copy link
Member Author

overlookmotel commented Feb 8, 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 labels Feb 8, 2026
@github-actions github-actions bot added the C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior label Feb 8, 2026
@overlookmotel overlookmotel force-pushed the om/02-08-docs_linter_plugins_correct_and_expand_jsdoc_comment_for_ruletester_config branch from ea456c1 to f7e0221 Compare February 8, 2026 20:26
@overlookmotel overlookmotel force-pushed the om/02-08-refactor_linter_plugins_pass_fix_suggestion_offsets_to_rust_as_i64_s branch from 896e1a6 to 58d4d89 Compare February 8, 2026 20:26
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 8, 2026

Merging this PR will not alter performance

✅ 47 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/02-08-refactor_linter_plugins_pass_fix_suggestion_offsets_to_rust_as_i64_s (7c71615) with main (825f148)2

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (6e8ef38) during the generation of this report, so 825f148 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@overlookmotel overlookmotel marked this pull request as ready for review February 8, 2026 20:39
Copilot AI review requested due to automatic review settings February 8, 2026 20:40
@graphite-app graphite-app bot changed the base branch from om/02-08-docs_linter_plugins_correct_and_expand_jsdoc_comment_for_ruletester_config to graphite-base/19159 February 8, 2026 20:41
@overlookmotel overlookmotel self-assigned this Feb 8, 2026
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 simplifies JS→Rust fix/suggestion range handling by removing the “+1 offset” workaround and instead representing fix start/end offsets as signed 64-bit integers, enabling -1 (BOM-relative) while still supporting the full u32 range once validated on the Rust side.

Changes:

  • Refactors Rust JsFix to use start: i64 / end: i64 and adds validation/conversion logic for negative/out-of-range offsets.
  • Updates JS plugin FixReport to send start/end directly (no +1 encoding).
  • Updates fixture snapshots to reflect new error surfaces and output formatting.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
crates/oxc_linter/src/external_linter.rs Switches JsFix offsets to i64 and adds conversion/validation path for invalid offsets and BOM -1.
apps/oxlint/src-js/plugins/fix.ts Updates JS-side payload shape to { start, end, text } and adjusts documentation accordingly.
apps/oxlint/test/fixtures/suggestions/output.snap.md Snapshot updates reflecting new error behavior/output.
apps/oxlint/test/fixtures/suggestions/fix.snap.md Snapshot updates reflecting new error behavior/output.
apps/oxlint/test/fixtures/suggestions/fix-suggestions.snap.md Snapshot updates reflecting new error behavior/output.
apps/oxlint/test/fixtures/fixes/output.snap.md Snapshot updates reflecting new error behavior/output.
apps/oxlint/test/fixtures/fixes/fix.snap.md Snapshot updates reflecting new error behavior/output.

@graphite-app graphite-app bot force-pushed the om/02-08-refactor_linter_plugins_pass_fix_suggestion_offsets_to_rust_as_i64_s branch from 58d4d89 to f3db61b Compare February 8, 2026 20:48
@graphite-app graphite-app bot force-pushed the graphite-base/19159 branch from f7e0221 to 6e8ef38 Compare February 8, 2026 20:48
@graphite-app graphite-app bot changed the base branch from graphite-base/19159 to main February 8, 2026 20:49
@graphite-app graphite-app bot force-pushed the om/02-08-refactor_linter_plugins_pass_fix_suggestion_offsets_to_rust_as_i64_s branch from f3db61b to 215f80e Compare February 8, 2026 20:49
@overlookmotel overlookmotel force-pushed the om/02-08-refactor_linter_plugins_pass_fix_suggestion_offsets_to_rust_as_i64_s branch from 215f80e to 7c71615 Compare February 8, 2026 20:58
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Feb 8, 2026
Copy link
Member Author

overlookmotel commented Feb 8, 2026

Merge activity

…`s (#19159)

Follow-on after #19092.

That PR added 1 to offsets of fixes before sending them to Rust side, to support offset `-1` (legal when fix is to remove a BOM).

Upon reflection, I think that solution is too complicated and confusing. Instead, represent `start` and `end` offsets of fixes as `i64`s in `JsFix`. This supports `-1` as an offset, and also the full range of valid `u32` values. Check on Rust side that the values are in range before converting to `u32`s.

This also makes for better error messages for invalid offsets - no more inexplicable "Failed to deserialize JSON returned by `lintFile`" errors.
@graphite-app graphite-app bot force-pushed the om/02-08-refactor_linter_plugins_pass_fix_suggestion_offsets_to_rust_as_i64_s branch from 7c71615 to 55be9fe Compare February 8, 2026 21:04
@graphite-app graphite-app bot merged commit 55be9fe into main Feb 8, 2026
21 checks passed
@graphite-app graphite-app bot deleted the om/02-08-refactor_linter_plugins_pass_fix_suggestion_offsets_to_rust_as_i64_s branch February 8, 2026 21:10
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Feb 8, 2026
OskarLebuda pushed a commit to OskarLebuda/oxc that referenced this pull request Feb 17, 2026
…`s (oxc-project#19159)

Follow-on after oxc-project#19092.

That PR added 1 to offsets of fixes before sending them to Rust side, to support offset `-1` (legal when fix is to remove a BOM).

Upon reflection, I think that solution is too complicated and confusing. Instead, represent `start` and `end` offsets of fixes as `i64`s in `JsFix`. This supports `-1` as an offset, and also the full range of valid `u32` values. Check on Rust side that the values are in range before converting to `u32`s.

This also makes for better error messages for invalid offsets - no more inexplicable "Failed to deserialize JSON returned by `lintFile`" errors.
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.

1 participant

Comments