-
-
Notifications
You must be signed in to change notification settings - Fork 542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(js_syntax): use dedicated declarations for binding patterns #1800
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ Deploy Preview for biomejs canceled.
|
Parser conformance results onjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
CodSpeed Performance ReportMerging #1800 will not alter performanceComparing Summary
|
arendjr
approved these changes
Feb 13, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven’t looked at all the code changes, but appreciate the clear explanation. Sounds like a good solution 👍
ematipico
approved these changes
Feb 13, 2024
8c257d8
to
fe914ea
Compare
8e5de09
to
54d4bb0
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-Changelog
Area: changelog
A-Core
Area: core
A-Formatter
Area: formatter
A-Linter
Area: linter
A-Parser
Area: parser
A-Tooling
Area: internal tools
A-Website
Area: website
L-JavaScript
Language: JavaScript and super languages
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fix #1648
Fix #1652.
Previously, Biome returned the parent declaration for any binding patterns.
For instance:
Because rules such as noInvalidUseBeforeDeclaration and noUnusedVariables rely on the actual declarations, this resulted in wrong false positive or wrong false negative: in the previous example,
a
is wrongly reported as unused and its use is wrongly reported as a use before declaration.Now,
a
andb
have distinct and dedicated declarations:This avoids the two previous issues.
I had to replace
JsBindingWithDefault
byJsArrayBindingPatternElement
in order to get a proper type for the declaration of an array pattern element. This makes also the CST more consistent, because is analog toJsObjectBindingPatternShorthandProperty
andJsObjectBindingPatternProperty
and it reusesJsInitializerClause
.For consistency, I also replaced
JsAssignementWithDefault
byJsArrayAssignementPatternElement
noInvalidUseBeforeDeclaration
- false-positive for param destructuring with default values #1648 and 💅noUnusedVariables
- false-positive for param destructuring if it's used as a default value for another destructured param #1652.Remaining tasks:
Test Plan