mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
feat(prettier): support format arrow function as expression (#1364)
This commit is contained in:
parent
5af76b4bcd
commit
210dbd3ff2
1 changed files with 11 additions and 1 deletions
|
|
@ -10,7 +10,17 @@ pub(super) fn print_arrow_function<'a>(
|
|||
let mut parts = p.vec();
|
||||
|
||||
parts.push(ss!("() => "));
|
||||
parts.push(expr.body.format(p));
|
||||
if expr.expression {
|
||||
let stmt = &expr.body.statements[0];
|
||||
match stmt {
|
||||
// ExpressionStatement will add a semicolon and Hardline, But we don't need it
|
||||
// So we only need to format the expression of the ExpressionStatement
|
||||
Statement::ExpressionStatement(expr_stmt) => parts.push(expr_stmt.expression.format(p)),
|
||||
_ => parts.push(stmt.format(p)),
|
||||
}
|
||||
} else {
|
||||
parts.push(expr.body.format(p));
|
||||
}
|
||||
|
||||
Doc::Array(parts)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue