VScode使用ESLint时



用户设置setting.json:
//配置eslint
"eslint.autoFixOnSave" : true ,
"eslint.validate" : [
"javascript" ,
"javascriptreact" ,
"html" ,
{
"language" : "vue" ,
"autoFix" : true
}

],
"eslint.options" : {
"plugins" : [ "html" ]

},
//为了符合eslint的两个空格间隔原则
"editor.tabSize" : 4 ,

"workbench.startupEditor" : "welcomePage" ,
"vetur.format.defaultFormatter.js" : "vscode-typescript" ,
"javascript.format.insertSpaceBeforeFunctionParenthesis" : true ,
"editor.quickSuggestions" : {
"strings" : true
},
// 是否在行尾加分号
"prettier.semi" : true


eslint规则相应修改:
"indent" : [ "error" , 4 ], // 行首4个空格
"semi" : [ 2 , "always" ], //语句强制分号结尾


这样你保存时就会自动修复了。格式化时可能修复不全(待研究

基于VScode相关参考
https://www.cnblogs.com/why-not-try/p/8067559.html  这个试了格式化时和保存都可以


猜你喜欢

转载自www.cnblogs.com/liuming666/p/9712427.html