Skip to content

Conversation

@marvinhagemeister
Copy link
Contributor

When a lint diagnostic contained an invalid range where the start value was bigger than the end value, we'd panic when passing the range to dprint. We should ensure that the range is correct right when we're creating the lint diagnostic instead.

Fixes #31249

When a lint diagnostic contained an invalid range where the `start` value was bigger than the `end` value, we'd panic when passing the range to dprint. We should ensure that the range is correct right when we're creating the lint diagnostic instead.
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 fixes a panic that occurred when a lint diagnostic contained an invalid range where the start value was greater than the end value. The fix adds early validation in the Context.report() method to throw a clear error instead of allowing the invalid range to propagate to dprint.

  • Added range validation that throws a RangeError when start > end
  • Added a test case to verify the error is thrown for invalid ranges

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cli/js/40_lint.js Added validation in the report() method to check if start > end and throw a RangeError with a descriptive message
tests/unit/lint_plugin_test.ts Added import for assertStringIncludes and created a test case that validates the error is thrown when a plugin reports an invalid range

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

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

LGTM

@marvinhagemeister marvinhagemeister merged commit 099f8d6 into main Nov 12, 2025
25 checks passed
@marvinhagemeister marvinhagemeister deleted the lint-range branch November 12, 2025 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deno panicked when running linter

4 participants