佳木斯湛栽影视文化发展公司

主頁 > 知識(shí)庫 > vscode配置setting.json文件實(shí)現(xiàn)eslint自動(dòng)格式代碼

vscode配置setting.json文件實(shí)現(xiàn)eslint自動(dòng)格式代碼

熱門標(biāo)簽:智能手機(jī) 檢查注冊(cè)表項(xiàng) 呼叫中心市場(chǎng)需求 服務(wù)器配置 網(wǎng)站文章發(fā)布 鐵路電話系統(tǒng) 銀行業(yè)務(wù) 美圖手機(jī)

一、ESlint+Vetur 實(shí)現(xiàn)ESlint代碼規(guī)范


二、重點(diǎn)----舊版本(舊版本配置在setting.json 會(huì)出現(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”]
}

以下是對(duì)自己vscode-settings.json 做一個(gè)記錄(僅供參考)

{
 //設(shè)置文字大小
 "editor.fontSize": 18,

 //設(shè)置文字行高
 "editor.lineHeight": 24,

 //開啟行數(shù)提示
 "editor.lineNumbers": "on",

 // 在輸入時(shí)顯示含有參數(shù)文檔和類型信息的小面板。
 "editor.parameterHints.enabled": true,

 // 調(diào)整窗口的縮放級(jí)別
 "window.zoomLevel": 0,

 // 文件目錄
 "workbench.iconTheme": "vscode-icons",

 // 設(shè)置字體
 "editor.fontFamily": "'Droid Sans Mono', 'Courier New', monospace, 'Droid Sans Fallback'",

 // 自動(dòng)換行
 "editor.wordWrap": "on",

 // 自定義vscode面板顏色
 "workbench.colorCustomizations": {
  "tab.activeBackground": "#253046", // 活動(dòng)選項(xiàng)卡的背景色
  "activityBar.background": "#253046", //活動(dòng)欄背景色
  "sideBar.background": "#253046", //側(cè)邊欄背景色
  "activityBar.foreground": "#23f8c8", //活動(dòng)欄前景色(例如用于圖標(biāo))
  "editor.background": "#292a2c" //編輯器背景顏色
  // "editor.foreground":"#ff0000", 	//編輯器默認(rèn)前景色
  // "editor.findMatchBackground":"#23f8c8", 	//當(dāng)前搜索匹配項(xiàng)的顏色
  // "editor.findMatchHighlightBackground":"#ff0000", 	//其他搜索匹配項(xiàng)的顏色
  // "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", 	//匹配括號(hào)的背景色
  // "editorCursor.foreground":"#ff0000", 	//編輯器光標(biāo)顏色
  // "editorGutter.background":"#ff0000", 	//編輯器導(dǎo)航線的背景色,導(dǎo)航線包括邊緣符號(hào)和行號(hào)
  // "editorLineNumber.foreground":"#ff0000", 	//編輯器行號(hào)顏色
  // "sideBar.foreground":"#ff0000", 	//側(cè)邊欄前景色
  // "sideBarSectionHeader.background":"#ff0000", 	//側(cè)邊欄節(jié)標(biāo)題的背景顏色
  // "statusBar.background":"#ff0000", 	//標(biāo)準(zhǔn)狀態(tài)欄背景色
  // "statusBar.noFolderBackground":"#ff0000", 	//沒有打開文件夾時(shí)狀態(tài)欄的背景色
  // "statusBar.debuggingBackground":"#ff0000", 	//調(diào)試程序時(shí)狀態(tài)欄的背景色
  // "tab.activeForeground":"#ff0000", 	//活動(dòng)組中活動(dòng)選項(xiàng)卡的前景色
  // "tab.inactiveBackground":"#ff0000", 	//非活動(dòng)選項(xiàng)卡的背景色
  // "tab.inactiveForeground":"#ff0000" // 活動(dòng)組中非活動(dòng)選項(xiàng)卡的前景色
 },
 // vscode默認(rèn)啟用了根據(jù)文件類型自動(dòng)設(shè)置tabsize的選項(xiàng)
 "editor.detectIndentation": false,

 // 重新設(shè)定tabsize
 "editor.tabSize": 2,

 // #每次保存的時(shí)候自動(dòng)格式化
 "editor.formatOnSave": true,

 // #讓函數(shù)(名)和后面的括號(hào)之間加個(gè)空格
 "javascript.format.insertSpaceBeforeFunctionParenthesis": true,

 // #這個(gè)按用戶自身習(xí)慣選擇
 "vetur.format.defaultFormatter.html": "js-beautify-html",

 // #讓vue中的js按編輯器自帶的ts格式進(jìn)行格式化
 "vetur.format.defaultFormatter.js": "vscode-typescript",

 // 保存時(shí)運(yùn)行的代碼ESLint操作類型。
 "editor.codeActionsOnSave": {
  "source.fixAll.eslint": true
 },

 // 添加emmet支持vue文件
 "emmet.includeLanguages": {
  "wxml": "html",
  "vue": "html"
 },

 // 兩個(gè)選擇器中是否換行
 "minapp-vscode.disableAutoConfig": true,

 //快速預(yù)覽(右側(cè))
 "editor.minimap.enabled": true,

 // tab 代碼補(bǔ)全
 "files.associations": {
  "*.wpy": "vue",
  "*.vue": "vue",
  "*.cjson": "jsonc",
  "*.wxss": "css",
  "*.wxs": "javascript"
 },

 // 用來配置如何使用ESLint CLI引擎API啟動(dòng)ESLint。 默認(rèn)為空選項(xiàng)
 "eslint.options": {
  "extensions": [".js", ".vue"]
 },

 // 在onSave還是onType時(shí)執(zhí)行l(wèi)inter。默認(rèn)為onType。
 "eslint.run": "onSave",

 // 啟用ESLint作為已驗(yàn)證文件的格式化程序。
 "eslint.format.enable": true,

 // 語言標(biāo)識(shí)符的數(shù)組,為此ESLint擴(kuò)展應(yīng)被激活,并應(yīng)嘗試驗(yàn)證文件。
 "eslint.probe": ["javascript", "javascriptreact", "vue-html", "vue", "html"],

 //關(guān)閉rg.exe進(jìn)程 用cnpm導(dǎo)致會(huì)出現(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默認(rèn)偏移一個(gè)indent
 "vetur.format.styleInitialIndent": true,

 // 定義匿名函數(shù)的函數(shù)關(guān)鍵字后面的空格處理。
 "javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,

 // 定義函數(shù)參數(shù)括號(hào)前的空格處理方式。
 "typescript.format.insertSpaceBeforeFunctionParenthesis": true,

 // 新版本消息
 "vsicons.dontShowNewVersionMessage": true,

 // 控制資源管理器是否在把文件刪除到廢紙簍時(shí)進(jìn)行確認(rèn)。
 "explorer.confirmDelete": true,

 // 使用eslint-plugin-vue驗(yàn)證template>中的vue-html
 "vetur.validation.template": false,

 // 指定用在工作臺(tái)中的顏色主題。
 "workbench.colorTheme": "One Dark Pro"
}

