vscode 配置 eslint 自动修复
- 安装 vetur 、eslint 、prettier-code formatter
- 设置中进入 setting.json 文件,配置以下内容
{
"editor.tabSize": 2,"vetur.format.defaultFormatter.html": "prettyhtml","vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
"wrap_attributes": "auto"},"prettyhtml": {
"printWidth": 200,"singleQuote": false,"wrapAttributes": false,"sortAttributes": false},"prettier": {
"useTabs": true, "semi": false, "singleQuote": true, "trailingComma": "none" }},"editor.codeActionsOnSave": {
"source.fixAll.eslint": true},"javascript.format.insertSpaceBeforeFunctionParenthesis": true, "vetur.format.defaultFormatter.js": "vscode-typescript", "[vue]": {
"editor.defaultFormatter": "octref.vetur"},"eslint.autoFixOnSave": true, "eslint.validate": ["javascript", {
"language": "vue", "autoFix": true },"typescript" ],"tslint.autoFixOnSave": true,"typescript.updateImportsOnFileMove.enabled": "always",
}