Skip to content

Commit

Permalink
fix: maintain parens for jsx element in member expr (dprint#584)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Nov 20, 2023
1 parent 492fe2f commit 0b44991
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/generation/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3648,8 +3648,11 @@ fn is_jsx_paren_expr_handled_node<'a>(node: Node<'a>, context: &Context<'a>) ->
return true;
}

// do not allow in expr statement, argument, attributes, or jsx exprs
!matches!(parent.kind(), NodeKind::ExprStmt | NodeKind::ExprOrSpread | NodeKind::JSXExprContainer)
// do not allow in expr statement, argument, attributes, jsx exprs, or member exprs
!matches!(
parent.kind(),
NodeKind::ExprStmt | NodeKind::ExprOrSpread | NodeKind::JSXExprContainer | NodeKind::MemberExpr
)
}

fn gen_jsx_element<'a>(node: &JSXElement<'a>, context: &mut Context<'a>) -> PrintItems {
Expand Down
7 changes: 7 additions & 0 deletions tests/specs/issues/deno/issue021279.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
== should not cause syntax error ==
const $$children = (<>{children}</>).toString();
const { getLayer } = await uno.generate($$children, { minify: true })

[expect]
const $$children = (<>{children}</>).toString();
const { getLayer } = await uno.generate($$children, { minify: true });

0 comments on commit 0b44991

Please sign in to comment.