fix(linter/no-var): only fix to const if the var has an initializer#15385
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 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.
Merge activity
|
4de0f23 to
989b8e3
Compare
CodSpeed Performance ReportMerging #15385 will not alter performanceComparing Summary
Footnotes
|

fixes #15383