1. 程式人生 > >eslint+vuter+prettier 自動格式化程式碼配置

eslint+vuter+prettier 自動格式化程式碼配置

{ "workbench.editor.enablePreview": false, //開啟檔案不覆蓋 "search.followSymlinks": false, //關閉rg.exe程序 "editor.minimap.enabled": false, //關閉快速預覽 "liveServer.settings.donotShowInfoMsg": true, //關閉liveserver提示 "files.autoSave": "afterDelay", //開啟自動儲存 "editor.fontSize": 16, //設定文字大小 "editor.lineHeight": 24
, //設定文字行高 "editor.lineNumbers": "on", //開啟行數提示 "editor.quickSuggestions": { //開啟自動顯示建議 "other": true, "comments": true, "strings": true }, "workbench.colorTheme": "Darcula Theme from IntelliJ", //指定工作臺中使用的顏色主題"window.zoomLevel": 0, // 調整視窗的縮放級別 "editor.tabSize": 2, //製表符符號eslint
"editor.formatOnSave": true, //每次儲存自動格式化 "eslint.autoFixOnSave": true, // 每次儲存的時候將程式碼按eslint格式進行修復 "prettier.eslintIntegration": true, //讓prettier使用eslint的程式碼格式進行校驗 "prettier.semi": false, //去掉程式碼結尾的分號 "prettier.singleQuote": true, //使用帶引號替代雙引號 "javascript.format.insertSpaceBeforeFunctionParenthesis"
: true, //讓函式(名)和後面的括號之間加個空格 "vetur.format.defaultFormatter.html": "js-beautify-html", //格式化.vue中html "vetur.format.defaultFormatter.js": "vscode-typescript", //讓vue中的js按編輯器自帶的ts格式進行格式化 "vetur.format.defaultFormatterOptions": { "js-beautify-html": { "wrap_attributes": "force-aligned" //屬性強制折行對齊 } }, "eslint.validate": [ //開啟對.vue檔案中錯誤的檢查 "javascript", "javascriptreact", { "language": "html", "autoFix": true }, { "language": "vue", "autoFix": true } ],}


在.eslintrc.js新增

'no-unreachable': 0 //防止使用swtich語句 語法檢查報錯

注意:eslint, prettier-Code formatter  ,vetur 這三個外掛必須安裝,其他的外掛根據自己的習慣