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

Formatting not working when {@render} is in document #2542

Open
sebwib opened this issue Oct 23, 2024 · 2 comments
Open

Formatting not working when {@render} is in document #2542

sebwib opened this issue Oct 23, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@sebwib
Copy link

sebwib commented Oct 23, 2024

Describe the bug

I use svelte 5.0.5, and the latest of all relevant packages.
I have selected "defaut formatter" to be Svelte for VS Code, version v109.1.0
If I create a +page.svelte file with this content:

<script lang="ts">
  let { children } = $props()
</script>

<div>
  <h1>
  </h1>
</div>

Then press save, it properly adds a ; to the end of the second line.
If I add this:

<script lang="ts">
  let { children } = $props()
</script>

<div>
  <h1>
    {@render children?.()}
  </h1>
</div>

It no longer adds the ;. Formatting fails when {@render children?.()} is included

Reproduction

Described above

Expected behaviour

Formatting should work when @render is used

System Info

  • OS: Mac OS
  • IDE: VSCode

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

No response

@sebwib sebwib added the bug Something isn't working label Oct 23, 2024
@vincaslt
Copy link

Check #2383 and #2462 (comment)

Basically, you'll need to update your prettier and prettier-plugin-svelte to latest versions, then create .prettierrc file in your root with:

{
  "plugins": ["prettier-plugin-svelte"],
  "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}

@sebwib
Copy link
Author

sebwib commented Oct 23, 2024

This did help, thank you!

I did find that issue but the link provided in that thread pointed to a 404
(https://github.com/sveltejs/kit/blob/main/packages/create-svelte/shared/%2Bprettier/.prettierrc)

This should be included in the official ReadMe on the homepage now that Svelte 5 is no longer a preview-package.

@jasonlyu123 jasonlyu123 pinned this issue Oct 23, 2024
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

No branches or pull requests

2 participants