I work on multiple Projects (Javascript - React Native). Some use the default formatting that comes with VS Code out of the box and some use prettier.
I now want to set up VS Code, so when i save a file it applies prettier, when prettier is used in the project, else use the default styling format.
I have installed the prettier extension and have set "prettier.requireConfig": true in the settings, so that it only applies in projects with a .prettierrc file.
So right now the formatting works in the prettier projects as expected, but when i save in other projects no formatting is applied at all.
This is what i added in vs codes settings.json:
"editor.formatOnSave": true,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"prettier.requireConfig": true,
When i disable prettier and remove the defaultFormatter part, it will no longer apply prettier and use the vs code default style in all projects again.
So my question is, how can i set up vs code, so that i can use prettier properly in Projects that use it and when i have to do work in another Project i still have some basic formatting, but i don't reformat the whole file when i save.