VSCode配置eslint

在Vue.js项目中,使用的是eslint检查。

安装插件:ESLint

vscode里打开 文件>首选项 > 设置, 在用户设置setting.json里面:可以这样设置

{
 //配置eslint
    "eslint.autoFixOnSave": true,
    "files.autoSave":"off",
    "eslint.validate": [
       "javascript",
       "javascriptreact",
       "html",
       { "language": "vue", "autoFix": true }
     ],
     "eslint.options": {
        "plugins": ["html"]
     },
     //为了符合eslint的两个空格间隔原则
     "editor.tabSize": 2   
}

这样每次保存文件(ctrl+s)时,eslint插件会自动对当前文件进行eslint语法修正!

原文地址:https://www.cnblogs.com/scale/p/9487624.html