To format your document, press Control + Shift + P
. (For Mac users, use the Command
key instead of Control
) and search for >Format Document With...
. See if that resolves the issue.
If it works, your settings may have been overridden. Open your settings.json
file by pressing Control + ,
, then click on the open settings.json
button in the top right corner. Look at the javascriptreact
section.
Here is an example: By default, formatOnSave
is enabled for all document types, except those with a .jsx
extension where eslint
is used for formatting instead.
{
// Other settings, ignore these
// ...
"editor.formatOnSave": true,
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.formatOnSave": false
},
// Other settings, ignore these
// ...
}
You can customize the settings according to your requirements.