From 0afb1a233f0acf91d078b1b71dab3e78f0869fe9 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 20:15:36 +0000 Subject: [PATCH] [autofix.ci] apply automated fixes --- crates/oxc_prettier/src/format/class.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/crates/oxc_prettier/src/format/class.rs b/crates/oxc_prettier/src/format/class.rs index f83586dbf79cbd..0de0e8f9c3e196 100644 --- a/crates/oxc_prettier/src/format/class.rs +++ b/crates/oxc_prettier/src/format/class.rs @@ -5,7 +5,11 @@ use oxc_span::GetSpan; use super::assignment::AssignmentLikeNode; use crate::{ - array, doc::{Doc, DocBuilder, Group, IfBreak, Line}, format::{assignment, Separator}, group, hardline, if_break, indent, indent_if_break, line, softline, space, ss, Format, Prettier, + array, + doc::{Doc, DocBuilder, Group, IfBreak, Line}, + format::{assignment, Separator}, + group, hardline, if_break, indent, indent_if_break, line, softline, space, ss, Format, + Prettier, }; pub(super) fn print_class<'a>(p: &mut Prettier<'a>, class: &Class<'a>) -> Doc<'a> { @@ -15,9 +19,10 @@ pub(super) fn print_class<'a>(p: &mut Prettier<'a>, class: &Class<'a>) -> Doc<'a // Keep old behaviour of extends in same line // If there is only on extends and there are not comments - // ToDo: implement comment checks + // ToDo: implement comment checks // @link https://github.com/prettier/prettier/blob/aa3853b7765645b3f3d8a76e41cf6d70b93c01fd/src/language-js/print/class.js#L62 - let group_mode = class.super_class.is_some() || class.implements.as_ref().map(|v| !v.is_empty()).unwrap_or(false); + let group_mode = class.super_class.is_some() + || class.implements.as_ref().map(|v| !v.is_empty()).unwrap_or(false); if let Some(params) = &class.type_parameters { group_parts.push(params.format(p)); @@ -33,7 +38,7 @@ pub(super) fn print_class<'a>(p: &mut Prettier<'a>, class: &Class<'a>) -> Doc<'a if let Some(super_type_parameters) = &class.super_type_parameters { extend_parts.push(super_type_parameters.format(p)); } - + if group_mode { heritage_clauses_parts.push(group!(p, softline!(), Doc::Array(extend_parts))) } else { @@ -61,12 +66,12 @@ pub(super) fn print_class<'a>(p: &mut Prettier<'a>, class: &Class<'a>) -> Doc<'a } parts.push(ss!("class ")); - + if let Some(id) = &class.id { parts.push(id.format(p)); parts.push(space!()); } - + if group_mode { let printend_parts_group = if should_indent_only_heritage_clauses(class) { array!(p, Doc::Array(group_parts), indent!(p, Doc::Array(heritage_clauses_parts))) @@ -382,17 +387,17 @@ fn print_heritage_clauses_implements<'a>(p: &mut Prettier<'a>, class: &Class<'a> } if should_indent_only_heritage_clauses(class) { - parts.push(Doc::IfBreak(IfBreak{ + parts.push(Doc::IfBreak(IfBreak { break_contents: p.boxed(ss!("")), flat_content: p.boxed(softline!()), - group_id: None // ToDo - how to attach group id + group_id: None, // ToDo - how to attach group id })); } else { parts.extend(hardline!()); } parts.push(ss!("implements ")); - + let implements_docs = implements.iter().map(|v| v.format(p)).collect(); parts.push(indent!(p, group!(p, Doc::Array(p.join(Separator::CommaLine, implements_docs)))));