From aa0f6812fa6e3414aa2f864ed9b11bf67f7fbb32 Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Sat, 14 Jan 2023 00:42:43 -0800 Subject: [PATCH] fix ci around autofmt --- packages/autofmt/src/element.rs | 2 +- packages/autofmt/tests/samples/attributes.rsx | 13 +++++++-- packages/autofmt/tests/samples/long.rsx | 5 +++- packages/autofmt/tests/samples/reallylong.rsx | 27 +++++++++---------- packages/autofmt/tests/samples/simple.rsx | 4 ++- packages/autofmt/tests/wrong/multiexpr.rsx | 5 +++- 6 files changed, 35 insertions(+), 21 deletions(-) diff --git a/packages/autofmt/src/element.rs b/packages/autofmt/src/element.rs index 41a6d1c1c..43e556bcb 100644 --- a/packages/autofmt/src/element.rs +++ b/packages/autofmt/src/element.rs @@ -66,7 +66,7 @@ impl Writer<'_> { // check if we have a lot of attributes let attr_len = self.is_short_attrs(attributes); - let is_short_attr_list = attr_len < 80; + let is_short_attr_list = (attr_len + self.out.indent * 4) < 80; let children_len = self.is_short_children(children); let is_small_children = children_len.is_some(); diff --git a/packages/autofmt/tests/samples/attributes.rsx b/packages/autofmt/tests/samples/attributes.rsx index 68bfa33c9..fa08b1cf4 100644 --- a/packages/autofmt/tests/samples/attributes.rsx +++ b/packages/autofmt/tests/samples/attributes.rsx @@ -45,6 +45,15 @@ rsx! { a: "123" } - // Short attributes - div { a: "123", a: "123", a: "123", a: "123", a: "123", a: "123", a: "123", a: "123", a: "123" } + div { + a: "123", + a: "123", + a: "123", + a: "123", + a: "123", + a: "123", + a: "123", + a: "123", + a: "123" + } } diff --git a/packages/autofmt/tests/samples/long.rsx b/packages/autofmt/tests/samples/long.rsx index 2464a1905..c5ace9cc3 100644 --- a/packages/autofmt/tests/samples/long.rsx +++ b/packages/autofmt/tests/samples/long.rsx @@ -33,6 +33,9 @@ pub fn Explainer<'a>( } cx.render(rsx! { - div { class: "flex flex-wrap items-center dark:text-white py-16 border-t font-light", left, right } + div { class: "flex flex-wrap items-center dark:text-white py-16 border-t font-light", + left, + right + } }) } diff --git a/packages/autofmt/tests/samples/reallylong.rsx b/packages/autofmt/tests/samples/reallylong.rsx index 6de13287f..98e9765ae 100644 --- a/packages/autofmt/tests/samples/reallylong.rsx +++ b/packages/autofmt/tests/samples/reallylong.rsx @@ -1,18 +1,15 @@ pub static Icon3: Component<()> = |cx| { - cx.render(rsx!(svg { class: "w-6 h-6", - stroke_linecap: "round", - fill: "none", - stroke_linejoin: "round", - stroke_width: "2", - stroke: "currentColor", - view_box: "0 0 24 24", - path { - d: "M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2", + cx.render(rsx! { + svg { + class: "w-6 h-6", + stroke_linecap: "round", + fill: "none", + stroke_linejoin: "round", + stroke_width: "2", + stroke: "currentColor", + view_box: "0 0 24 24", + path { d: "M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2" } + circle { cx: "12", cy: "7", r: "4" } } - circle { - cx: "12", - cy: "7", - r: "4", - } - })) + }) }; diff --git a/packages/autofmt/tests/samples/simple.rsx b/packages/autofmt/tests/samples/simple.rsx index 38aaa21ca..a0e573974 100644 --- a/packages/autofmt/tests/samples/simple.rsx +++ b/packages/autofmt/tests/samples/simple.rsx @@ -37,7 +37,9 @@ rsx! { // One level compression div { - a { class: "py-2 px-3 bg-indigo-500 hover:bg-indigo-600 rounded text-xs text-white", href: "#", + a { + class: "py-2 px-3 bg-indigo-500 hover:bg-indigo-600 rounded text-xs text-white", + href: "#", "Send invitation" } } diff --git a/packages/autofmt/tests/wrong/multiexpr.rsx b/packages/autofmt/tests/wrong/multiexpr.rsx index 5732f2cdd..56c57e37e 100644 --- a/packages/autofmt/tests/wrong/multiexpr.rsx +++ b/packages/autofmt/tests/wrong/multiexpr.rsx @@ -1,5 +1,8 @@ fn ItWroks() { cx.render(rsx! { - div { class: "flex flex-wrap items-center dark:text-white py-16 border-t font-light", left, right } + div { class: "flex flex-wrap items-center dark:text-white py-16 border-t font-light", + left, + right + } }) }