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

Snippets are not formatted #448

Open
hmnd opened this issue Jul 1, 2024 · 5 comments
Open

Snippets are not formatted #448

hmnd opened this issue Jul 1, 2024 · 5 comments

Comments

@hmnd
Copy link

hmnd commented Jul 1, 2024

I get the following error when I try to format a file containing a Svelte 5 snippet. I'm running the latest v3.2.5 of the plugin.

[error] /home/hmnd/dev/[myproject]/src/[myfile.svelte]: Expected if, each or await
@hmnd
Copy link
Author

hmnd commented Jul 2, 2024

Oops, I didn't include the parser override in my .prettierrc 🤦

@hmnd hmnd closed this as completed Jul 2, 2024
@hmnd
Copy link
Author

hmnd commented Jul 13, 2024

I was experiencing this again and spent a bunch of time trying to track down what was going on. I've found that formatting fails if prettier-plugin-tailwindcss is included after prettier-plugin-svelte. If I list the svelte plugin last, everything works as expected.

Perhaps it should be documented that the svelte plugin must be listed first?

@hmnd hmnd reopened this Jul 13, 2024
@jasonlyu123
Copy link
Member

prettier-plugin-tailwindcss did document that the plugin should be the last one. https://github.com/tailwindlabs/prettier-plugin-tailwindcss#compatibility-with-other-prettier-plugins

@hmnd
Copy link
Author

hmnd commented Jul 13, 2024

@jasonlyu123 didn't notice that! However, that makes this issue even more confusing. I can only get Svelte formatting to work when prettier-plugin-svelte is last, not prettier-plugin-tailwindcss. And although this results in successful formatting, prettier-plugin-tailwindcss no longer sorts classes.

Eg:

Works

{
  "plugins": [
    "prettier-plugin-tailwindcss",
    "prettier-plugin-svelte"
  ],
}

Does not work

{
  "plugins": [
    "prettier-plugin-svelte",
    "prettier-plugin-tailwindcss"
  ],
}

@freemnw
Copy link

freemnw commented Nov 9, 2024

had the same problem
This was caused by having both svelte v4 and v5 installed in my monorepo. Removed v4 and the problem went away

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

3 participants