Skip to content

Commit 5a56cc4

Browse files
committed
fix(formatter): printing VariableDeclarator is incorrect when it is part of ForStatement
1 parent 1c21c46 commit 5a56cc4

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

crates/oxc_formatter/src/write/variable_declaration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl<'a> Format<'a> for AstNode<'a, Vec<'a, VariableDeclarator<'a>>> {
4848
let length = self.len();
4949

5050
let is_parent_for_loop = matches!(
51-
self.parent,
51+
self.parent.parent(),
5252
AstNodes::ForStatement(_) | AstNodes::ForInStatement(_) | AstNodes::ForOfStatement(_)
5353
);
5454

tasks/prettier_conformance/snapshots/prettier.js.snap.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
js compatibility: 472/699 (67.53%)
1+
js compatibility: 474/699 (67.81%)
22

33
# Failed
44

@@ -94,7 +94,6 @@ js compatibility: 472/699 (67.53%)
9494
| js/decorators-export/before_export.js | 💥 | 88.89% |
9595
| js/destructuring-ignore/ignore.js | 💥💥💥 | 83.33% |
9696
| js/explicit-resource-management/for-await-using-of-comments.js | 💥 | 0.00% |
97-
| js/explicit-resource-management/using-declarations.js | 💥 | 70.00% |
9897
| js/explicit-resource-management/valid-await-using-comments.js | 💥 | 66.67% |
9998
| js/explicit-resource-management/valid-for-await-using-binding-escaped-of-of.js | 💥 | 50.00% |
10099
| js/explicit-resource-management/valid-for-using-binding-escaped-of-of.js | 💥 | 50.00% |
@@ -182,7 +181,6 @@ js compatibility: 472/699 (67.53%)
182181
| js/try/catch.js | 💥 | 52.63% |
183182
| js/try/try.js | 💥 | 50.00% |
184183
| js/unicode/nbsp-jsx.js | 💥 | 22.22% |
185-
| js/variable_declarator/multiple.js | 💥 | 87.27% |
186184
| js/yield/jsx-without-parenthesis.js | 💥 | 50.00% |
187185
| js/yield/jsx.js | 💥 | 50.00% |
188186
| jsx/attr-element/attr-element.js | 💥 | 0.00% |

0 commit comments

Comments
 (0)