Skip to content

feat(linter/tsgolint): add support for labeled ranges in tsgolint diagnostics#19201

Merged
graphite-app[bot] merged 1 commit intomainfrom
02-09-feat_linter_tsgolint_add_support_for_labeled_ranges_in_tsgolint_diagnostics
Feb 13, 2026
Merged

feat(linter/tsgolint): add support for labeled ranges in tsgolint diagnostics#19201
graphite-app[bot] merged 1 commit intomainfrom
02-09-feat_linter_tsgolint_add_support_for_labeled_ranges_in_tsgolint_diagnostics

Conversation

@camchenry
Copy link
Member

@camchenry camchenry commented Feb 10, 2026

This adds support for labeled ranges coming from tsgolint. In some cases, this might mean the primary span is also completely zeroed out, indicating that labeled ranges are the only source of labels.

Before:

Screenshot 2026-02-10 at 9 27 20 PM

After:

Screenshot 2026-02-10 at 9 26 49 PM

@github-actions github-actions bot added A-linter Area - Linter C-enhancement Category - New feature or request labels Feb 10, 2026
Copy link
Member Author


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.

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 10, 2026

Merging this PR will not alter performance

✅ 47 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing 02-09-feat_linter_tsgolint_add_support_for_labeled_ranges_in_tsgolint_diagnostics (be0ce50) with main (e9c5b1e)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 (90ec3d2) during the generation of this report, so e9c5b1e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@camc314 camc314 self-assigned this Feb 10, 2026
@camchenry camchenry force-pushed the 02-09-feat_linter_tsgolint_add_support_for_labeled_ranges_in_tsgolint_diagnostics branch from b932c7f to 09b0e93 Compare February 11, 2026 02:34
@camchenry camchenry marked this pull request as ready for review February 11, 2026 02:44
@camchenry camchenry requested a review from camc314 as a code owner February 11, 2026 02:44
Copilot AI review requested due to automatic review settings February 11, 2026 02:44
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 adds support for labeled ranges in tsgolint diagnostics, enabling more detailed and precise error reporting. The implementation allows tsgolint to provide multiple labeled spans for a single diagnostic, with special handling for cases where the primary span is completely zeroed out (unspanned).

Changes:

  • Added LabeledRange struct to represent labeled code ranges with descriptive labels
  • Extended diagnostic payload structures to include labeled_ranges field
  • Modified diagnostic conversion logic to handle labeled ranges with conditional primary span inclusion
Comments suppressed due to low confidence (1)

crates/oxc_linter/src/tsgolint.rs:1423

  • According to the PR description, a key feature is handling cases where "the primary span is also completely zeroed out, indicating that labeled ranges are the only source of labels." However, there's no test case for when labeled_ranges is not empty AND the main span is unspanned (e.g., SPAN or Span::new(0, 0)). This scenario would exercise the logic at line 725 where is_unspanned() is checked. Consider adding a test case with an unspanned main span to verify that only the labeled ranges are used and no primary label is added.
    #[test]
    fn test_message_from_tsgo_lint_diagnostic_with_labeled_ranges() {
        let diagnostic = TsGoLintRuleDiagnostic {
            span: Span::new(0, 10),
            rule: "some_rule".into(),
            message: RuleMessage {
                id: "some_id".into(),
                description: "Some description".into(),
                help: None,
            },
            fixes: vec![],
            suggestions: vec![],
            labeled_ranges: vec![
                LabeledRange { label: "Label 1".into(), range: Range { pos: 0, end: 5 } },
                LabeledRange { label: "Label 2".into(), range: Range { pos: 5, end: 10 } },
            ],
            file_path: "some/file/path".into(),
        };

        let message = Message::from_tsgo_lint_diagnostic(diagnostic, "Some text over 10 bytes.");

        assert!(message.error.labels.is_some());
        let labels = message.error.labels.as_ref().unwrap();
        assert_eq!(labels.len(), 3);
        assert_eq!(labels[0], LabeledSpan::new(Some("Label 1".into()), 0, 5));
        assert_eq!(labels[1], LabeledSpan::new(Some("Label 2".into()), 5, 5));
    }

