From 238eed5c2c7c95ed4f2212c0055ffda3ef115058 Mon Sep 17 00:00:00 2001 From: Dylan Piercey Date: Fri, 16 Jun 2023 08:30:32 -0700 Subject: [PATCH] fix: better follow prettiers trailingComma config --- .../argument-attr.expected/auto.marko | 2 +- .../argument-attr.expected/concise.marko | 2 +- .../argument-attr.expected/html.marko | 2 +- .../argument-attr.expected/with-parens.marko | 2 +- .../argument-tag.expected/auto.marko | 2 +- .../argument-tag.expected/concise.marko | 2 +- .../argument-tag.expected/html.marko | 2 +- .../argument-tag.expected/with-parens.marko | 2 +- .../attr-with-argument.expected/auto.marko | 2 +- .../attr-with-argument.expected/concise.marko | 2 +- .../attr-with-argument.expected/html.marko | 2 +- .../with-parens.marko | 2 +- .../if-condition.expected/auto.marko | 25 +++++++++++++++++++ .../if-condition.expected/concise.marko | 23 +++++++++++++++++ .../if-condition.expected/html.marko | 25 +++++++++++++++++++ .../if-condition.expected/with-parens.marko | 25 +++++++++++++++++++ .../tag-argument.expected/auto.marko | 2 +- .../tag-argument.expected/concise.marko | 2 +- .../tag-argument.expected/html.marko | 2 +- .../tag-argument.expected/with-parens.marko | 2 +- src/__tests__/fixtures/if-condition.marko | 20 +++++++++++++++ src/index.ts | 4 +-- 22 files changed, 136 insertions(+), 18 deletions(-) create mode 100644 src/__tests__/__snapshots__/if-condition.expected/auto.marko create mode 100644 src/__tests__/__snapshots__/if-condition.expected/concise.marko create mode 100644 src/__tests__/__snapshots__/if-condition.expected/html.marko create mode 100644 src/__tests__/__snapshots__/if-condition.expected/with-parens.marko create mode 100644 src/__tests__/fixtures/if-condition.marko diff --git a/src/__tests__/__snapshots__/argument-attr.expected/auto.marko b/src/__tests__/__snapshots__/argument-attr.expected/auto.marko index 4c6252d..622b69b 100644 --- a/src/__tests__/__snapshots__/argument-attr.expected/auto.marko +++ b/src/__tests__/__snapshots__/argument-attr.expected/auto.marko @@ -3,7 +3,7 @@ { aaaaaaaaaa: 1, bbbbbbbbbb: 2, cccccccccc: 3 }, aaaaaaaaaa, bbbbbbbbbb, - cccccccccc, + cccccccccc )/> -- ${test} diff --git a/src/__tests__/__snapshots__/argument-attr.expected/concise.marko b/src/__tests__/__snapshots__/argument-attr.expected/concise.marko index c8b1e94..51cdc68 100644 --- a/src/__tests__/__snapshots__/argument-attr.expected/concise.marko +++ b/src/__tests__/__snapshots__/argument-attr.expected/concise.marko @@ -3,7 +3,7 @@ div foo( { aaaaaaaaaa: 1, bbbbbbbbbb: 2, cccccccccc: 3 }, aaaaaaaaaa, bbbbbbbbbb, - cccccccccc, + cccccccccc ) -- ${test} diff --git a/src/__tests__/__snapshots__/argument-attr.expected/html.marko b/src/__tests__/__snapshots__/argument-attr.expected/html.marko index 4c6252d..622b69b 100644 --- a/src/__tests__/__snapshots__/argument-attr.expected/html.marko +++ b/src/__tests__/__snapshots__/argument-attr.expected/html.marko @@ -3,7 +3,7 @@ { aaaaaaaaaa: 1, bbbbbbbbbb: 2, cccccccccc: 3 }, aaaaaaaaaa, bbbbbbbbbb, - cccccccccc, + cccccccccc )/> -- ${test} diff --git a/src/__tests__/__snapshots__/argument-attr.expected/with-parens.marko b/src/__tests__/__snapshots__/argument-attr.expected/with-parens.marko index 4c6252d..622b69b 100644 --- a/src/__tests__/__snapshots__/argument-attr.expected/with-parens.marko +++ b/src/__tests__/__snapshots__/argument-attr.expected/with-parens.marko @@ -3,7 +3,7 @@ { aaaaaaaaaa: 1, bbbbbbbbbb: 2, cccccccccc: 3 }, aaaaaaaaaa, bbbbbbbbbb, - cccccccccc, + cccccccccc )/> -- ${test} diff --git a/src/__tests__/__snapshots__/argument-tag.expected/auto.marko b/src/__tests__/__snapshots__/argument-tag.expected/auto.marko index 8f80b7d..474de03 100644 --- a/src/__tests__/__snapshots__/argument-tag.expected/auto.marko +++ b/src/__tests__/__snapshots__/argument-tag.expected/auto.marko @@ -3,6 +3,6 @@ { aaaaaaaaaa: 1, bbbbbbbbbb: 2, cccccccccc: 3 }, aaaaaaaaaa, bbbbbbbbbb, - cccccccccc, + cccccccccc )/> diff --git a/src/__tests__/__snapshots__/argument-tag.expected/concise.marko b/src/__tests__/__snapshots__/argument-tag.expected/concise.marko index f007c8f..ae324c3 100644 --- a/src/__tests__/__snapshots__/argument-tag.expected/concise.marko +++ b/src/__tests__/__snapshots__/argument-tag.expected/concise.marko @@ -3,6 +3,6 @@ foo( { aaaaaaaaaa: 1, bbbbbbbbbb: 2, cccccccccc: 3 }, aaaaaaaaaa, bbbbbbbbbb, - cccccccccc, + cccccccccc ) foo(a, b) diff --git a/src/__tests__/__snapshots__/argument-tag.expected/html.marko b/src/__tests__/__snapshots__/argument-tag.expected/html.marko index 8f80b7d..474de03 100644 --- a/src/__tests__/__snapshots__/argument-tag.expected/html.marko +++ b/src/__tests__/__snapshots__/argument-tag.expected/html.marko @@ -3,6 +3,6 @@ { aaaaaaaaaa: 1, bbbbbbbbbb: 2, cccccccccc: 3 }, aaaaaaaaaa, bbbbbbbbbb, - cccccccccc, + cccccccccc )/> diff --git a/src/__tests__/__snapshots__/argument-tag.expected/with-parens.marko b/src/__tests__/__snapshots__/argument-tag.expected/with-parens.marko index 8f80b7d..474de03 100644 --- a/src/__tests__/__snapshots__/argument-tag.expected/with-parens.marko +++ b/src/__tests__/__snapshots__/argument-tag.expected/with-parens.marko @@ -3,6 +3,6 @@ { aaaaaaaaaa: 1, bbbbbbbbbb: 2, cccccccccc: 3 }, aaaaaaaaaa, bbbbbbbbbb, - cccccccccc, + cccccccccc )/> diff --git a/src/__tests__/__snapshots__/attr-with-argument.expected/auto.marko b/src/__tests__/__snapshots__/attr-with-argument.expected/auto.marko index b441d52..7a9c6e1 100644 --- a/src/__tests__/__snapshots__/attr-with-argument.expected/auto.marko +++ b/src/__tests__/__snapshots__/attr-with-argument.expected/auto.marko @@ -3,5 +3,5 @@ { aaaaaaaaaa: 1, bbbbbbbbbb: 2, cccccccccc: 3 }, aaaaaaaaaa, bbbbbbbbbb, - cccccccccc, + cccccccccc )/> diff --git a/src/__tests__/__snapshots__/attr-with-argument.expected/concise.marko b/src/__tests__/__snapshots__/attr-with-argument.expected/concise.marko index 5b6fb0f..1cbedae 100644 --- a/src/__tests__/__snapshots__/attr-with-argument.expected/concise.marko +++ b/src/__tests__/__snapshots__/attr-with-argument.expected/concise.marko @@ -3,5 +3,5 @@ div foo( { aaaaaaaaaa: 1, bbbbbbbbbb: 2, cccccccccc: 3 }, aaaaaaaaaa, bbbbbbbbbb, - cccccccccc, + cccccccccc ) diff --git a/src/__tests__/__snapshots__/attr-with-argument.expected/html.marko b/src/__tests__/__snapshots__/attr-with-argument.expected/html.marko index b441d52..7a9c6e1 100644 --- a/src/__tests__/__snapshots__/attr-with-argument.expected/html.marko +++ b/src/__tests__/__snapshots__/attr-with-argument.expected/html.marko @@ -3,5 +3,5 @@ { aaaaaaaaaa: 1, bbbbbbbbbb: 2, cccccccccc: 3 }, aaaaaaaaaa, bbbbbbbbbb, - cccccccccc, + cccccccccc )/> diff --git a/src/__tests__/__snapshots__/attr-with-argument.expected/with-parens.marko b/src/__tests__/__snapshots__/attr-with-argument.expected/with-parens.marko index b441d52..7a9c6e1 100644 --- a/src/__tests__/__snapshots__/attr-with-argument.expected/with-parens.marko +++ b/src/__tests__/__snapshots__/attr-with-argument.expected/with-parens.marko @@ -3,5 +3,5 @@ { aaaaaaaaaa: 1, bbbbbbbbbb: 2, cccccccccc: 3 }, aaaaaaaaaa, bbbbbbbbbb, - cccccccccc, + cccccccccc )/> diff --git a/src/__tests__/__snapshots__/if-condition.expected/auto.marko b/src/__tests__/__snapshots__/if-condition.expected/auto.marko new file mode 100644 index 0000000..5ab7f2e --- /dev/null +++ b/src/__tests__/__snapshots__/if-condition.expected/auto.marko @@ -0,0 +1,25 @@ + + + + + + + diff --git a/src/__tests__/__snapshots__/if-condition.expected/concise.marko b/src/__tests__/__snapshots__/if-condition.expected/concise.marko new file mode 100644 index 0000000..a0cdc69 --- /dev/null +++ b/src/__tests__/__snapshots__/if-condition.expected/concise.marko @@ -0,0 +1,23 @@ +if( + thisPerson.address && + thisPerson.phone && + thisPerson.age && + thisPerson.nationality +) + person-card [ + address=thisPerson.address + phone=thisPerson.phone + age=thisPerson.age + ] + +if( + thisPerson.address && + thisPerson.phone && + thisPerson.age && + thisPerson.nationality +) + person-card [ + address=thisPerson.address + phone=thisPerson.phone + age=thisPerson.age + ] diff --git a/src/__tests__/__snapshots__/if-condition.expected/html.marko b/src/__tests__/__snapshots__/if-condition.expected/html.marko new file mode 100644 index 0000000..5ab7f2e --- /dev/null +++ b/src/__tests__/__snapshots__/if-condition.expected/html.marko @@ -0,0 +1,25 @@ + + + + + + + diff --git a/src/__tests__/__snapshots__/if-condition.expected/with-parens.marko b/src/__tests__/__snapshots__/if-condition.expected/with-parens.marko new file mode 100644 index 0000000..5ab7f2e --- /dev/null +++ b/src/__tests__/__snapshots__/if-condition.expected/with-parens.marko @@ -0,0 +1,25 @@ + + + + + + + diff --git a/src/__tests__/__snapshots__/tag-argument.expected/auto.marko b/src/__tests__/__snapshots__/tag-argument.expected/auto.marko index 57676d7..1ebaf80 100644 --- a/src/__tests__/__snapshots__/tag-argument.expected/auto.marko +++ b/src/__tests__/__snapshots__/tag-argument.expected/auto.marko @@ -3,5 +3,5 @@ { aaaaaaaaaa: 1, bbbbbbbbbb: 2, cccccccccc: 3 }, aaaaaaaaaa, bbbbbbbbbb, - cccccccccc, + cccccccccc )/> diff --git a/src/__tests__/__snapshots__/tag-argument.expected/concise.marko b/src/__tests__/__snapshots__/tag-argument.expected/concise.marko index 8d1dead..d1253d7 100644 --- a/src/__tests__/__snapshots__/tag-argument.expected/concise.marko +++ b/src/__tests__/__snapshots__/tag-argument.expected/concise.marko @@ -3,5 +3,5 @@ foo( { aaaaaaaaaa: 1, bbbbbbbbbb: 2, cccccccccc: 3 }, aaaaaaaaaa, bbbbbbbbbb, - cccccccccc, + cccccccccc ) diff --git a/src/__tests__/__snapshots__/tag-argument.expected/html.marko b/src/__tests__/__snapshots__/tag-argument.expected/html.marko index 57676d7..1ebaf80 100644 --- a/src/__tests__/__snapshots__/tag-argument.expected/html.marko +++ b/src/__tests__/__snapshots__/tag-argument.expected/html.marko @@ -3,5 +3,5 @@ { aaaaaaaaaa: 1, bbbbbbbbbb: 2, cccccccccc: 3 }, aaaaaaaaaa, bbbbbbbbbb, - cccccccccc, + cccccccccc )/> diff --git a/src/__tests__/__snapshots__/tag-argument.expected/with-parens.marko b/src/__tests__/__snapshots__/tag-argument.expected/with-parens.marko index 57676d7..1ebaf80 100644 --- a/src/__tests__/__snapshots__/tag-argument.expected/with-parens.marko +++ b/src/__tests__/__snapshots__/tag-argument.expected/with-parens.marko @@ -3,5 +3,5 @@ { aaaaaaaaaa: 1, bbbbbbbbbb: 2, cccccccccc: 3 }, aaaaaaaaaa, bbbbbbbbbb, - cccccccccc, + cccccccccc )/> diff --git a/src/__tests__/fixtures/if-condition.marko b/src/__tests__/fixtures/if-condition.marko new file mode 100644 index 0000000..713c3ca --- /dev/null +++ b/src/__tests__/fixtures/if-condition.marko @@ -0,0 +1,20 @@ + + + + + + + diff --git a/src/index.ts b/src/index.ts index 652a775..46fa15b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -363,7 +363,7 @@ export const printers: Record> = { [",", b.line], tagPath.map((it) => print(it), "arguments") ), - opts.trailingComma ? b.ifBreak(",") : "", + opts.trailingComma === "all" ? b.ifBreak(",") : "", ]), b.softline, ")", @@ -591,7 +591,7 @@ export const printers: Record> = { [",", b.line], attrPath.map((it) => print(it), "arguments") ), - opts.trailingComma ? b.ifBreak(",") : "", + opts.trailingComma === "all" ? b.ifBreak(",") : "", ]), b.softline, ")",