學(xué)習(xí)這些前端代碼規(guī)范,讓你的代碼更絲滑!
大家好,我是 CUGGZ。
不以規(guī)矩,不能成方圓。今天來推薦幾個(gè)流行的前端代碼規(guī)范,可以參考這些規(guī)范來制訂適合自己團(tuán)隊(duì)的代碼規(guī)范,也可以通過學(xué)習(xí)這些規(guī)范來編寫更簡(jiǎn)潔清晰的代碼,讓你的代碼更絲滑!
JavaScript
Airbnb JavaScript Style Guide
Airbnb JavaScript Style Guide 是由 Airbnb 開源的 JavaScript 代碼風(fēng)格指南。主要是為編寫 JavaScript 代碼提供規(guī)范的風(fēng)格,方便開發(fā)者理解、閱讀代碼。
Github(英文):https://github.com/airbnb/javascript。
Github(中文):https://github.com/sivan/javascript-style-guide。
JavaScript Standard Style
JavaScript 標(biāo)準(zhǔn)風(fēng)格,無需管理 .eslintrc,.jshintrc, 或 .jscsrc 文件即可運(yùn)行,真正做到開箱即用。
Github:https://github.com/standard/standard。
idiomatic.js
編寫具備一致風(fēng)格、通俗易懂 JavaScript 的規(guī)則,提供了中文版。
Github:https://github.com/rwaldron/idiomatic.js。
Google JavaScript Style Guide
谷歌 JavaScript 風(fēng)格指南。
Github:https://google.github.io/styleguide/jsguide.html#terminology-notes。
CSS
Airbnb CSS / Sass Styleguide
用更合理的方式編寫 CSS 和 Sass。
Github:https://github.com/airbnb/css。
Code Guide
開發(fā)靈活,穩(wěn)定,可持續(xù) HTML 和 CSS 代碼的規(guī)范,提供了中文版。
Github:https://github.com/mdo/code-guide。
Google HTML/CSS Style Guide
谷歌 HTML/CSS 風(fēng)格指南,旨在改善協(xié)作和代碼質(zhì)量。
地址:https://google.github.io/styleguide/htmlcssguide.html。
Sass Guidelines
編寫健全、可維護(hù)和可擴(kuò)展的 Sass 的指南。
Github:https://github.com/KittyGiraudel/sass-guidelines。
Vue
Vue.js 風(fēng)格指南
這是 Vue 官方提供的 Vue(2.x)特有代碼的風(fēng)格指南。
Github:https://v2.cn.vuejs.org/v2/style-guide/。
Vue.js Component Style Guide
本規(guī)范提供了一種統(tǒng)一的編碼規(guī)范來編寫 Vue.js 代碼。
Github:https://github.com/pablohpsilva/vuejs-component-style-guide。
React
Airbnb React/JSX Style Guide
Airbnb React/JSX 風(fēng)格指南,基于 JavaScript 當(dāng)前流行的標(biāo)準(zhǔn)。
Github:https://github.com/airbnb/javascript/tree/master/react。
TypeScript
Google TypeScript Style Guide
谷歌 TypeScript 風(fēng)格指南。
地址:https://google.github.io/styleguide/tsguide.html。
其他
Node.js Style Guide
Node.js Style Guide 是編寫一致且美觀的 node.js 代碼的指南。
Github:https://github.com/felixge/node-style-guide。
Git Style Guide
Git 風(fēng)格指南,這份風(fēng)格指南受到 How to Get Your Change Into the Linux Kernel,git man pages 和大量社區(qū)通用實(shí)踐的啟發(fā),提供了中文版。
Github:https://github.com/agis/git-style-guide。
HTTP API Design Guide
本指南描述了一組 HTTP+JSON API 設(shè)計(jì)實(shí)踐。它的目標(biāo)是一致性和專注于業(yè)務(wù)邏輯,同時(shí)避免設(shè)計(jì)輪子。提供了中文版。
Github:https://github.com/interagent/http-api-design。
Google JSON Style Guide
谷歌 JSON 風(fēng)格指南。
地址:https://google.github.io/styleguide/jsoncstyleguide.xml。
京東凹凸實(shí)驗(yàn)室前端規(guī)范
由凹凸實(shí)驗(yàn)室整理,基于 W3C、蘋果開發(fā)者 等官方文檔,并結(jié)合團(tuán)隊(duì)日常業(yè)務(wù)需求以及團(tuán)隊(duì)在日常開發(fā)過程中總結(jié)提煉出的經(jīng)驗(yàn)而制定。
Github:https://github.com/o2team/guide。
Document Style Guide
阮一峰開源的中文技術(shù)文檔的寫作規(guī)范。
Github:https://github.com/ruanyf/document-style-guide。