欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

prettier自動(dòng)格式化去換行的實(shí)現(xiàn)代碼

 更新時(shí)間:2020年08月25日 16:00:46   作者:我愛(ài)搬磚,搬磚愛(ài)我  
這篇文章主要介紹了prettier自動(dòng)格式化去換行的實(shí)現(xiàn)代碼,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

插件

在這里插入圖片描述
在這里插入圖片描述

新建 .prettierrc 文件在根目錄,里面寫上這個(gè)
第一個(gè)是超出800字符換行,第二個(gè)是單引號(hào),第三個(gè)是結(jié)尾不要分號(hào)

在這里插入圖片描述

vscode里面的設(shè)置文件settings。json代碼

{
 // vscode默認(rèn)啟用了根據(jù)文件類型自動(dòng)設(shè)置tabsize的選項(xiàng)
 "editor.detectIndentation": false,
 // 重新設(shè)定tabsize
 "editor.tabSize": 2,
 // #每次保存的時(shí)候自動(dòng)格式化
 "editor.formatOnSave": true,
 // // 添加 vue 支持
 "eslint.validate": [
  "javascript",
  "javascriptreact",
  {
   "language": "vue",
   "autoFix": true
  }
 ],
 "eslint.autoFixOnSave": true,
 "vetur.validation.template": false,
 // #讓prettier使用eslint的代碼格式進(jìn)行校驗(yàn)
 "prettier.eslintIntegration": true,
 // #去掉代碼結(jié)尾的分號(hào)
 "prettier.semi": false,
 // #使用帶引號(hào)替代雙引號(hào)
 "prettier.singleQuote": 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",
 "vetur.format.defaultFormatterOptions": {
  "js-beautify-html": {
   // 換行
   // "wrap_attributes": "force-aligned"
   // 不換行
   "wrap_attributes": "aligned-multiple"
  }
 },
 // 格式化stylus, 需安裝Manta's Stylus Supremacy插件
 "stylusSupremacy.insertColons": false, // 是否插入冒號(hào)
 "stylusSupremacy.insertSemicolons": false, // 是否插入分好
 "stylusSupremacy.insertBraces": false, // 是否插入大括號(hào)
 "stylusSupremacy.insertNewLineAroundImports": false, // import之后是否換行
 "stylusSupremacy.insertNewLineAroundBlocks": false, // 兩個(gè)選擇器中是否換行
 "auto-rename-tag.activationOnLanguage": [
  "*"
 ],
 "window.zoomLevel": 0,
 // esli彈框報(bào)錯(cuò)
 "devDependencies": {
  "babel-eslint": "^10.0.3",
  "eslint": "^4.15.0",
  "eslint-config-airbnb": "^16.1.0",
  "eslint-plugin-jsx-a11y": "^6.0.3",
  "eslint-plugin-react": "^7.12.1",
  "eslint-config-google": "^0.9.1",
  "eslint-config-standard": "^10.2.1",
  "eslint-plugin-html": "^4.0.1",
  "eslint-plugin-import": "^2.8.0",
  "eslint-plugin-node": "^5.2.1",
  "eslint-plugin-promise": "^3.6.0",
  "eslint-plugin-standard": "^3.0.1"
 },
 "http.proxyAuthorization": null,
 "eslint.migration.2_x": "off",
 "workbench.editorAssociations": [],
 "eslint.codeAction.disableRuleComment": {},
 "eslint.codeAction.showDocumentation": {},
 "editor.suggest.snippetsPreventQuickSuggestions": false,
 "files.associations": {
  "*.cjson": "jsonc",
  "*.wxss": "css",
  "*.wxs": "javascript"
 },
 "emmet.includeLanguages": {
  "wxml": "html"
 },
 "minapp-vscode.disableAutoConfig": true,
 "editor.codeActionsOnSave": null,
 "[vue]": {
  "editor.defaultFormatter": "esbenp.prettier-vscode"
 },
 "[jsonc]": {
  "editor.defaultFormatter": "vscode.json-language-features"
 },
 "[javascript]": {
  "editor.defaultFormatter": "esbenp.prettier-vscode"
 }
}

保存,打開(kāi)一個(gè)后綴名為.vue文件,右鍵文檔格式方式

在這里插入圖片描述

點(diǎn)默認(rèn)格式化程序,再點(diǎn)Vetur

在這里插入圖片描述
在這里插入圖片描述

大功告成,,ctrl+s自動(dòng)格式化,這是不換行的方式

后綴名為 .js,用上面同樣步驟,但是默認(rèn)值用prettier

在這里插入圖片描述

喜歡標(biāo)簽換行用這個(gè)
打開(kāi)vscode設(shè)置文件settings。json,找到,想用哪個(gè)打開(kāi)就好,不用就注釋

在這里插入圖片描述

總結(jié)

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

相關(guān)文章

最新評(píng)論