一、ESlint+Vetur 實現(xiàn)ESlint代碼規(guī)范
二、重點----舊版本(舊版本配置在setting.json 會出現(xiàn)警告)
{ “eslint.autoFixOnSave”: true, “eslint.validate”: [ “javascript”, { “l(fā)anguage”: “vue”, “autoFix”: true }, { “l(fā)anguage”: “html”, “autoFix”: true } ] }
三、新版配置----新版本
{ “editor.codeActionsOnSave”: { “source.fixAll.eslint”: true }, “eslint.probe”: [“javascript”, “vue”, “html”] }
以下是對自己vscode-settings.json 做一個記錄(僅供參考)
{ //設(shè)置文字大小 "editor.fontSize": 18, //設(shè)置文字行高 "editor.lineHeight": 24, //開啟行數(shù)提示 "editor.lineNumbers": "on", // 在輸入時顯示含有參數(shù)文檔和類型信息的小面板。 "editor.parameterHints.enabled": true, // 調(diào)整窗口的縮放級別 "window.zoomLevel": 0, // 文件目錄 "workbench.iconTheme": "vscode-icons", // 設(shè)置字體 "editor.fontFamily": "'Droid Sans Mono', 'Courier New', monospace, 'Droid Sans Fallback'", // 自動換行 "editor.wordWrap": "on", // 自定義vscode面板顏色 "workbench.colorCustomizations": { "tab.activeBackground": "#253046", // 活動選項卡的背景色 "activityBar.background": "#253046", //活動欄背景色 "sideBar.background": "#253046", //側(cè)邊欄背景色 "activityBar.foreground": "#23f8c8", //活動欄前景色(例如用于圖標(biāo)) "editor.background": "#292a2c" //編輯器背景顏色 // "editor.foreground":"#ff0000", //編輯器默認前景色 // "editor.findMatchBackground":"#23f8c8", //當(dāng)前搜索匹配項的顏色 // "editor.findMatchHighlightBackground":"#ff0000", //其他搜索匹配項的顏色 // "editor.lineHighlightBackground":"#ff0000", //光標(biāo)所在行高亮文本的背景顏色 // "editor.selectionBackground":"#ff0000", //編輯器所選內(nèi)容的顏色 // "editor.selectionHighlightBackground":"#ff0000", //與所選內(nèi)容具有相同內(nèi)容的區(qū)域顏色 // "editor.rangeHighlightBackground":"#ff0000", //突出顯示范圍的背景顏色,例如 "Quick Open" 和“查找”功能 // "editorBracketMatch.background":"#ff0000", //匹配括號的背景色 // "editorCursor.foreground":"#ff0000", //編輯器光標(biāo)顏色 // "editorGutter.background":"#ff0000", //編輯器導(dǎo)航線的背景色,導(dǎo)航線包括邊緣符號和行號 // "editorLineNumber.foreground":"#ff0000", //編輯器行號顏色 // "sideBar.foreground":"#ff0000", //側(cè)邊欄前景色 // "sideBarSectionHeader.background":"#ff0000", //側(cè)邊欄節(jié)標(biāo)題的背景顏色 // "statusBar.background":"#ff0000", //標(biāo)準(zhǔn)狀態(tài)欄背景色 // "statusBar.noFolderBackground":"#ff0000", //沒有打開文件夾時狀態(tài)欄的背景色 // "statusBar.debuggingBackground":"#ff0000", //調(diào)試程序時狀態(tài)欄的背景色 // "tab.activeForeground":"#ff0000", //活動組中活動選項卡的前景色 // "tab.inactiveBackground":"#ff0000", //非活動選項卡的背景色 // "tab.inactiveForeground":"#ff0000" // 活動組中非活動選項卡的前景色 }, // vscode默認啟用了根據(jù)文件類型自動設(shè)置tabsize的選項 "editor.detectIndentation": false, // 重新設(shè)定tabsize "editor.tabSize": 2, // #每次保存的時候自動格式化 "editor.formatOnSave": true, // #讓函數(shù)(名)和后面的括號之間加個空格 "javascript.format.insertSpaceBeforeFunctionParenthesis": true, // #這個按用戶自身習(xí)慣選擇 "vetur.format.defaultFormatter.html": "js-beautify-html", // #讓vue中的js按編輯器自帶的ts格式進行格式化 "vetur.format.defaultFormatter.js": "vscode-typescript", // 保存時運行的代碼ESLint操作類型。 "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, // 添加emmet支持vue文件 "emmet.includeLanguages": { "wxml": "html", "vue": "html" }, // 兩個選擇器中是否換行 "minapp-vscode.disableAutoConfig": true, //快速預(yù)覽(右側(cè)) "editor.minimap.enabled": true, // tab 代碼補全 "files.associations": { "*.wpy": "vue", "*.vue": "vue", "*.cjson": "jsonc", "*.wxss": "css", "*.wxs": "javascript" }, // 用來配置如何使用ESLint CLI引擎API啟動ESLint。 默認為空選項 "eslint.options": { "extensions": [".js", ".vue"] }, // 在onSave還是onType時執(zhí)行l(wèi)inter。默認為onType。 "eslint.run": "onSave", // 啟用ESLint作為已驗證文件的格式化程序。 "eslint.format.enable": true, // 語言標(biāo)識符的數(shù)組,為此ESLint擴展應(yīng)被激活,并應(yīng)嘗試驗證文件。 "eslint.probe": ["javascript", "javascriptreact", "vue-html", "vue", "html"], //關(guān)閉rg.exe進程 用cnpm導(dǎo)致會出現(xiàn)rg.exe占用內(nèi)存很高 "search.followSymlinks": false, // 給js-beautify-html設(shè)置屬性隔斷 "vetur.format.defaultFormatterOptions": { "js-beautify-html": { "wrap_attributes": "force-aligned", "max_preserve_newlines": 0 } }, // style默認偏移一個indent "vetur.format.styleInitialIndent": true, // 定義匿名函數(shù)的函數(shù)關(guān)鍵字后面的空格處理。 "javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": true, // 定義函數(shù)參數(shù)括號前的空格處理方式。 "typescript.format.insertSpaceBeforeFunctionParenthesis": true, // 新版本消息 "vsicons.dontShowNewVersionMessage": true, // 控制資源管理器是否在把文件刪除到廢紙簍時進行確認。 "explorer.confirmDelete": true, // 使用eslint-plugin-vue驗證template>中的vue-html "vetur.validation.template": false, // 指定用在工作臺中的顏色主題。 "workbench.colorTheme": "One Dark Pro" }
總結(jié)
到此這篇關(guān)于vscode配置setting.json文件實現(xiàn)eslint自動格式代碼的文章就介紹到這了,更多相關(guān)vscode 配置eslint自動格式化內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
標(biāo)簽:襄陽 莆田 錫林郭勒盟 丹東 哈爾濱 雙鴨山 鄂爾多斯 遵義
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《vscode配置setting.json文件實現(xiàn)eslint自動格式代碼》,本文關(guān)鍵詞 vscode,配置,setting.json,文件,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。