prettier-plugin-svelte: prettier-ignore is ignored
The following snippet of code will get formatted regardless of whether the <!-- prettier-ignore -->
comment is above the line. The standard prettier html parser handles this case.
<script>
// whatever
</script>
<!-- prettier-ignore -->
<span>[</span><span>{value}</span><span>]</span>
<style>
/* whatever */
</style>
The spans need to stay on one line as this component is inside of a <pre>
tag and being on new lines modifies the outcome. (That’s a separate issue that can’t necessarily be handled by #28, so the prettier-ignores
should be respected.)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 41
- Comments: 16 (4 by maintainers)
Commits related to this issue
- Removes `<wr/>` due to `prettier` formatting. `prettier-plugin-svelte` does not respect `prettier`s ignore rules (laid out [here](https://prettier.io/docs/en/ignore). There's an open issue for that: ... — committed to philipp-tailor/svelte_sidebar by deleted user 5 years ago
- Fixes UnwrittenFun/prettier-plugin-svelte#59 — committed to RedHatter/prettier-plugin-svelte by deleted user 4 years ago
- Skip formatting <style> or <script> if unsupported language or prettier-ignored (#130) #55 #59 — committed to sveltejs/prettier-plugin-svelte by ehrencrona 4 years ago
This would be greatly appreciated…
I just had this issue when trying to inject a dynamic style tag and found this worked, no prettier-ignore required:
My other issue was that postCSS was clobbering the style tag: hiding it in the nested string got around that. Without doing that results in Prettier doing this:
It is not working for me. I updated dependencies to
and this
still wraps.
The prettier plugin seems to kick in since my
<script>
and<style>
tags get reordered properly.Is anyone else having issues with this?
Implemented in 1.1.0.
<!-- prettier-ignore -->
still does not work in:@dummdidumm Your example here does not work:
prettier still formats everything in this node… nothing I can do will prevent prettier from running in a svelte file on any line. I was attempting to do this to bypass #240 which still seems to be a bug.
#130 will fix this
So after finally getting SCSS working with svelte beta/vsCode (and wanting to use .pug, which I know is not supported atm). I looked for away to omit <template> tag from being formatted. I found this thread and tried the above and it seems to be working for me?
One thing I know that I did is make a .prettierrc in my root app folder with
Not sure that matters any though. As it seems to work in .css/.html/.svelte files shown in screencap. Any thing I can do to help just ask I will spend time(though I am quite the noob).