feat(prettier): improve the format of ReturnStatement to support longer width (#1336)

This commit is contained in:
Dunqing 2023-11-16 11:10:27 +08:00 committed by GitHub
parent 2bed242016
commit 8d7c0d73d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -254,8 +254,16 @@ impl<'a> Format<'a> for ReturnStatement<'a> {
parts.push(ss!("return"));
if let Some(argument) = &self.argument {
parts.push(ss!(" "));
parts.push(format!(p, argument));
parts.push(group![
p,
if_break!("("),
indent!(p, softline!(), format!(p, argument)),
softline!(),
if_break!(")")
]);
}
parts.push(p.str(";"));
parts.push(hardline!());
Doc::Array(parts)
}
}