- Create a folder in the root folder of your project named
.vscode
- Create a new file inside that folder named
settings.json
- Copy/paste the following content
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit" // will automatically fix explicit eslint issues
},
"editor.quickSuggestions": {
"strings": "on"
},
"editor.formatOnSave": true, // enable format on save
// select prettier formatter for typescript and react files
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"typescript.preferences.importModuleSpecifier": "non-relative" // prevent relative imports
}
- Go to your
Settings
- Go to
Languages & Frameworks > JavaScript > Prettier
- Enable
Run on save
- Make sure that the option
Prefer Prettier configuration to IDE code style is enabled too