prettier-plugin-svelte icon indicating copy to clipboard operation
prettier-plugin-svelte copied to clipboard

Handling of multiple HTML comments on top of file

Open hgiesel opened this issue 3 years ago • 2 comments

Scenario: I try to write to comments on the top of the svelte file.

Expected behavior: They are preserved. Actual behavior: prettier-plugin-svelte seems to push one off and places it before the template part:

diff --git a/ts/editor/image-overlay/WithImageConstrained.svelte b/ts/editor/image-overlay/WithImageConstrained.svelte
index 50abe8bdf..13e8e2a40 100644
--- a/ts/editor/image-overlay/WithImageConstrained.svelte
+++ b/ts/editor/image-overlay/WithImageConstrained.svelte
@@ -1,8 +1,4 @@
 <!--
-Copyright: ...
-License: ...
--->
-<!--
 @component
 My comp
 -->
@@ -202,6 +198,12 @@ My comp
     }
 </script>
 
+<!--
+Copyright: ...
+License: ...
+-->
+
+
 {#if activeImage}
     <slot {toggleActualSize} {active} />
 {/if}

Related (?): #258

hgiesel avatar Apr 25 '22 18:04 hgiesel

I just ran into this last week, actually. I ended up just combining the comments into a single comment so that it would stay at the top of the file.

Conduitry avatar Apr 25 '22 18:04 Conduitry

However I noticed that it will then show the copyright + license in the tooltip for the component.

hgiesel avatar Apr 25 '22 19:04 hgiesel

There's now a none option for the sort order which will not reorder anything. As for the bug: The best solution would probably to only change the current logic to "keep all comments except <!-- prettier-ignore -->" where they are when reordering.

dummdidumm avatar Mar 15 '23 11:03 dummdidumm