1、NPM安装:
npm i standard --save-dev
2、VSCode插件: StandardJS、ESLint、Prettier-Standard
3、VsCode配置文件:
{
"[html]": {
"editor.defaultFormatter": "numso.prettier-standard-vscode"
},
"[vue]": {
"editor.defaultFormatter": "numso.prettier-standard-vscode"
},
"[script]": {
"editor.defaultFormatter": "numso.prettier-standard-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "numso.prettier-standard-vscode"
},
// 保存自动修复
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"standard.autoFixOnSave": true,
"standard.options": {
"parser": "babel-eslint",
// 是否在每行结尾添加分号
"prettier.semi": false,
// 让函数(名)和后面的括号之间加个空格
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
// 如果为true将使用单引号
"prettier.singleQuote": true
}
}
4、重启VSCode
网友评论