vue vscode 保存时自动验证eslint规则格式化代码

在vscode setting.json中添加如下配置

希望大家快乐开发,另外vscode的git扩展功能也是不错的哦,改天再给大家分享

 "eslint.autoFixOnSave": true,
"eslint.validate": [
        "javascript",
        "javascriptreact",
        {
        "language": "html",
        "autoFix": true
        },
        {
        "language": "vue",
        "autoFix": true
        }
    ],
    "eslint.options": {
    //这里为你项目中配置的.eslintrc.js文件,这样保存时效验的规则就和项目一致了,只需轻轻一按  ctrl+s  完美格式化,麻麻再也不用担心我的格式了
        "configFile": "E:/sixi-pro/DJL/OA/OAUI3/.eslintrc.js"
    }

旧版的如果失效的话报错信息为

The setting is deprecated. Use editor.codeActionsOnSave instead with a source.fixAll.eslint member.

可更新配置为

{
  "editor.tabSize": 2,
  "editor.detectIndentation": false,
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "vetur.validation.template": false,
  "vetur.format.defaultFormatter.js": "vscode-typescript",
  "vetur.format.defaultFormatter.html": "js-beautify-html",
  "vetur.format.defaultFormatterOptions": {
    "js-beautify-html": {
      "wrap_attributes": "auto"
    },
    "prettyhtml": {
      "printWidth": 120,
      "singleQuote": false,
      "wrapAttributes": false,
      "sortAttributes": false
    }
  },
  "html.format.wrapAttributes": "auto",
  "javascript.format.insertSpaceBeforeFunctionParenthesis": true,
  "files.autoSave": "afterDelay",
  "gitlens.advanced.messages": {
    "suppressCommitHasNoPreviousCommitWarning": false,
    "suppressCommitNotFoundWarning": false,
    "suppressFileNotUnderSourceControlWarning": false,
    "suppressGitVersionWarning": false,
    "suppressLineUncommittedWarning": false,
    "suppressNoRepositoryWarning": false,
    "suppressResultsExplorerNotice": false,
    "suppressShowKeyBindingsNotice": true
  },
  "git.confirmSync": false,
  "git.enableSmartCommit": true,
  "gitlens.historyExplorer.enabled": true,
  "files.autoSaveDelay": 3000,
  "workbench.startupEditor": "newUntitledFile",
  "workbench.iconTheme": "material-icon-theme",
  "workbench.colorTheme": "dark-plus-syntax",
  "terminal.integrated.rendererType": "dom",
  "search.followSymlinks": false,
  "explorer.confirmDelete": false,
  "gitlens.views.fileHistory.enabled": true,
  "gitlens.views.lineHistory.enabled": true,
  "backgroundCover.imagePath": "c:\\Users\\ifugle\\Downloads\\img\\e649343cf9e7267c89c0b7d3a5e9024e.jpg",
  "backgroundCover.randomImageFolder": "c:\\Users\\ifugle\\Downloads\\img",
  "backgroundCover.opacity": 0.6,
  "backgroundCover.autoStatus": true,
  "sync.autoDownload": true,
  "sync.autoUpload": true,
  "sync.forceDownload": false,
  "sync.forceUpload": false,
  "sync.quietSync": true,
  "sync.gist": "f70df4488ac2ee79373df2e6e18bb70d",
  "diffEditor.ignoreTrimWhitespace": true,
  "files.associations": {
    "*.cjson": "jsonc",
    "*.wxss": "css",
    "*.wxs": "javascript"
  },
  "emmet.includeLanguages": {
    "wxml": "html"
  },
  "minapp-vscode.disableAutoConfig": true,
}

完整的配置文件请移步这里

https://blog.csdn.net/qq_39517820/article/details/81253961

你可能感兴趣的:(#,JavaScript,#,HTML+CSS,Eslint)