prettier / prettier-vscode

Visual Studio Code extension for Prettier
https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
MIT License
5.04k stars 446 forks source link

Not formating after VSCode updated to 1.5.0 #1598

Closed joubertvasc closed 3 years ago

joubertvasc commented 3 years ago

Issue Type: Bug

After update VSCode to version 1.5.0, prettier is not formating the code on file save.

Extension version: 5.7.1 VS Code version: Code 1.50.0 (93c2f0fbf16c5a4b10e4d5f89737d9c2c25488a3, 2020-10-07T06:01:33.073Z) OS version: Linux x64 5.8.10-050810-generic

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz (6 x 4300)| |GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: disabled_software
skia_renderer: enabled_on
video_decode: unavailable_off
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|1, 1, 1| |Memory (System)|30.32GB (7.22GB free)| |Process Argv|--no-sandbox --unity-launch --crash-reporter-id da7f72a0-fd1c-48f3-a2ad-fa5de17417cb| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|cinnamon| |XDG_CURRENT_DESKTOP|X-Cinnamon| |XDG_SESSION_DESKTOP|cinnamon| |XDG_SESSION_TYPE|x11|
stesvis commented 3 years ago

Same here

andystalick commented 3 years ago

When I run "Format Document" from the command palette, I get a popup that says "There are multiple formatters for .ts files, please choose a default" If I choose Prettier, it formats manually, and formatOnSave works from there on.

joubertvasc commented 3 years ago

Great! It's working again. Thank's.

Em sex., 9 de out. de 2020 às 15:40, Andrew Stalick < notifications@github.com> escreveu:

When I run "Format Document" from the command palette, I get a popup that says "There are multiple formatters for .ts files, please choose a default" If I choose Prettier, it formats manually, and formatOnSave works from there on.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/prettier/prettier-vscode/issues/1598#issuecomment-706342489, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGMHQWPIWTFRHEBN4IAUJLSJ5KIJANCNFSM4SKMLX2A .

--

Joubert Vasconcelos

kylemilloy commented 3 years ago

You can add:

"editor.defaultFormatter": "esbenp.prettier-vscode",

to settings.json and it will default to prettier on all files (js, jsx, vue, html, etc)

From there you can overwrite it with:

"[php]": {
  "editor.defaultFormatter": "junstyle.php-cs-fixer",
}

For language specific formatters.

ivanjeremic commented 3 years ago

same here Version: 1.50.0 (user setup) Commit: 93c2f0fbf16c5a4b10e4d5f89737d9c2c25488a3 Date: 2020-10-07T06:10:52.432Z Electron: 9.2.1 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Windows_NT x64 10.0.19041

BBirdselllab commented 3 years ago

Same issue here with Prettier suddenly not formating on save anymore.

VS Code
Version: 1.50.0
Commit: 93c2f0fbf16c5a4b10e4d5f89737d9c2c25488a3
MacOS 10.15.6 

Prettier
["INFO" - 10:35:14 AM] Extension Name: esbenp.prettier-vscode.
["INFO" - 10:35:14 AM] Extension Version: 5.7.1.
AdamZaczek commented 3 years ago

You can add:

"editor.defaultFormatter": "esbenp.prettier-vscode",

to settings.json and it will default to prettier on all files (js, jsx, vue, html, etc)

From there you can overwrite it with:

"[php]": {
  "editor.defaultFormatter": "junstyle.php-cs-fixer",
}

For language specific formatters.

"editor.defaultFormatter": "esbenp.prettier-vscode",

This in .vscode/settings.json works, thanks!

Suv4o commented 3 years ago

I'm facing the same issue here. After update VSCode to version 1.5.0, prettier is not formating the code on file save. I tried to add "editor.defaultFormatter": "esbenp.prettier-vscode" in settings.json file but it does't work for me. I'm using Nuxt JS.

marko-hologram commented 3 years ago

I had this strange issue where it looked like Prettier was running, but it didn't actually format my TypeScript files on save. Files just didn't change at all, but I didn't get any errors in Prettier output.

If I used "Format Document With..." command, I would get this error in a notification:

Command 'Format Document With...' resulted in an error (No loader specified for extension ".cjs", so searchPlaces item ".prettierrc.cjs" is invalid)

Adding "editor.defaultFormatter": "esbenp.prettier-vscode" in my workspace settings.json file and doing "Developer: Reload Window" command suddenly made everything work again.

oaydinyilmaz commented 3 years ago

Thanks @kylemilloy

"editor.defaultFormatter": "esbenp.prettier-vscode"

Extension worked after putting above in settings.json

settings.json paths as below in your OS:

marrkeri commented 3 years ago

(WINDOWS) CTRL + SHIFT + P image image

