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

Extension 'Prettier - Code formatter' is configured as formatter but it cannot format 'Svelte'-files #16093

Open
qupig opened this issue Feb 19, 2024 · 7 comments
Labels
status:needs investigation Issues that need additional investigation, e.g. to understand whether the reported behavior is a bug

Comments

@qupig
Copy link

qupig commented Feb 19, 2024

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.

@nitriques
Copy link

We are having the same problem. Reverting back to prettier 3.1.0 did fix the problem, thanks for the info @qupig .

@sosukesuzuki
Copy link
Member

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!

@sosukesuzuki sosukesuzuki added the status:needs investigation Issues that need additional investigation, e.g. to understand whether the reported behavior is a bug label Mar 9, 2024
@nitriques
Copy link

I can add more context, hoping it can help.

  1. We had issues on two macs, all with the latest vs-code and extensions.
  2. Same issues with a windows 11 box.
  3. It only for svelte files, prettier was able to format ts.
  4. I diffed 3.1 vs 3.2 and could not find anything obvious.

@sveltecult
Copy link

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.

@sosukesuzuki
Copy link
Member

prettier/prettier-vscode#3335 will solve this.

@nitriques
Copy link

That's good news !
Thanks !

@Synweigh
Copy link

Still an issue despite prettier/prettier-vscode#3335 being merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:needs investigation Issues that need additional investigation, e.g. to understand whether the reported behavior is a bug
Projects
None yet
Development

No branches or pull requests

5 participants