I am trying to add configurations to my project so that the code auto formats. I have made some updates to the user settings in VS Code and also installed eslint and prettier.
Now whenever I try to save my code gets changer from this
<div className={style.app}>
<div className={style.mobileHeader}>
<div className={style.logoBox}>
</div>
</div>
</div>
to
<
div className = {
style.app
} >
<
div className = {
style.mobileHeader
} >
<
div className = {
style.logoBox
} >
All this added whitespace is not only unreadable buy my IDE doesn't even register it as JavaScript.
I have tried many different configurations in my .eslintrc.js or .eslintrc.json (I only have one but I have tried both naming conventions). Currently I have deleted all the content in my .eslintrc.json except for the empty brackets {}. I also recently updated my user settings to
{
"files.autoSave": "afterDelay",
"window.zoomLevel": 0,
"git.autofetch": true,
"explorer.confirmDragAndDrop": false,
"workbench.startupEditor": "welcomePage",
"dart.flutterSdkPath": "/Users/trevor/Applications/flutter",
"javascript.updateImportsOnFileMove.enabled": "always",
"python.pythonPath": "/usr/local/bin/python3",
"editor.defaultFormatter": "octref.vetur",
"vetur.format.defaultFormatter.html": "prettier",
"vetur.format.defaultFormatter.css": "prettier",
"vetur.format.defaultFormatter.postcss": "prettier",
"vetur.format.defaultFormatter.scss": "prettier",
"vetur.format.defaultFormatter.less": "prettier",
"vetur.format.defaultFormatter.stylus": "stylus-supremacy",
"vetur.format.defaultFormatter.js": "prettier",
"vetur.format.defaultFormatter.ts": "prettier",
"vetur.validation.template": false,
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"eslint.autoFixOnSave": true,
"editor.formatOnSave": true,
"eslint.validate": [{
"language": "vue",
"autoFix": true
},
{
"language": "html",
"autoFix": true
},
{
"language": "javascript",
"autoFix": true
},
{
"language": "react",
"autoFix": true
},
]
}
I am thinking something here must be causing the issue but I can't see what it would be.
I am noticing the only code that is being formatted is the code inside the return statements of my of my React pages. Other code seems uneffected.