mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 20:32:10 +00:00
feat(prettier): add HardLine and Semicolon in ExpressionStatement (#1285)
This commit is contained in:
parent
b528af1b93
commit
c15b76b92d
2 changed files with 9 additions and 17 deletions
|
|
@ -69,7 +69,13 @@ impl<'a> Format<'a> for Statement<'a> {
|
|||
|
||||
impl<'a> Format<'a> for ExpressionStatement<'a> {
|
||||
fn format(&self, p: &mut Prettier<'a>) -> Doc<'a> {
|
||||
self.expression.format(p)
|
||||
let mut parts = p.vec();
|
||||
parts.push(self.expression.format(p));
|
||||
if p.options.semi {
|
||||
parts.push(p.str(";"));
|
||||
}
|
||||
parts.push(Doc::Hardline);
|
||||
Doc::Array(parts)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -151,19 +157,7 @@ impl<'a> Format<'a> for DoWhileStatement<'a> {
|
|||
|
||||
impl<'a> Format<'a> for ContinueStatement {
|
||||
fn format(&self, p: &mut Prettier<'a>) -> Doc<'a> {
|
||||
let mut parts = p.vec();
|
||||
parts.push(string!(p, "continue"));
|
||||
|
||||
if let Some(label) = &self.label {
|
||||
parts.push(string!(p, " "));
|
||||
parts.push(format!(p, label));
|
||||
}
|
||||
|
||||
if p.options.semi {
|
||||
parts.push(Doc::Str(";"));
|
||||
}
|
||||
|
||||
Doc::Array(parts)
|
||||
Doc::Line
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
Compatibility: 0/173 (0.00%)
|
||||
Compatibility: 2/173 (0.01%)
|
||||
|
||||
# Failed
|
||||
|
||||
|
|
@ -11,7 +11,6 @@ Compatibility: 0/173 (0.00%)
|
|||
* arrows-bind
|
||||
* assignment
|
||||
* assignment-comments
|
||||
* assignment-expression
|
||||
* async
|
||||
* async-do-expressions
|
||||
* babel-plugins
|
||||
|
|
@ -96,7 +95,6 @@ Compatibility: 0/173 (0.00%)
|
|||
* line
|
||||
* line-suffix-boundary
|
||||
* literal
|
||||
* literal-numeric-separator
|
||||
* logical-assignment
|
||||
* logical_expressions
|
||||
* member
|
||||
|
|
|
|||
Loading…
Reference in a new issue