fix(linter/no-var): handle TypeScript declare keyword in fixer#15426
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via 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. |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the diagnostic span positioning for the no-var rule to correctly highlight the var keyword in declarations that have preceding keywords (like declare var). Previously, the span started at the beginning of the declaration, but now it correctly locates and highlights just the var keyword.
Key changes:
- Updated span calculation to find the actual position of the "var" keyword using
find_next_token_from - Added
dec.declarecondition to the fix logic to ensuredeclare varis replaced withdeclare let(notdeclare const) - Added test case for
declare varscenario
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/oxc_linter/src/rules/eslint/no_var.rs | Implemented dynamic var keyword location finding and updated fix logic to handle declare statements correctly |
| crates/oxc_linter/src/snapshots/eslint_no_var.snap | Updated snapshot to reflect corrected diagnostic span positioning for declare var case |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging #15426 will not alter performanceComparing Summary
Footnotes
|
Merge activity
|
70c6c88 to
e32bbf6
Compare

Related #14833