This helped me, but after some time I have to do Configure default again :)

ntotten commented 3 years ago

I'll try to look this week, but if somebody has time it would be great to figure out what changed in this VSCode release. I don't see anything in the release notes about changes to formatter config.

code-for-coffee commented 3 years ago

@ntotten may be worth looking into whatever affected the VS Code ESLint plugin. I use this plugin combined with yours to format. https://github.com/microsoft/vscode-eslint/ Edit:

This looks to be an issue where settings are nullified somehow. It is affecting more than one plugin but once the settings are replaced it seems to be fine. I also encountered this with the vscode-eslint plugin but updating my settings fixed both.

https://github.com/microsoft/vscode-eslint/issues/1086

jakesmith4 commented 3 years ago

I had the same problem. After the version 1.50.0 update prettier stopped formatting on save in my HTML. I put the above code in the settings.json and now everything is working just fine again. Here it is below:

"editor.defaultFormatter": "esbenp.prettier-vscode"

chunkydonut21 commented 3 years ago

Add

"editor.defaultFormatter": "esbenp.prettier-vscode", 
"[javascript]": { "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true } 

in settings.json. It fixed the issue for me.

breeze917 commented 3 years ago

i had same problem, but correct work in some files after add "editor.defaultFormatter": "esbenp.prettier-vscode", properties in setting json.

but, unfortunately does not work in .dart files

image

marko-hologram commented 3 years ago

i had same problem, but correct work in some files after add "editor.defaultFormatter": "esbenp.prettier-vscode", properties in setting json.

but, unfortunately does not work in .dart files

image

I believe Prettier doesn't support .dart files at all so it isn't really tied to this issue that's being reported.

You should probably refer to Flutter docs for dart files formatting (https://flutter.dev/docs/development/tools/formatting#automatically-formatting-code-in-vs-code).

Also, as some people mentioned above, you can target specific languages and apply another default formatter to them using this is an example:

"[php]": {
  "editor.defaultFormatter": "junstyle.php-cs-fixer",
}
radove commented 3 years ago

(WINDOWS) CTRL + SHIFT + P image image

This helped me, but after some time I have to do Configure default again :)

image

This helped me as well, remember you have to click "Configure Default Formatter..." first and then select Prettier, as shown above.

Darkzarich commented 3 years ago

After the update it seems to ignore .eslintrc.js I have in my project folder. I have set rule

"quotes": [
    "error",
    "single",
    {
        "allowTemplateLiterals": true,
        "avoidEscape": true
    }
    ],

But after formatting it uses double quotes instead... Actually it seesm there is some conflict happening in the current version: it makes it single quoted and then makes it double quoted.

breeze917 commented 3 years ago

thank you, guys.

i didn't know product do not support dart.file because it worked dart.file before update. anyway i modified setting by yours opinion, but does not solved.

thank you for comment .

phyokyawdev commented 3 years ago

Setting prettier.requireConfig value to false in Setting.json worked for me

Leafl commented 3 years ago

One thing that seemed to work for me was: (WINDOWS) [CTRL] + [SHIFT] + [P] (MAC) [CMD] + [SHIFT] + [P] searching for: >Prettier: Create Configuration File

(For Mac's the file may be hidden, to show hidden files: [CMD] +[SHIFT] + [.]

Then modifying that file based on what I had in the settings.json mentioning or under prettier

wvankuipers commented 3 years ago

Changing the config worked for one session, but after I restart the editor Prettier is again not formatting my files (on safe)

sethlivingston commented 3 years ago

Add

"editor.defaultFormatter": "esbenp.prettier-vscode", 
"[javascript]": { "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true } 

in settings.json. It fixed the issue for me.

If you've tried a number of things to troubleshoot this problem, undo those things and try just these settings. It worked for me as others have said, especially when I removed some other settings that further broke the formatter.

Deadweasel commented 3 years ago

I have had this problem for a while now, and today I tried completely resetting everything. I removed the references in Settings. I uninstalled Prettier and reloaded VSCode. Weirdly, when I searched out the extension again, VSCode still showed the thing installed and enabled globally. Uninstalled again and reloaded, and this time it did not show as Installed already when I searched it out in the Marketplace again. Installed Prettier again, and immediately it just started working. No Settings editing, no reloading, it just. Freaking. Works.

THANK DOG! :D

martimors commented 3 years ago

Works on my Windows machine, never works on Ubuntu. It worked at some point but now I've tried all of the above steps and it just refuses to work.

ntotten commented 3 years ago

Can anyone report if this is still happening? It seems like this was an issue with VS Code that has since been resolved. I was never really able to reproduce this.

wvankuipers commented 3 years ago

I have not encountered the issue since my last comment (Oct 2020)

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.