forked from oxc-project/oxc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(linter/no-unused-vars): false positive for discarded reads within…
… sequences (oxc-project#6907) Fixes a case where no-unused-vars incorectly reports a read as unused in edge cases where a logical/binary expression is used as a conditional shorthand to write a variable within sequence expressions. Some code examples will make this more clear. ```js function foo(a) { let x = somePropertyIWantToCheck(); (x in a && x.hasPropA = true, console.log(a)) } ``` Since the logical expression is not in the last position within the sequence expression list, it's getting discarded as unused. However, the right expression (`x.hasPropA = true`) has side effects, so it _is_ being used.
- Loading branch information
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
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
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
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