Skip to content

Code sections removed when formatting file with syntax errors #492

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

Open
BernieSumption opened this issue Apr 25, 2025 · 0 comments
Open

Comments

@BernieSumption
Copy link

Given the following invalid code (invalid because an {:else} block comes before a {:else if} block):

{#if condition === 0}
  A
{:else}
  REMOVED
{:else if condition === 1}
  ELIF
{/if}

Running prettier with prettier-plugin-svelte enabled on this file removes the section marked REMOVED.

This can lead to code being deleted if a file is saved and auto-formatted mid-way through refactoring.

I would expect that formatting a Svelte file with syntax errors had no effect, which is the behaviour for JavaScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant