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
Prettier could also format your files on save.
However, installing and enabling does not result in working.
You have to check "format on Save" in VSCode: Setting >> User >> Text Editor >> Formatting
If doing what @Simin Maleki mentioned does not solve it for you, there is a chance that your default formatter is not set:
File > Preferences > Settings > Search for "default formatter"
Make sure your Editor: Default Formatter
field is not null
but rather esbenp.prettier-vscode
and that all the languages below are ticked. This fixed my issue.
File Path:
C:\Users\pgmre\AppData\Roaming\Code\User\settings.json
Change From:
"[javascript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
},
To:
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
Note:
can you try to add this section to your user setting file?
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
// "editor.formatOnSave": true,
},
Sometimes, prettier stops working when there are syntactic errors in the code. You can view the errors by clicking on the x button on the bottom right corner beside Prettier
Enabling "format on Save" in VSCode: Setting >> User >> Text Editor >> Formatting worked for me!