Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Dec 22, 2022
1 parent 09e48a5 commit fc729c8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/language-js/needs-parens.js
Expand Up @@ -79,10 +79,9 @@ function needsParens(path, options) {

// `for ((let.a) of []);`
if (name === "object" && node.name === "let") {
const statement = path.findAncestor(
const expression = path.findAncestor(
(node) => node.type === "ForOfStatement"
);
const expression = statement.left;
)?.left
if (
expression &&
startsWithNoLookaheadToken(
Expand Down
Expand Up @@ -37,6 +37,9 @@ for (foo of let[a]);
for ((let.a) of foo);
for ((let[a]) of foo);
for ((let.a) in foo);
for ((let[a]) in foo);
=====================================output=====================================
for ((let) of foo);
for (foo of let);
Expand All @@ -45,5 +48,8 @@ for (foo of let[a]);
for ((let).a of foo);
for ((let)[a] of foo);
for (let.a in foo);
for ((let)[a] in foo);
================================================================================
`;
3 changes: 3 additions & 0 deletions tests/format/js/identifier/for-of/let.js
Expand Up @@ -4,3 +4,6 @@ for (foo of let.a);
for (foo of let[a]);
for ((let.a) of foo);
for ((let[a]) of foo);

for ((let.a) in foo);
for ((let[a]) in foo);

0 comments on commit fc729c8

Please sign in to comment.