一、ESLint安装配置
1.eslint–weiruan
2.prettier-code formatter
// setting.json文件内容
{
//ESLint 插件的配置
"editor.codeActionsOnSave": {
"source.fixAll": true,
},
// prettier 配置路径
"prettier.configPath": "C:\\Users\\24107\\.prettierrc",
"eslint.alwaysShowStatus": true,
"prettier.trailingComma": "none",
"prettier.semi": false,
// 每行文字个数超出此限制将会被迫换行
"prettier.printWidth": 300,
// 使用单引号替换双引号
"prettier.singleQuote": true,
"prettier.arrowParens": "avoid",
// 设置 .vue 文件中,HTML代码的格式化插件
"vetur.format.defaultFormatter.html": "js-beautify-html",
"vetur.ignoreProjectWarning": true,
"vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
"wrap_attributes": false
},
"prettier": {
"printWidth": 300,
"trailingComma": "none",
"semi": false,
"singleQuote": true,
"arrowParens": "avoid"
}
},
"workbench.colorTheme": "Default Dark+",
"editor.linkedEditing": true,
"workbench.iconTheme": "material-icon-theme",
"window.zoomLevel": 2,
"security.workspace.trust.untrustedFiles": "open",
"editor.tabSize": 2,
// 自动加逗号的,回到setting文件,注释掉"editor.formatOnSave": true,
// "editor.formatOnSave": true,
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
3.路径下找不到.prettierrc,自己配置一个里面写,"C:\Users\自己用户名.prettierrc"新建一个.prettierrc文件,写入如下内容
{"semi": false, "singleQuote": true, "printWidth": 300}