You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Svelte allows for components with two script tags, so long as one is a <script module>.
<script lang='ts' module>
...
<script lang='ts'>
If you do this however, prettier complains and will stop formatting documents, saying: ParseError: A component can only have one instance-level <script> element
The solution is to use deprecated syntax to achieve the same result:
However this produces a svelte linter warning at the top of the documents: context="module" is deprecated, use the 'module' attribute instead
After making this change, prettier formatting starts working again.
The text was updated successfully, but these errors were encountered:
This sounds like prettier is using a different Svelte version to format than what you have in your project. Make sure to follow these instructions in case you did install prettier or prettier-plugin-svelte into your local project.
Otherwise I need a reproduction to properly look into this.
I've tried pegging my prettier-plugin-svelte version to 3.3.3 with no effect. It seems specifically to have issues with svelte 5 features like runes, too.
First message should be minimum viable reproduction if used in a blank .svelte file. Does that format nicely for you?
Svelte allows for components with two script tags, so long as one is a
<script module>
.If you do this however, prettier complains and will stop formatting documents, saying:
ParseError: A component can only have one instance-level <script> element
The solution is to use deprecated syntax to achieve the same result:
However this produces a svelte linter warning at the top of the documents:
context="module" is deprecated, use the 'module' attribute instead
After making this change, prettier formatting starts working again.
The text was updated successfully, but these errors were encountered: