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

Pretter is replacing HTML markup in <svelte:head> when Formatting on Save #149

Closed
ejoflo opened this issue Sep 30, 2020 · 7 comments · Fixed by sveltejs/svelte#5487
Closed

Comments

@ejoflo
Copy link

ejoflo commented Sep 30, 2020

There is a string of markup inserted by Prettier when I am attempting to save one of my Svelte components. I am running the following extensions:

Svelte for VS Code 102.1.0
Prettier - Code formatter 5.7.1

I also have the svelte.svelte-vscode selected in settings under Edtior: Default Formatter

Here is the original markup:
Screen Shot 2020-09-29 at 10 25 16 PM

When I attempt to save using the built-in "Format on Save" option using the latest Svelte Tools and Prettier, the following markup is inserted:

Screen Shot 2020-09-29 at 10 23 21 PM

@ehrencrona
Copy link
Contributor

Could you please post the complete content of a .svelte file that triggers this behavior as text?

@ejoflo
Copy link
Author

ejoflo commented Sep 30, 2020

Is it possible to post this code privately? Unfortunately I don't have permission from the client to share the codebase publicly.

@ehrencrona
Copy link
Contributor

I’d only need a single file where the issue occurs. If you can strip it down to the minimum needed for it to happen, that’s great. Feel free to replace any text or code or whatever might be sensitive.

@dummdidumm
Copy link
Member

We just need a minimum reproducible that is copy-pasteable, not the whole file or the whole project.

@ejoflo
Copy link
Author

ejoflo commented Sep 30, 2020

Okay, the code I posted in the image above can reproduce the bug. Just save as .svelte file and paste it into VS Code. Press Alt(Option)+Shift+F to format or enable Format on Save in the settings. I just tested this. If you need more I can strip it down further but this alone appears to be enough to trigger the bug.

<svelte:head>
  <style>
    body {
      overflow: hidden;
    }
  </style>
</svelte:head>

@ehrencrona
Copy link
Contributor

I can't reproduce the issue; the file formats fine for me (svelte extension 102.1.0). Weird.

@ejoflo
Copy link
Author

ejoflo commented Oct 1, 2020

This is what my .prettierrc looks like. I wonder if it would make a difference?

{
  "svelteStrictMode": true,
  "svelteSortOrder": "scripts-markup-styles",
  "tabWidth": 2,
  "singleQuote": true,
  "jsxSingleQuote": true,
  "arrowParens": "always"
}

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

Successfully merging a pull request may close this issue.

4 participants