头图

1-vscode 中安装eslint
2-在vue项目中开启esLint检测, 在vue.config.js文件中

  lintOnSave: true,

3-下面是我vscode的配置文件settings.json文件

{
    // VScode主题配置
    "editor.tabSize": 2,
    "eslint.autoFixOnSave": true, // 每次保存的时候将代码按eslint格式进行修复
    "editor.lineHeight": 24,
    "editor.renderLineHighlight": "none",
    "editor.renderWhitespace": "none",
    "editor.fontFamily": "Consolas",
    "editor.fontSize": 13,
    "editor.cursorBlinking": "smooth",
    "editor.multiCursorModifier": "ctrlCmd",
    "editor.formatOnSave": true,
    "editor.quickSuggestions": {
        "other": true,
        "comments": true,
        "strings": false
    },
    "prettier.semi": true, //去掉代码结尾的分号
    "prettier.singleQuote": false, //使用单引号替代双引号
    "javascript.format.insertSpaceBeforeFunctionParenthesis": true, //让函数(名)和后面的括号之间加个空格
    "vetur.format.defaultFormatter.html": "js-beautify-html", //格式化.vue中html
    "vetur.format.defaultFormatterOptions": {
    "js-beautify-html": {
    "wrap_attributes": "force-aligned" //属性强制折行对齐
    }
    },
    "eslint.validate": [
        "javascript",
        "javascriptreact",
        "html",
        "vue",
    ],
    "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "debug.console.fontSize": 14,
  "git.path": "F:/Program Files/Git/bin/git.exe",  //git路径的配置
}



那年
115 声望12 粉丝