-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Format on Save (prettier) stopped working with latest update #108447
Comments
Same problem |
Same thing happened to me just now. I set prettier as the Default Formatter in Settings and it started working again. My Default Formatter was null. |
Worked for me, thank you! |
Yes, it worked as default formatter, but surely I shouldn't have to set default formatter for vscode. It should be on a project by project basis. |
This worked for me also but there's some scenarios where I just want prettier for a specific project and not globally 😢 |
Same for me, selecting |
In case anyone is having issues finding the option @j-francisco explained above: File -> Preferences -> Settings (for Windows) Search for "Default Formatter". In the dropdown, prettier will show as esbenp.prettier-vscode. |
@AlissonRS Thx |
The above solution by @j-francisco and @AlissonRS fixes the prettier issue but for me, but all other language settings have been messed up too. For python, we use |
I understand the frustation from people who are dependent on this. I use other tools such as Headwind, which now does not work. |
Same here. Is it a breaking change from VS Code or is it prettier which changed its namespace/code name? |
I fixed it and now it broke again from alone, this has no effect #108447 (comment) Edit Fixed it again by directly searching Format on Save and activate it. |
So, what's the issue here? Is it that the settings ( |
@jrieken it's not related to |
Yeah, that's the question. Out of the box, |
Both in my case, first the editor.defaultFormatte was null, after I fixed it one day later the ( |
@ivanjeremic Do you use settings sync? |
Yes I do. |
I don't any settings sync and yeah my Anyway, here, since I set the right formatter, I'm good. 👍🏻 |
I am experiencing same behavior as @nicolasrouanne . If I set prettier as formatter in user settings, then only it works. If I set it only in workspace settings for my TS project, it does not work. This isn't ideal for people working on languages other than TS/JS. |
@ap00rv I have tried that and I cannot reproduce. I have prettier installed and configured to be the default formatter for typescript-files and format on save works for me. {
"editor.formatOnSave": true,
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
} Can you (or someone) share reproducible steps with me? |
Hi @jrieken , can you try using the above settings only at workspace level ( default formatter in user setting should be null) and then see what happens ? |
Yeah, that's what I have. |
ok, my apologies. It is working for me now after setting the following in workspace setting only . Sorry for the trouble.
|
All my coworkers and I are on VS Code |
Thank you, worked for me! |
Thank you!! When prettier started working again I felt like I could breath again 😂 |
Thank you for the setting, worked for me. |
@j-francisco Came in clutch, thanks |
worked as a glove, thanks |
Put this fields to settings.json "editor.defaultFormatter": "esbenp.prettier-vscode", |
参考:microsoft/vscode#108447 (comment) File -> Preferences -> Settings (for Windows) Code -> Preferences -> Settings (for Mac) Search for "Default Formatter". In the dropdown, prettier will show as esbenp.prettier-vscode.
Me too |
I'm about to roll back to the working vscode. Now it's just buggy. In some directories it does format, in others just don't. I tried: "editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSaveMode": "file" This didn't work. The funny thing is: In my node project any "format on save" work. But in my PHP project all format on all files works normaly. |
Here's what worked for me: |
My biggest problem is after setting a defaultFormatter, anything not formatted with Prettier (Go, Terraform, etc) throws "prettier can't format this file". It's odd to me that this all worked great for years, but now breaks...and even the workarounds are fragile...but this isn't a regression. I need to spend the weekend going through settings with a fine toothed comb. :-( |
I struggled with this issue as well when formatting on save with Prettier for JS and Black for Python. These settings used to coexist great but something changed. I had success by setting
|
Thank you for sharing @mddilley -- this will save my sanity, but also find the need for so much more configuration just to maintain prior behavior infuriating. Was there a technical reason for this change? Someone thought it was good DevEx? Curious minds want to know. |
no work with php, (html, css OK) |
This didn't work for me |
@xavierhazzardadmin look inside your
|
Perhaps it was only to me, but it happened because I'd forgotten to lay Once I lay the config file properly, it was all fixed. |
@paullewisn i'm no expert, just someone who finds it infuriating when i need to spend a week re-configuring a "tool" that's supposed to help make me productive :-) so maybe something in this will help you... if you haven't already, try a few things (some as a direct fix, some to prevent other problems): ctrl-, and make sure "editor: default formatter" setting is null. this is so the explicit ones you specify are in full control with no surprises. unless you only work in one language, whatever you set this to will be wrong in some files and cause confusion. double check "Editor: Format On Save" is checked while in settings, it should be per your settings.json. trust byt verify. adjust "Editor: Format On Save Mode" -- some have reported it only works properly when set to "file". in settings.json, make sure files.autoSave is off. this is called out in "Format on Save" setting description and some plugin readmes. if it still doesn't work after all that, consider having vscode run eslint, and eslint in turn call prettier...this gets the best of both tools and has ran w/o problems for years (minus the default formatter changes that broke the whole chain). if you go this route, you'll need a small amount of config for each tool + appropriate project dependencies installed. there are a lot of online articles to help with that, here's one: https://dev.to/thetinygoat/prettier-eslint-setup-for-vscode-5b6 good luck! |
Worked!!! 🍡 |
@appyofficial that will work great, until you try to work in a file prettier doesn't handle... keeping default null and having per-language settings is required if you work in languages not supported by prettier. otherwise things like terraform, go, etc. will get errors on each save about unsupported formatter. if this works for you, great... KISS. :-) |
How do you configure the config files ? should i create a .prettierrc file at the root of my project and set some of the properties suggested ?? but which ? |
@Redskinsjo that will be somewhat personal-preference/project specific, but you can start with something like: # .prettierrc
{
"printWidth": 80,
"singleQuote": true,
"tabWidth": 2,
"semi": false
}
# .prettierignore
package.json
package-lock.json then extend as needed: |
i created a .prettierrc and a .prettierignore file at the root of my project, but Prettier still doesn't work. |
This comment has been minimized.
This comment has been minimized.
Worked for me. Thanks a lot. |
Format on Save (prettier) stopped working with the latest update
Multiple time reinstalled Prettier, and checked the settings, it happened right after the update of VSCode.
https://gyazo.com/f07a3bfd0733edeed2a8d213fc3d21ac
The text was updated successfully, but these errors were encountered: