Skip to content

fix(linter/no-var): handle TypeScript declare keyword in fixer#15426

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/11-07-fix_linter_no-var_handle_typescript_declare_keyword_in_fixer
Nov 7, 2025
Merged

fix(linter/no-var): handle TypeScript declare keyword in fixer#15426
graphite-app[bot] merged 1 commit intomainfrom
c/11-07-fix_linter_no-var_handle_typescript_declare_keyword_in_fixer

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Nov 7, 2025

Related #14833

@camc314 camc314 marked this pull request as ready for review November 7, 2025 11:58
Copilot AI review requested due to automatic review settings November 7, 2025 11:58
Copy link
Contributor Author

camc314 commented Nov 7, 2025


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 C-bug Category - Bug labels Nov 7, 2025
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 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.declare condition to the fix logic to ensure declare var is replaced with declare let (not declare const)
  • Added test case for declare var scenario

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-hq
Copy link

codspeed-hq bot commented Nov 7, 2025

CodSpeed Performance Report

Merging #15426 will not alter performance

Comparing c/11-07-fix_linter_no-var_handle_typescript_declare_keyword_in_fixer (70c6c88) with main (6565dbe)

Summary

✅ 4 untouched
⏩ 33 skipped1

Footnotes

  1. 33 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.

@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Nov 7, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 7, 2025

Merge activity

@graphite-app graphite-app bot force-pushed the c/11-07-fix_linter_no-var_handle_typescript_declare_keyword_in_fixer branch from 70c6c88 to e32bbf6 Compare November 7, 2025 12:34
@graphite-app graphite-app bot merged commit e32bbf6 into main Nov 7, 2025
20 checks passed
@graphite-app graphite-app bot deleted the c/11-07-fix_linter_no-var_handle_typescript_declare_keyword_in_fixer branch November 7, 2025 12:39
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants