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

fmt - Error formatting Svelte 5 snippet #26324

Closed
lts20050703 opened this issue Oct 16, 2024 · 5 comments · Fixed by #26654 or #26948
Closed

fmt - Error formatting Svelte 5 snippet #26324

lts20050703 opened this issue Oct 16, 2024 · 5 comments · Fixed by #26654 or #26948
Assignees
Labels
bug Something isn't working correctly deno fmt Related to the "deno fmt" subcommand or dprint upstream Changes in upstream are required to solve these issues

Comments

@lts20050703
Copy link

Reproduction

{#snippet test()}
<div>Test</div>
{/snippet}

Expected

No errors

Actual

Error formatting: ...
   Syntax error (expected text node) at file:///...

deno --version
deno 2.0.0 (stable, release, x86_64-unknown-linux-gnu)
v8 12.9.202.13-rusty
typescript 5.6.2

@satyarohith satyarohith added bug Something isn't working correctly deno fmt Related to the "deno fmt" subcommand or dprint labels Oct 16, 2024
@satyarohith
Copy link
Member

The error I get when I format using prettier:

app.svelte
[error] app.svelte: Expected if, each or await
[error] > 1 | {#snippet test()}
[error]     |  ^
[error]   2 | <div>Test</div>
[error]   3 | {/snippet}
[error]   4 | (1:2)
[error] 1: {#snippet test()}
[error]      ^
[error] 2: <div>Test</div>
[error] 3: {/snippet}

@lts20050703
Copy link
Author

@satyarohith What's the version of prettier and prettier-plugin-svelte are you using? I'm using "prettier": "^3.3.3", "prettier-plugin-svelte": "^3.2.7" and it works fine.

@lts20050703
Copy link
Author

@satyarohith Svelte 5 just released (https://svelte.dev/blog/svelte-5-is-alive), and a fix to make this work would be greatly appreciated, as snippets is really useful to re-use HTML template code and remove duplication.

@bartlomieju bartlomieju self-assigned this Oct 24, 2024
@bartlomieju bartlomieju added the upstream Changes in upstream are required to solve these issues label Oct 26, 2024
bartlomieju added a commit that referenced this issue Nov 5, 2024
Fix #26245 
Close #26324 
Fix #26508 
Fix #26540 
Fix #26562

---------

Co-authored-by: Bartek Iwańczuk <[email protected]>
@sylc
Copy link
Contributor

sylc commented Nov 10, 2024

I'm still getting an error in deno 2.0.5 (stable, release, x86_64-pc-windows-msvc)

{#snippet test()}
  <div>Test</div>
{/snippet}
deno fmt --unstable-component
Error formatting: C:\Users\sylva\Documents\Projects\temp\deno-init\test.svelte
   Unexpected token `/`. Expected identifier, string literal, numeric literal or [ for the computed key at file:///C:/Users/sylva/Documents/Projects/temp/deno-init/test.svelte.tsx:2:21

                   <>{/snippet}</>
                      ~
Checked 4 files

@bartlomieju bartlomieju reopened this Nov 12, 2024
@sureshjoshi
Copy link

I just ran into this as well.
It looks like the rest of the fix for this is unreleased (maybe in markup_fmt 0.15.2?): g-plane/markup_fmt#73

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly deno fmt Related to the "deno fmt" subcommand or dprint upstream Changes in upstream are required to solve these issues
Projects
None yet
5 participants