前段时间因编辑器代码格式开发时和其他同事不一致搞得头痛,最近整理配置了下setting再也不用手动编译格式代码了,打开文件Code->首选项->设置搜索setting
配置如下
{
// "browser-preview.startUrl": "http://localhost:8080", 默认打开地址
"git.autofetch": true,
"editor.fontLigatures": null,
// 代码字体大小
"editor.fontSize": 14,
"fileheader.Author": "yuyi",
"fileheader.LastModifiedBy": "yuyi",
// 编辑器宽度自动缩放代码换行
"editor.wordWrap": "on",
// tab大小2个空格
"editor.tabSize": 2,
// 编辑器tab窗口是否显示
"workbench.editor.showTabs": true,
"terminal.integrated.defaultProfile.linux": "",
// 让函数(名)和后面的括号之间加个空格
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
// 保存自动格式化
"editor.formatOnSave": false,
// 开启vscode 文件路径导航
"breadcrumbs.enabled": true,
// prettier 设置强制单引号
"prettier.singleQuote": true,
"prettier.semi": true,
// 遵循 es5/none/all 语法中定义的尾逗号,all/es5结尾处加上尾逗号
"prettier.trailingComma": "none",
// 注释格式化
// "prettier.requirePragma": true,
// "prettier.insertPragma": false,
"vetur.format.defaultFormatter.html": "prettier",
// vetur 的自定义设置
"vetur.format.defaultFormatterOptions": {
"prettier": {
"semi": true, //无分号
"singleQuote": true, //单引号
"TrailingCooma": true, //让对象里面有个空格
"eslintIntegration": true, // 是否用eslint 整合
"trailingComma": "none",
"printWidth": 100
}
},
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.fixAll.tslint": true,
"source.fixAll.eslint": true
},
"eslint.probe": ["javascript"],
"eslint.validate": ["javascript", "vue", "html"],
"eslint.options": {
"extensions": [".js", ".vue", ".ts", ".tsx"]
},
"eslint.alwaysShowStatus": true,
"eslint.format.enable": false,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"vetur.format.options.tabSize": 2,
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"window.zoomLevel": 1,
"gitlens.views.branches.branches.layout": "list"
}