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