In my Nuxt application where ESlint and Prettier are installed and enabled, I switched to Visual Studio Code editor.
When I open a .vue file and pre
For me - it was to do with ESlint which also works with Prettier. Eslint wasn't working (a local installation vs global installation conflict) which broke Prettier.
Don't forget to enable "editor.defaultFormatter" in the settings of the VSCode. In my case it was null and hence even the "editor.formatOnSave" was also not seeming to solve the issue.
How I've sorted it after having super huge frustrations with Prettier stopping working in VSCode.
VS Code
-> View
-> Command Palette
, and type: Format Document With
Configure Default Formatter...
and then choose Prettier - Code formatter
.This sorted the problem for me magically.
Depending on your case this might help you...
This is not a problem with Prettier itself, but prettier-vscode
, the VSCode extension. According to its documentation, Vue formatting is disabled by default:
prettier.disableLanguages (default: ["vue"])
A list of languages IDs to disable this extension on. Restart required. Note: Disabling a language enabled in a parent folder will prevent formatting instead of letting any other formatter to run
In this case, to enable you should set "prettier.disableLanguages": []
. And since this is an extension configuration, you should do it in VSCode settings file, not .prettierrc
.
I am not using Vue, but had the same problem.
I already had the settings
Editor: default formatter
to prettierEditor: Format on Save
to true
.eslintrc.js
and .prettierrc
files
But nothing worked.The solution to my problem was that I had all set properly, except I needed to:
Command
+ Shift
+ p
format document with
Configure Default Formatter...
Prettier
as default.I don't know why the Editor: Format on Save
set to true
was not enough.
I needed to select default formatter using the above steps so it worked.
If none of the other answers work, check that a conflicting prettier config .prettierrc
does not exist in your working directory or check for .prettierignore
to be sure the files/folders are not being ignored.