diff --git a/crates/oxc_prettier/src/needs_parens.rs b/crates/oxc_prettier/src/needs_parens.rs index 0a931a716a271..054b0139997ab 100644 --- a/crates/oxc_prettier/src/needs_parens.rs +++ b/crates/oxc_prettier/src/needs_parens.rs @@ -53,6 +53,7 @@ impl<'a> Prettier<'a> { fn check_kind(&self, kind: AstKind<'a>) -> bool { let parent_kind = self.parent_kind(); + let parent_parent_kind = self.parent_parent_kind(); match kind { AstKind::NumericLiteral(literal) => { matches!(parent_kind, AstKind::MemberExpression(e) if e.object().span() == literal.span) @@ -97,6 +98,22 @@ impl<'a> Prettier<'a> { AstKind::ExpressionStatement(_) => { matches!(assign_expr.left, AssignmentTarget::ObjectAssignmentTarget(_)) } + AstKind::SequenceExpression(sequence_expr) => match parent_parent_kind { + Some(AstKind::ForStatement(for_stat)) + if for_stat + .init + .as_ref() + .is_some_and(|e| e.span() == sequence_expr.span) + || for_stat + .update + .as_ref() + .is_some_and(|e| e.span() == sequence_expr.span) => + { + false + } + + _ => true, + }, _ => true, }, AstKind::UpdateExpression(update_expr) => match parent_kind { diff --git a/tasks/prettier_conformance/prettier.js.snap.md b/tasks/prettier_conformance/prettier.js.snap.md index e37f1046755e8..3f4f16090bc4f 100644 --- a/tasks/prettier_conformance/prettier.js.snap.md +++ b/tasks/prettier_conformance/prettier.js.snap.md @@ -1,4 +1,4 @@ -js compatibility: 265/593 (44.69%) +js compatibility: 266/593 (44.86%) # Failed @@ -43,7 +43,6 @@ js compatibility: 265/593 (44.69%) * assignment/issue-6922.js * assignment/issue-7572.js * assignment/lone-arg.js -* assignment/sequence.js ### assignment-comments * assignment-comments/call.js