總結(jié)

到此這篇關(guān)于vscode配置setting.json文件實(shí)現(xiàn)eslint自動(dòng)格式代碼的文章就介紹到這了,更多相關(guān)vscode 配置eslint自動(dòng)格式化內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:
  • 在vue中使用eslint,配合vscode的操作
  • 關(guān)于VSCode 裝好ESLint 插件 import 報(bào)黃線的問題
  • Idea安裝Eslint插件提示:Plugin NativeScript was not installed的問題
  • vue-cli3項(xiàng)目配置eslint代碼規(guī)范的完整步驟
  • 使用eslint和githooks統(tǒng)一前端風(fēng)格的技巧
  • eslint+prettier統(tǒng)一代碼風(fēng)格的實(shí)現(xiàn)方法
  • vue-cli4項(xiàng)目開啟eslint保存時(shí)自動(dòng)格式問題
  • vscode代碼格式化和eslint的使用
  • vscode 配置vue+vetur+eslint+prettier自動(dòng)格式化功能
  • JS代碼檢查工具ESLint介紹與使用方法
  • Vue的Eslint配置文件eslintrc.js說明與規(guī)則介紹
  • vue項(xiàng)目中使用eslint+prettier規(guī)范與檢查代碼的方法
  • ESLint 是如何檢查 .vue 文件的

標(biāo)簽:沈陽 長(zhǎng)治 河南 新疆 滄州 上海 紅河 樂山

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《vscode配置setting.json文件實(shí)現(xiàn)eslint自動(dòng)格式代碼》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    沂南县| 依安县| 定襄县| 武汉市| 丘北县| 游戏| 湘乡市| 莆田市| 秦皇岛市| 栾城县| 桃江县| 长治市| 天峨县| 广灵县| 钦州市| 芮城县| 平阳县| 桐庐县| 双柏县| 呼和浩特市| 乌兰浩特市| 孝感市| 潍坊市| 九寨沟县| 金平| 望都县| 科尔| 福泉市| 昌都县| 益阳市| 多伦县| 凤冈县| 柘城县| 赤城县| 珠海市| 万全县| 余干县| 昂仁县| 罗甸县| 陆河县| 楚雄市|