强迫症表示被这个搞的很烦,经常要去查到底是哪里出了问题,但是总是碍于精力不够,先留个坑在这里,有时间把 ESlint / Prettier 还有 VSCode 里的一些自动化的格式配置都重新弄一遍,现在基本上都是使用以下这个办法来解决...
首先根据网上参考的大多配置,基本没用!
最常说的就是在 Prettier 里面设置 Prettier Path 的值。如果直接在 VSCode 里面编辑,无论是 json 写进去,还是设置里面填写进去,都没用
最终解决方案,是直接在项目根目录创建 .prettierrc 文件,然后填写内容如下:
{
"printWidth": 200,
"eslintIntegration": true,
"stylelintIntegration": true,
"tabWidth": 4,
"semi": true,
"singleQuote": true,
"bracketSpacing": true,
"arrowParens": "avoid",
"htmlWhitespaceSensitivity": "ignore",
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"files.insertFinalNewline": true,
"useTabs": false,
"endOfLine": "auto",
"ignorePath": ".gnore",
"trailingComma": "none"
}