Skip to content

fix(linter/no-var): only fix to const if the var has an initializer#15385

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/11-06-fix_linter_no-var_only_fix_to_const_if_the_var_has_an_initializer
Nov 6, 2025
Merged

fix(linter/no-var): only fix to const if the var has an initializer#15385
graphite-app[bot] merged 1 commit intomainfrom
c/11-06-fix_linter_no-var_only_fix_to_const_if_the_var_has_an_initializer

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Nov 6, 2025

fixes #15383

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

camc314 commented Nov 6, 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 6, 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 improves the no_var linter rule's auto-fix logic to correctly handle variable declarations without initializers. Previously, uninitialized variables (e.g., var foo;) were incorrectly fixed to const foo;, which would cause a syntax error since const requires an initializer. The fix ensures that any declaration containing at least one uninitialized variable uses let instead of const.

Key changes:

  • Updated the fix condition to check if all declarations have initializers before using const
  • Modified test expectations to reflect the corrected behavior for uninitialized variables
  • Added new test cases to verify proper handling of mixed initialized/uninitialized declarations

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

@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 6, 2025

Merge activity

@graphite-app graphite-app bot force-pushed the c/11-06-fix_linter_no-var_only_fix_to_const_if_the_var_has_an_initializer branch from 4de0f23 to 989b8e3 Compare November 6, 2025 15:26
@graphite-app graphite-app bot merged commit 989b8e3 into main Nov 6, 2025
20 checks passed
@graphite-app graphite-app bot deleted the c/11-06-fix_linter_no-var_only_fix_to_const_if_the_var_has_an_initializer branch November 6, 2025 15:31
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 6, 2025

CodSpeed Performance Report

Merging #15385 will not alter performance

Comparing c/11-06-fix_linter_no-var_only_fix_to_const_if_the_var_has_an_initializer (989b8e3) with main (b1d3e00)1

Summary

✅ 4 untouched
⏩ 33 skipped2

Footnotes

  1. No successful run was found on main (989b8e3) during the generation of this report, so b1d3e00 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 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.

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.

Linter fixer bug: no_var rule converts uninitialized var to const without initializer

2 participants