fix(prettier): remove unnecessary group and ident in BinaryishExpression (#1337)

This commit is contained in:
Dunqing 2023-11-16 11:16:26 +08:00 committed by GitHub
parent 8d7c0d73d1
commit b443a0798f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 13 deletions

View file

@ -2,7 +2,7 @@
use oxc_ast::ast::*;
use oxc_syntax::operator::{BinaryOperator, LogicalOperator};
use crate::{doc::Doc, group, ss, Format, Prettier};
use crate::{doc::Doc, ss, Format, Prettier};
pub enum BinaryishLeft<'a, 'b> {
Expression(&'b Expression<'a>),
@ -42,15 +42,10 @@ impl<'a> Prettier<'a> {
) -> Doc<'a> {
let mut parts = self.vec();
parts.push(left.format(self));
let mut parts_inner = self.vec();
parts_inner.push(ss!(" "));
let mut parts_inner_inner = self.vec();
parts_inner_inner.push(ss!(operator.as_str()));
parts_inner_inner.push(Doc::Line);
parts_inner_inner.push(right.format(self));
let indent = Doc::Indent(parts_inner_inner);
parts_inner.push(group!(self, indent));
parts.push(Doc::Indent(parts_inner));
Doc::Group(parts)
parts.push(ss!(" "));
parts.push(ss!(operator.as_str()));
parts.push(Doc::Line);
parts.push(right.format(self));
Doc::Array(parts)
}
}

View file

@ -1,4 +1,4 @@
Compatibility: 5/173 (2.89%)
Compatibility: 6/173 (3.47%)
# Failed
@ -140,7 +140,6 @@ Compatibility: 5/173 (2.89%)
* reserved-word
* rest
* return
* return-outside-function
* sequence-break
* sequence-expression
* shebang