graphite-app bot pushed a commit to oxc-project/tsgolint that referenced this pull request Feb 11, 2026
- closes #650
- depends on oxc-project/oxc#19201

This adds support for labeled ranges being returned by the tsgolint headless mode. This should be a backwards compatible change, as we can simply ignore this additional data on the `oxlint` side. Let's check it, but I think that old versions of `oxlint` won't serialize this field.

## Changes

This adds a new `ReportDiagnostic` that allows completely customizing how a `RuleDiagnostic` is reported. This is like a superset of all the other diagnostic reporting functions. So, this naturally allows setting of the new `LabeledRanges` field as well. Diagnostic functions in rules can then be refactored to return `RuleDiagnostic` instead of `RuleMessage`. This will also be useful in the future in case we add more fields to the diagnostic struct.

## Example

I used the `no-unnecessary-condition` rule diagnostic as an example because it is a good example where we lack contextual information currently, but it makes a lot more sense when we can add contextual labels with the type info.

Example output from running on `test.ts`:

```ts
// test.ts
const left: boolean = true;
const right: string = "foo";

if (left === right) {
  console.log("This will never be logged");
}
```

```json
{
  "kind": 0,
  "message": {
    "id": "noOverlapBooleanExpression",
    "description": "This condition will always return the same value since the types have no overlap."
  },
  "file_path": "/path/to/tsgolint/test.ts",
  "labeled_ranges": [
    { "label": "true", "range": { "pos": 62, "end": 66 } },
    { "label": "string", "range": { "pos": 70, "end": 76 } }
  ],
  "rule": "no-unnecessary-condition"
}
```
@camchenry
Copy link
Member Author

camchenry commented Feb 11, 2026

@camc314 Since oxc-project/tsgolint#651 merged, we'll need to get this in for the next oxlint release, if you have a chance to review.

@camchenry
Copy link
Member Author

This seemed to be working fine when I was testing manually. I don't think there should be any backwards incompatible changes, here so going to go ahead and merge this so we can have it ready for the next tsgolint+oxlint release.

@camchenry camchenry added the 0-merge Merge with Graphite Merge Queue label Feb 13, 2026
Copy link
Member Author

camchenry commented Feb 13, 2026

Merge activity

  • Feb 13, 4:33 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Feb 13, 4:33 AM UTC: camchenry added this pull request to the Graphite merge queue.
  • Feb 13, 4:38 AM UTC: The Graphite merge queue couldn't merge this PR because it was not satisfying all requirements (Failed CI: 'Test Linux').
  • Feb 13, 4:49 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Feb 13, 4:54 AM UTC: camchenry added this pull request to the Graphite merge queue.
  • Feb 13, 4:54 AM UTC: Merged by the Graphite merge queue.

