Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling of multiple HTML comments on top of file #291

Closed
hgiesel opened this issue Apr 25, 2022 · 3 comments · Fixed by #357
Closed

Handling of multiple HTML comments on top of file #291

hgiesel opened this issue Apr 25, 2022 · 3 comments · Fixed by #357
Labels
bug Something isn't working

Comments

@hgiesel
Copy link

hgiesel commented Apr 25, 2022

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 hgiesel changed the title Handling of multiple HTML comments Handling of multiple HTML comments on top of file Apr 25, 2022
@Conduitry
Copy link
Member

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 Conduitry added the bug Something isn't working label Apr 25, 2022
@hgiesel
Copy link
Author

hgiesel commented Apr 25, 2022

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

@dummdidumm
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants