vs code代码格式化配置

新版vs code 1.41.1 vetur+eslint+prettier格式化配置

{
    "workbench.iconTheme": "vscode-great-icons",
    // vscode默认启用了根据文件类型自动设置tabsize的选项
    "editor.detectIndentation": false,
    // 重新设定tabsize
    "editor.tabSize": 4,
    // #每次保存的时候自动格式化 
    "editor.formatOnSave": true,
    // #每次保存的时候将代码按eslint格式进行修复
    "editor.codeActionsOnSave": {
        "source.fixAll": true
    },
    "eslint.validate": [ //开启对.vue文件中错误的检查
        "javascript",
        "javascriptreact",
        "html",
        "vue",
    ],
    "javascript.format.insertSpaceBeforeFunctionParenthesis": true,
    "vetur.format.defaultFormatter.js": "prettier-eslint",
    "vetur.format.defaultFormatterOptions": {
        "prettyhtml": {
            "printWidth": 130, // No line exceeds 100 characters
            "wrapAttributes": false,
            "sortAttributes": true,
            "singleQuote": false // Prefer double quotes over single quotes
        },
        "prettier": {
            "semi": false,
            "singleQuote": true,
        }
    },
    "vetur.format.options.tabSize": 4,
    "eslint.alwaysShowStatus": true,
    //关闭快速查找
    "search.followSymlinks": false,
    //关闭快速预览
    "editor.minimap.enabled": false,
    //取消自动更新
    "update.mode": "none",
    "editor.quickSuggestions": {
        "strings": true
    },
    "explorer.confirmDelete": false,
    "prettier.tabWidth": 4,
    //是否在每行末尾添加分号
    "prettier.semi": false,
    //如果为 true,将使用单引号而不是双引号
    "prettier.singleQuote": true,
    "[javascript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[vue]": {
        "editor.defaultFormatter": "octref.vetur"
    },
}

旧版vetur+eslint+prettier格式化配置

{
    // vscode默认启用了根据文件类型自动设置tabsize的选项
    "editor.detectIndentation": false,
    // 重新设定tabsize
    "editor.tabSize": 4,
    // #每次保存的时候自动格式化 
    "editor.formatOnSave": true,
    // #每次保存的时候将代码按eslint格式进行修复
    "eslint.autoFixOnSave": true,
    "eslint.validate": [ //开启对.vue文件中错误的检查
        "javascript",
        "javascriptreact",
        {
            "language": "html",
            "autoFix": true,
        },
        {
            "language": "vue",
            "autoFix": true
        }
    ],
    "javascript.format.insertSpaceBeforeFunctionParenthesis": true,
    "vetur.format.defaultFormatter.js": "vscode-typescript",
    "vetur.format.defaultFormatter.html": "js-beautify-html",
    "vetur.format.defaultFormatterOptions": {
        "js-beautify-html": {
            "wrap_attributes": "force-aligned" //属性强制折行对齐
        },
    },
    //缩进设置为4
    "prettier.tabWidth": 4,
    //去掉代码结尾的分号指js
    "prettier.semi": false,
    "prettier.singleQuote": true,
    "eslint.alwaysShowStatus": true,
    //关闭快速查找
    "search.followSymlinks": false,
    //关闭快速预览
    "editor.minimap.enabled": false,
    //取消自动更新
    "update.mode": "none",
}

你可能感兴趣的:(开发工具)