Skip to content

Code sections removed when formatting file with syntax errors #492

Open
@BernieSumption

Description

@BernieSumption

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions