diff --git a/crates/oxc_prettier/src/format/arrow_function.rs b/crates/oxc_prettier/src/format/arrow_function.rs index d74bef1d0..e3c966b7b 100644 --- a/crates/oxc_prettier/src/format/arrow_function.rs +++ b/crates/oxc_prettier/src/format/arrow_function.rs @@ -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) }