Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode's format-on-save setting conflicts with prettier

Our extension uses VSCode's format on save setting.

However, our extension somehow prevents prettier to run - when a file is saved, our extension is fired, but the prettier isn't. I assume that prettier uses the same setting, and that our extension is registered/fired before it.

Is there a way to not prevent prettier from running?

like image 948
pegasus Avatar asked Oct 23 '18 17:10

pegasus


People also ask

How do I get prettier to format in save VS Code?

Automatically Format Document on VS Code Using PrettierOpen the VS Code Settings menu by tapping “Command + ,(comma)” if you use a Mac. Click on “Control + ,(comma)”, if you are a Windows user. Go to the search bar and input “Editor: Format on Save.” Ensure it has a checkmark.

Why is VS Code not formatting on save?

Usage. To automatically format the file on save, In Visual Studio Code, press Control + Shift + P or Command + Shift + P (Mac) to open the command palette and type setting and then select Preferences: Open User Settings option. Search for format on save setting and check the checkbox.


1 Answers

Try it, it's working for me, and make sure esbenp.prettier-vscode is installed.

{
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.formatOnSave": false,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
}


like image 184
weiliang Avatar answered Oct 01 '22 12:10

weiliang