vscode格式化配置-settings.jon

准备扩展:js-beautify-html,prettier,vetur

{  
    "workbench.colorTheme": "Tiny Light",
    "workbench.iconTheme": "vscode-icons",

    "editor.detectIndentation": false,// vscode默认启用了根据文件类型自动设置tabsize的选项
    "editor.tabSize": 4,            // 重新设定tabsize
    
    // ESLint 配置代码检查
    "eslint.format.enable": false,
    "eslint.alwaysShowStatus": false,
    "eslint.quiet": false, // 忽略检查
    "eslint.validate": [
        "javascript",
        "javascriptreact",
        "typescript",
        "typescriptreact",
        "vue-html",
        "html",
        "vue"
    ],
    "eslint.run": "onType",
    "eslint.options": {
        "extensions": [
            ".js",
            ".vue",
        ],
    },

    "javascript.format.placeOpenBraceOnNewLineForControlBlocks": false, // 函数左括号{是否换行
    "javascript.format.insertSpaceBeforeFunctionParenthesis": false, // 不让函数(名)和后面的括号之间加个空格
        
    // prettier 格式化配置
    "prettier.arrowParens": "avoid", //(x) => {} 箭头函数参数只有一个时是否要有小括号。avoid:省略括号
    "prettier.bracketSpacing": true, // 在对象,数组括号与文字之间加空格 "{ foo: bar }"
    "prettier.endOfLine": "auto", // 行尾换行格式
    "prettier.jsxBracketSameLine": false, // 在jsx中把'>' 是否单独放一行
    "prettier.jsxSingleQuote": true,  // 在jsx中使用单引号代替双引号
    "prettier.printWidth": 100,  // 超过最大值换行
    "prettier.singleQuote": true, //使用单引号而不是双引号
    "prettier.semi": true,  //在语句结尾处加分号
    "prettier.tabWidth": 4, // 缩进字节数
    "prettier.trailingComma": "none", //禁止随时添加逗号
    "prettier.useTabs": false, // 缩进不使用tab,使用空格

    //.vue文件template格式化支持,并使用js-beautify-html插件
    "vetur.format.defaultFormatter.html": "js-beautify-html",
    "vetur.format.defaultFormatter.js": "prettier",
    "vetur.format.defaultFormatter.less": "prettier",
    "vetur.format.defaultFormatter.css": "prettier",
    "vetur.format.options.tabSize": 4,   //缩进为4
    "vetur.format.options.useTabs": false,
    "vetur.format.defaultFormatterOptions": {
        //js-beautify-html格式化配置
        "js-beautify-html": {
            "wrap_attributes": "force-aligned" // 属性强制换行
        },
        "prettier": {
            "arrowParens": "avoid",    //(x) => {} 箭头函数参数只有一个时是否要有小括号。avoid:省略括号
            "bracketSpacing": true,  // 在对象,数组括号与文字之间加空格 "{ foo: bar }"
            "endOfLine": "auto",   // 行尾换行格式
            "eslintIntegration": false, //不让prettier使用eslint的代码格式进行校验   
            "jsxBracketSameLine": false, // 在jsx中把'>' 是否单独放一行
            "jsxSingleQuote": false, // 在jsx中使用单引号代替双引号
            "printWidth": 100,    // 超过最大值换行
            "singleQuote": true, //使用单引号而不是双引号
            "semi": true, //在语句结尾处加分号
            "tabWidth": 4,  //缩进字节数
            "trailingComma": "none", //禁止随时添加逗号
            "tslintIntegration": false,  // 不让prettier使用tslint的代码格式进行校验
            "useTabs": false // 缩进不使用tab,使用空格
        }
    },
    // 每一种语言的默认格式化规则
    "[html]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[javascript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[less]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[css]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "prettier.useEditorConfig": false 
}
posted @ 2021-06-24 20:10  kilig-wu  阅读(764)  评论(0编辑  收藏  举报