准備擴展: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
}