问题描述
VSCode 中安装了 Prettier 和 ESLint 插件,在项目中使用了 .eslintrc.js 文件规范项目代码。
但是保存代码时格式化并不是按该文件的配置而是按 Prettier 的配置
问题解决
修改 Settings.json 文件
win:ctrl + shift + p
mac:command + shift + p
{
// ...
// 注意这个是 false,很大原因都是因为这个
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.format.enable": true,
"eslint.options": {
//指定vscode的eslint所处理的文件的后缀
"extensions": [".js", ".vue", ".ts", ".tsx"]
}
// ...
}