Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
17 changes: 17 additions & 0 deletions crates/oxc_prettier/src/needs_parens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions tasks/prettier_conformance/prettier.js.snap.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
js compatibility: 265/593 (44.69%)
js compatibility: 266/593 (44.86%)

# Failed

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5482e73

Please sign in to comment.