prettier
prettier copied to clipboard
Extension 'Prettier - Code formatter' is configured as formatter but it cannot format 'Svelte'-files
I know that this issue is related to prettier-plugin-svelte
, Svelte for VS Code
, prettier-vscode
.
But the issue is posted in this repo because this is where the damage is directly caused.
After my repeated testing, this issue occurred when prettier
was updated to 3.1.1, and also exists in 3.2.0 or the latest 3.2.5 version.
In other words, the last working version was prettier v3.1.0
Specific issue manifestations:
Upgrading to prettier
3.1.1 or newer versions with only the prettier-vscode
plug-in installed will cause the Format Document
menu to disappear in svelte files.
If the Svelte for VS Code
plug-in is installed at the same time, the error message in the title will be prompted after clicking the Format Document
menu.
It looks like the issue is that after prettier
was updated to 3.1.1, the svelte
support provided by prettier-plugin-svelte
was not fed back to the prettier-vscode
plugin while the config file remained unchanged.
vscode settings
{
"[svelte]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
.prettierrc.json
{
"plugins": ["prettier-plugin-svelte"],
}
It will work fine via the prettier command line or specifying the vscode formatter as Svelte for VS Code
, but it has nothing to do with this issue.
We are having the same problem. Reverting back to prettier 3.1.0 did fix the problem, thanks for the info @qupig .
We are having the same problem. Reverting back to prettier 3.1.0 did fix the problem, thanks for the info @qupig .
It is strange that there is a difference in behavior between 3.1 and 3.2, we need to look into it!
I can add more context, hoping it can help.
- We had issues on two macs, all with the latest vs-code and extensions.
- Same issues with a windows 11 box.
- It only for svelte files, prettier was able to format ts.
- I diffed 3.1 vs 3.2 and could not find anything obvious.
This is indeed strange. I have a project that uses ^3.0.2
and it's perfectly working. Now, I started a new project and it has ^3.2.5
and it can't format .php
or .svelte
files even when I'm using the same .prettierrc.js
. It's as if it's not reading the config files nor running the plugins.
https://github.com/prettier/prettier-vscode/pull/3335 will solve this.
That's good news ! Thanks !
Still an issue despite https://github.com/prettier/prettier-vscode/pull/3335 being merged.
Having done some testing in the latest environment, it seems that v3.3.3 can no longer reproduce the issue, nor even v3.1.1 where the issue originally occurred.
Seems to have been fixed by prettier-vscode
(I'm guessing)?
If everyone can also confirm that this issue has been resolved, I will close the issue?
im having this issue with latest vsc + "prettier": "3.3.3"
@aplotor Same version, but I don't seem to be reproducing the issue anymore.
Just in case, check if you have the latest prettier-vscode
extension?
@qupig thanks, actually its working. i had to npm install prettier-plugin-svelte
. i originally only wanted to use prettier-plugin-tailwindcss
but it doesnt work w/o the prior i guess
@aplotor Of course, prettier
cannot parse your svelte
file without it.
It looks like this issue no longer exists and I'll close it.