graphite-app bot pushed a commit that referenced this pull request Feb 13, 2026
…gnostics (#19201)

- related to oxc-project/tsgolint#650

This adds support for labeled ranges coming from `tsgolint`. In some cases, this might mean the primary span is also completely zeroed out, indicating that labeled ranges are the only source of labels.

Before:

<img width="917" height="104" alt="Screenshot 2026-02-10 at 9 27 20 PM" src="https://github.com/user-attachments/assets/72102616-5bda-4306-bfcb-7ebfaadaef29" />

After:

<img width="925" height="128" alt="Screenshot 2026-02-10 at 9 26 49 PM" src="https://github.com/user-attachments/assets/26de8958-a52b-4157-921a-060e5280dfcc" />
@graphite-app graphite-app bot force-pushed the 02-09-feat_linter_tsgolint_add_support_for_labeled_ranges_in_tsgolint_diagnostics branch from 09b0e93 to e476382 Compare February 13, 2026 04:33
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Feb 13, 2026
…gnostics (#19201)

- related to oxc-project/tsgolint#650

This adds support for labeled ranges coming from `tsgolint`. In some cases, this might mean the primary span is also completely zeroed out, indicating that labeled ranges are the only source of labels.

Before:

<img width="917" height="104" alt="Screenshot 2026-02-10 at 9 27 20 PM" src="https://github.com/user-attachments/assets/72102616-5bda-4306-bfcb-7ebfaadaef29" />

After:

<img width="925" height="128" alt="Screenshot 2026-02-10 at 9 26 49 PM" src="https://github.com/user-attachments/assets/26de8958-a52b-4157-921a-060e5280dfcc" />
@camchenry camchenry force-pushed the 02-09-feat_linter_tsgolint_add_support_for_labeled_ranges_in_tsgolint_diagnostics branch from e476382 to be0ce50 Compare February 13, 2026 04:48
@github-actions github-actions bot added the A-cli Area - CLI label Feb 13, 2026
@camchenry camchenry added the 0-merge Merge with Graphite Merge Queue label Feb 13, 2026
@graphite-app graphite-app bot merged commit be0ce50 into main Feb 13, 2026
30 checks passed
@graphite-app graphite-app bot deleted the 02-09-feat_linter_tsgolint_add_support_for_labeled_ranges_in_tsgolint_diagnostics branch February 13, 2026 04:54
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Feb 13, 2026
camc314 pushed a commit that referenced this pull request Feb 16, 2026
# Oxlint
### 💥 BREAKING CHANGES

- 7711821 oxlint: [**BREAKING**] `no-shadow-restricted-names` report
`globalThis` by default (#19407) (Sysix)

### 🚀 Features

- ce1baa0 linter: Implement eslint/no-shadow (#18979) (Víctor Fernández)
- 7a333c1 linter: Support dynamic configs via CLI arguments (#19384)
(camc314)
- 1bf569b linter: Implement typescript/unified-signatures (#19375)
(camc314)
- 6562a9b linter: Implement typescript/parameter-properties (#19374)
(camc314)
- 94d8d74 linter: Implement typescript/no-use-before-define (#19373)
(camc314)
- 80b002a linter: Implement fixer for unicorn/no-instanceof-builtins
(#19371) (camc314)
- 5c3784b linter: Implement eslint/no-unmodified-loop-condition (#19341)
(Vincent R)
- cc00a59 linter/const-comparisons: Improve diagnostics when mixing
logical/comparison operators (#19370) (camc314)
- ea2c401 linter: Add support for no constructed context values (#18067)
(Jovi De Croock)
- f2440eb linter: Mark eslint/no-return-assign as having no fixer
(#19327) (camc314)
- 8588670 linter/unicorn: Implement suggestion for
`unicorn/no-await-in-promise-methods` rule (#19359) (Mikhail Baev)
- f0af965 linter: Move `jsx-a11y/no-static-element-interactions` rule
out of the nursery. (#19355) (connorshea)
- be0ce50 linter/tsgolint: Add support for labeled ranges in tsgolint
diagnostics (#19201) (camchenry)
- b5bc900 linter: Implement fixer for unicorn/no-new-buffer (#19326)
(camc314)
- 1612932 linter: Add typescript/no-unnecessary-condition (#19130)
(camc314)
- 37dc6c5 linter: Implement fixer for unicorn/prefer-includes (#19323)
(camc314)

### 🐛 Bug Fixes

- c2b1870 linter: Enforce config options for `react/forbid-dom-props`
rule. (#19387) (connorshea)
- 3d24e44 linter: Honor no-empty-function allow getters/setters for
object literals (#19393) (camc314)
- bbced8d linter: Enforce config options for `eslint/no-empty-function`
rule, improve docs. (#19390) (connorshea)
- 6bc8aec linter: Fix the behavior of `import/extensions` rule for a
file that has multiple extensions. (#18919) (connorshea)
- c62a295 linter/img-redundant-alt: Enforce whole-word matching for
redundant alt text (#19367) (camc314)
- 98956fe linter/describe-function-title: Skip autofix for type-only
imports (#19329) (camc314)
- d96d26d linter/plugins: Provide `parser.version` (#19364)
(overlookmotel)
- 81f0039 linter_codegen: Compute rule IDs relative to previous rule
(#19350) (camchenry)
- b7ef0a8 linter/consistent-indexed-object-style: Avoid unsafe Record
conversions for mapped types (#19320) (camc314)

### 📚 Documentation

- 3a6059f linter: Improve docs for `eslint/require-await` rule. (#19361)
(connorshea)
- b069269 linter/plugins: Add comment about deprecated `ScopeManager`
methods (#19363) (overlookmotel)
- 2d8aaf9 linter: Disable formatting for `eslint/no-unsafe-negation`
examples. (#19347) (connorshea)
- fb87806 linter: Ensure that we do not auto-format the docs for
`unicorn/number-literal-case` rule. (#19346) (connorshea)
- 8d3ae27 linter/typescript: Skip docs for deprecated type aware rule
options (#19324) (camc314)
# Oxfmt
### 💥 BREAKING CHANGES

- 00135b5 formatter/sort_imports: [**BREAKING**] Change default `groups`
order (#19427) (leaysgur)
- 9c34f72 formatter/sort_imports: [**BREAKING**] Report invalid group
name with renaming `side-effect` > `side_effect` (#19416) (leaysgur)

### 🚀 Features

- 4baebef formatter/sort_imports: Support `{ newlinesBetween: bool }`
inside `groups` (#19358) (leaysgur)
- d1c2fb6 formatter/sort_imports: Support `customGroups`
attributes(`selector` and `modifiers`) (#19356) (leaysgur)

### 🐛 Bug Fixes

- f084ea6 oxfmt: Explicitly pass `process.env` for the forked process
(#19380) (Long Ho)
- 2bc7a14 formatter: Arrow function body incorrectly broken when return
type has comment (#19368) (Dunqing)
- 90ec3d2 oxfmt: Update tailwind plugin which fixes crash on non-js file
(#19353) (leaysgur)
- e9c5b1e formatter: Treat `PrivateFieldExpression` as simple call
argument (#19348) (Dunqing)
- 80643d5 formatter: Match Prettier union indentation with leading
comments (#19271) (Dunqing)

### ⚡ Performance

- c169c77 syntax: Optimize `is_identifier_name_patched` (#19386)
(sapphi-red)
OskarLebuda pushed a commit to OskarLebuda/oxc that referenced this pull request Feb 17, 2026
…gnostics (oxc-project#19201)

- related to oxc-project/tsgolint#650

This adds support for labeled ranges coming from `tsgolint`. In some cases, this might mean the primary span is also completely zeroed out, indicating that labeled ranges are the only source of labels.

Before:

<img width="917" height="104" alt="Screenshot 2026-02-10 at 9 27 20 PM" src="https://github.com/user-attachments/assets/72102616-5bda-4306-bfcb-7ebfaadaef29" />

After:

<img width="925" height="128" alt="Screenshot 2026-02-10 at 9 26 49 PM" src="https://github.com/user-attachments/assets/26de8958-a52b-4157-921a-060e5280dfcc" />
OskarLebuda pushed a commit to OskarLebuda/oxc that referenced this pull request Feb 17, 2026
# Oxlint
### 💥 BREAKING CHANGES

- 7711821 oxlint: [**BREAKING**] `no-shadow-restricted-names` report
`globalThis` by default (oxc-project#19407) (Sysix)

### 🚀 Features

- ce1baa0 linter: Implement eslint/no-shadow (oxc-project#18979) (Víctor Fernández)
- 7a333c1 linter: Support dynamic configs via CLI arguments (oxc-project#19384)
(camc314)
- 1bf569b linter: Implement typescript/unified-signatures (oxc-project#19375)
(camc314)
- 6562a9b linter: Implement typescript/parameter-properties (oxc-project#19374)
(camc314)
- 94d8d74 linter: Implement typescript/no-use-before-define (oxc-project#19373)
(camc314)
- 80b002a linter: Implement fixer for unicorn/no-instanceof-builtins
(oxc-project#19371) (camc314)
- 5c3784b linter: Implement eslint/no-unmodified-loop-condition (oxc-project#19341)
(Vincent R)
- cc00a59 linter/const-comparisons: Improve diagnostics when mixing
logical/comparison operators (oxc-project#19370) (camc314)
- ea2c401 linter: Add support for no constructed context values (oxc-project#18067)
(Jovi De Croock)
- f2440eb linter: Mark eslint/no-return-assign as having no fixer
(oxc-project#19327) (camc314)
- 8588670 linter/unicorn: Implement suggestion for
`unicorn/no-await-in-promise-methods` rule (oxc-project#19359) (Mikhail Baev)
- f0af965 linter: Move `jsx-a11y/no-static-element-interactions` rule
out of the nursery. (oxc-project#19355) (connorshea)
- be0ce50 linter/tsgolint: Add support for labeled ranges in tsgolint
diagnostics (oxc-project#19201) (camchenry)
- b5bc900 linter: Implement fixer for unicorn/no-new-buffer (oxc-project#19326)
(camc314)
- 1612932 linter: Add typescript/no-unnecessary-condition (oxc-project#19130)
(camc314)
- 37dc6c5 linter: Implement fixer for unicorn/prefer-includes (oxc-project#19323)
(camc314)

### 🐛 Bug Fixes

- c2b1870 linter: Enforce config options for `react/forbid-dom-props`
rule. (oxc-project#19387) (connorshea)
- 3d24e44 linter: Honor no-empty-function allow getters/setters for
object literals (oxc-project#19393) (camc314)
- bbced8d linter: Enforce config options for `eslint/no-empty-function`
rule, improve docs. (oxc-project#19390) (connorshea)
- 6bc8aec linter: Fix the behavior of `import/extensions` rule for a
file that has multiple extensions. (oxc-project#18919) (connorshea)
- c62a295 linter/img-redundant-alt: Enforce whole-word matching for
redundant alt text (oxc-project#19367) (camc314)
- 98956fe linter/describe-function-title: Skip autofix for type-only
imports (oxc-project#19329) (camc314)
- d96d26d linter/plugins: Provide `parser.version` (oxc-project#19364)
(overlookmotel)
- 81f0039 linter_codegen: Compute rule IDs relative to previous rule
(oxc-project#19350) (camchenry)
- b7ef0a8 linter/consistent-indexed-object-style: Avoid unsafe Record
conversions for mapped types (oxc-project#19320) (camc314)

### 📚 Documentation

- 3a6059f linter: Improve docs for `eslint/require-await` rule. (oxc-project#19361)
(connorshea)
- b069269 linter/plugins: Add comment about deprecated `ScopeManager`
methods (oxc-project#19363) (overlookmotel)
- 2d8aaf9 linter: Disable formatting for `eslint/no-unsafe-negation`
examples. (oxc-project#19347) (connorshea)
- fb87806 linter: Ensure that we do not auto-format the docs for
`unicorn/number-literal-case` rule. (oxc-project#19346) (connorshea)
- 8d3ae27 linter/typescript: Skip docs for deprecated type aware rule
options (oxc-project#19324) (camc314)
# Oxfmt
### 💥 BREAKING CHANGES

- 00135b5 formatter/sort_imports: [**BREAKING**] Change default `groups`
order (oxc-project#19427) (leaysgur)
- 9c34f72 formatter/sort_imports: [**BREAKING**] Report invalid group
name with renaming `side-effect` > `side_effect` (oxc-project#19416) (leaysgur)

### 🚀 Features

- 4baebef formatter/sort_imports: Support `{ newlinesBetween: bool }`
inside `groups` (oxc-project#19358) (leaysgur)
- d1c2fb6 formatter/sort_imports: Support `customGroups`
attributes(`selector` and `modifiers`) (oxc-project#19356) (leaysgur)

### 🐛 Bug Fixes

- f084ea6 oxfmt: Explicitly pass `process.env` for the forked process
(oxc-project#19380) (Long Ho)
- 2bc7a14 formatter: Arrow function body incorrectly broken when return
type has comment (oxc-project#19368) (Dunqing)
- 90ec3d2 oxfmt: Update tailwind plugin which fixes crash on non-js file
(oxc-project#19353) (leaysgur)
- e9c5b1e formatter: Treat `PrivateFieldExpression` as simple call
argument (oxc-project#19348) (Dunqing)
- 80643d5 formatter: Match Prettier union indentation with leading
comments (oxc-project#19271) (Dunqing)

### ⚡ Performance

- c169c77 syntax: Optimize `is_identifier_name_patched` (oxc-project#19386)
(sapphi-red)
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 C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments