Why does jsx code formatting not correctly
As you note, the Beautify extension is the root cause here (see this issue). That extension provides a document formatter that VSCode will run when you run the format command
A few options:
- Disable the extension
- Disable Beautify for just js files by removing the
js
entry from the"beautify.language"
setting - Make sure your file has a language mode of
javascriptreact
. I believe this will prevent Beautify from running on the file
Choose the language in right-bottom corner as "JavaScript React".
And a better way is to rename the js
files to jsx
.