File tree 3 files changed +12
-3
lines changed
3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
10
10
- Add support for ` @zackad/prettier-plugin-twig ` ([ #308 ] ( https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/308 ) )
11
11
- Dropped support for ` @zackad/prettier-plugin-twig-melody ` ([ #308 ] ( https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/308 ) )
12
12
- Updated Prettier options types ([ #325 ] ( https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/325 ) )
13
+ - Don't remove whitespace inside template literals in Svelte ([ #332 ] ( https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/332 ) )
13
14
14
15
## [ 0.6.9] - 2024-11-19
15
16
Original file line number Diff line number Diff line change @@ -537,7 +537,7 @@ function sortTemplateLiteral(
537
537
// And does not end with a space
538
538
ignoreLast : i < node . expressions . length && ! / \s $ / . test ( quasi . value . raw ) ,
539
539
540
- collapseWhitespace : {
540
+ collapseWhitespace : collapseWhitespace && {
541
541
start : collapseWhitespace && collapseWhitespace . start && i === 0 ,
542
542
end :
543
543
collapseWhitespace &&
@@ -553,7 +553,7 @@ function sortTemplateLiteral(
553
553
ignoreFirst : i > 0 && ! / ^ \s / . test ( quasi . value . cooked ) ,
554
554
ignoreLast :
555
555
i < node . expressions . length && ! / \s $ / . test ( quasi . value . cooked ) ,
556
- collapseWhitespace : {
556
+ collapseWhitespace : collapseWhitespace && {
557
557
start : collapseWhitespace && collapseWhitespace . start && i === 0 ,
558
558
end :
559
559
collapseWhitespace &&
Original file line number Diff line number Diff line change @@ -416,7 +416,6 @@ import Custom from '../components/Custom.astro'
416
416
`<div class="sm:p-0 p-0 {someVar}sm:block md:inline flex" />` ,
417
417
`<div class="p-0 sm:p-0 {someVar}sm:block flex md:inline" />` ,
418
418
] ,
419
- [ '<div class={`sm:p-0\np-0`} />' , '<div class={`p-0 sm:p-0`} />' ] ,
420
419
t `{#await promise()} <div class="${ yes } " /> {:then} <div class="${ yes } " /> {/await}` ,
421
420
t `{#await promise() then} <div class="${ yes } " /> {/await}` ,
422
421
@@ -436,6 +435,15 @@ import Custom from '../components/Custom.astro'
436
435
437
436
// Escapes
438
437
t `<div class={"before:content-['\\\\2248']"}></div>` ,
438
+
439
+ // Preserve whitespace in template strings
440
+ // This test has lots of whitespace to ensure that the Svelte
441
+ // parser doesn't produce invalid syntax as output since it breaks
442
+ // when changing the length of the text.
443
+ [
444
+ `<div\n class={\`underline \n flex\`}></div>` ,
445
+ `<div\n class={\`flex \n underline\`}\n></div>` ,
446
+ ] ,
439
447
] ,
440
448
} ,
441
449
} ,
You can’t perform that action at this time.
0 commit comments