• 首先在vscode商店下载ESLint
    在这里插入图片描述
  • 接下来就是进行将下面的代码配置到 .vscode
{
    "eslint.autoFixOnSave": true,
    "eslint.validate": [
        {
            "language": "vue",
            "autoFix": true
        },
        {
            "language": "html",
            "autoFix": true
        },
        {
            "language": "javascript",
            "autoFix": true
        }
    ],
    "git.autofetch": true,
    "editor.tabSize": 2,
    "files.associations": {
        "*.vue": "vue"
    },
    "eslint.autoFixOnSave": true,
    "eslint.options": {
        "extensions": [
            ".js",
            ".vue"
        ]
    },
    "eslint.validate": [
        "javascript",{
            "language": "vue",
            "autoFix": true
        },"html",
        "vue"
    ],
    "search.exclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/dist": true
    },
    "emmet.syntaxProfiles": {
        "javascript": "jsx",
        "vue": "html",
        "vue-html": "html"
    },
    "git.confirmSync": false,
    "window.zoomLevel": 0,
    "editor.renderWhitespace": "boundary",
    "editor.cursorBlinking": "smooth",
    "editor.minimap.enabled": true,
    "editor.minimap.renderCharacters": false,
    "window.title": "${dirty}${activeEditorMedium}${separator}${rootName}",
    "editor.codeLens": true,
    "editor.snippetSuggestions": "top",
    "search.location": "panel",
    "explorer.confirmDelete": false
}
  • 最后重启vscode,不规范代码会有红色下划线提示,command+s 连续保存即可

注意事项
1.低版本的vscode如下点击配置
在这里插入图片描述
2.高版本vscode按如下操作,将配置代码放入即可在这里插入图片描述
由于2020 新版本更新,需要在setting中替换成以下代码
在这里插入图片描述
在这里插入图片描述

"editor.codeActionsOnSave": {
     "source.fixAll.eslint": true,
 },
Logo

前往低代码交流专区

更多推荐