10個最佳的JavaScript風(fēng)格指南.md

1. airbnb JavaScript Style Guide

airbnb JavaScript style guide is my personal favorite and ranks at the top in my listing of 10 best coding style guides. It was released by Harrison Shoff of airbnb back in 2012 as open source under MIT license. airbnb labels it as** “mostly reasonable approach to JavaScript”**.
Ever since its release, airbnb’s style guide has gained popularity and is one of the most followed and comprehensive pack of coding standards for writing JavaScript.
The best thing I like about airbnb style guide is that it covers all aspects of coding in JavaScript right from guidelines for variable declaration, functions, events, test code to performance related tips.
You can get airbnb style guide at – github.com/airbnb/javascript.

2. Idiomatic.js JavaScript Style Guide

I will put this second only to airbnb coding standards. Idiomatic.js is developed by some of the most experienced JavaScript developers out there in the wild and is one of the oldest and most comprehensive Javascript coding standards available for use as open source.
The style guide is available in multiple languages including German, French, Italian, Korean, Russian and Romanian.
"they” say that this style guide covers “principles of writing consistent, idiomatic JavaScript” and “they” are the experts like Rick Waldro, Mathias Bynens, Kit Cambridge and many more.
Fork it, make changes, if required, and use in your next project or use it as a base style to build one for your organization.
You can get idiomatic.js style guide at - github.com/rwaldron/idiomatic.js/.

3. jQuery Core Style Guidelines

jQuery people write JavaScript by following this style guide are are doing this for years now. jQuery folks are working on to put together a module as well that can be used to check if code is written as per the jQuery standard style guide.
Till then, read the rules, write JavaScript per their guidelines and do review the code manually before you commit. There are tons of jQuery projects and modules that follow jQuery core JavaScript style guidelines.
You can read more on this at - jquery.org/style-guide/js/.

4. Google JavaScript Style Guide

The best thing about Google is that they share what they do. Google’s JavaScript style guide was released in 2012 and is maintained and upgraded by Robby walker, Bob Jervis, Dan Pupius and team. Many of Google’s open source JavaScript projects are already following this style guide.
Google’s style guide is divided in two parts, one focuses on JavaScript language rules (variables, functions) and the other one focuses purely on JavaScript style rules (cosmetic aspects).
You can read about this style guide at - googlecode.com.

5. Dojo Style Guide

Dojo toolkit was at its peak somewhere back in 2012, it may not be growing at the same pace now in 2015 but is still very popular and the reason for that can be attributed to the perfectionism Dojo community believes in. There is a comprehensive style guide that core Dojo developers have created for the community.
It derives its basics from the Java programming convention guide, you can check out the java guide at – geosoft.no.
This style guide smells a lot like Dojo and you might want to make necessary changes to make it a standard for your team of developers working on non Dojo projects. You will not find many coding standards as comprehensive as Dojo JavaScript Style guide.
You can read more on this at - hdojotoolkit.org.

6. JavaScript "Standard" Style

This is one style to rule them all as stated by “Feross Abukhadijeh”, the one who created and released it as open source under MIT license. There is a node package “standards.js” available to do the styling for you.
You write JavaScript your way and run it past "standards" node package to auto format the code and It’s all done. This style guide does only the minimal and doesn't go deep into your JavaScript to pin point performance related aspects or do test code review.
You can get this package at - github.com.

7. Node.js Style Guide

Felix Geisendorfer has come up with this style guide by picking up the most commonly used coding practices of Node.js community and adding additional bits as required. If you are working on a node package, you can follow this as is.
If you want to use it for some other project, you can fork it, change it as per your preferences and start using it. It’s free under creative commons license and you can get it at - node-style-guide.

8. Crockfords’s Coding Standards for JavaScript

This one is the creation of Douglus Crockford, a JavaScript enthusiast. The argument behind defining the style guide is that “long term value of the software is directly proportional to the quality of codebase”.
Crockford's style guide is based on java standards with enhancements made as necessary, you can follow it as is or use it as a base to create a standard for your community. You can get it at - crockford.com.

9. NPM's 'funny' Coding Style

They say, it is a bit unconventional but carefully crafted style guide to reduce the visual clutter. Any contributions to npm are supposed to follow these coding standards.
NPM style guide contains only minimal set of guidelines and talks about using commas, semicolons, indentation, white space, tabs etc. and doesn't go into guidelines around test code coverage and performance.
You can get npm style guide at - docs.npmjs.com.

10. WordPress JavaScript Coding Standards

WordPress has a huge ecosystem with almost 18% of all the websites on planet built on top of WordPress, but let us not go there right now.
WordPress has its own style guide for writing JavaScript. The style guide is derived from jQuery core style guidelines with minor modifications to suit the overall development landscape of WordPress.
You can get WordPress coding standards at - make.wordpress.org.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末忍燥,一起剝皮案震驚了整個濱河市蹋砚,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌珊擂,老刑警劉巖寻咒,帶你破解...
    沈念sama閱讀 219,366評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件哮翘,死亡現(xiàn)場離奇詭異,居然都是意外死亡毛秘,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,521評論 3 395
  • 文/潘曉璐 我一進(jìn)店門阻课,熙熙樓的掌柜王于貴愁眉苦臉地迎上來叫挟,“玉大人,你說我怎么就攤上這事限煞∧遥” “怎么了?”我有些...
    開封第一講書人閱讀 165,689評論 0 356
  • 文/不壞的土叔 我叫張陵署驻,是天一觀的道長奋献。 經(jīng)常有香客問我健霹,道長,這世上最難降的妖魔是什么瓶蚂? 我笑而不...
    開封第一講書人閱讀 58,925評論 1 295
  • 正文 為了忘掉前任糖埋,我火速辦了婚禮,結(jié)果婚禮上窃这,老公的妹妹穿的比我還像新娘瞳别。我一直安慰自己,他們只是感情好杭攻,可當(dāng)我...
    茶點故事閱讀 67,942評論 6 392
  • 文/花漫 我一把揭開白布祟敛。 她就那樣靜靜地躺著,像睡著了一般兆解。 火紅的嫁衣襯著肌膚如雪馆铁。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,727評論 1 305
  • 那天锅睛,我揣著相機(jī)與錄音埠巨,去河邊找鬼。 笑死衣撬,一個胖子當(dāng)著我的面吹牛乖订,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播具练,決...
    沈念sama閱讀 40,447評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼乍构,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了扛点?” 一聲冷哼從身側(cè)響起哥遮,我...
    開封第一講書人閱讀 39,349評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎陵究,沒想到半個月后眠饮,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,820評論 1 317
  • 正文 獨居荒郊野嶺守林人離奇死亡铜邮,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,990評論 3 337
  • 正文 我和宋清朗相戀三年仪召,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片松蒜。...
    茶點故事閱讀 40,127評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡扔茅,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出秸苗,到底是詐尸還是另有隱情召娜,我是刑警寧澤,帶...
    沈念sama閱讀 35,812評論 5 346
  • 正文 年R本政府宣布惊楼,位于F島的核電站玖瘸,受9級特大地震影響秸讹,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜雅倒,卻給世界環(huán)境...
    茶點故事閱讀 41,471評論 3 331
  • 文/蒙蒙 一璃诀、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧屯断,春花似錦文虏、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,017評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至趴久,卻和暖如春丸相,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背彼棍。 一陣腳步聲響...
    開封第一講書人閱讀 33,142評論 1 272
  • 我被黑心中介騙來泰國打工灭忠, 沒想到剛下飛機(jī)就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人座硕。 一個月前我還...
    沈念sama閱讀 48,388評論 3 373
  • 正文 我出身青樓弛作,卻偏偏與公主長得像,于是被迫代替她去往敵國和親华匾。 傳聞我的和親對象是個殘疾皇子映琳,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,066評論 2 355

推薦閱讀更多精彩內(nèi)容

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 9,511評論 0 23
  • 在開發(fā)過程中或者是在測試過程中會發(fā)現(xiàn)應(yīng)用程序出現(xiàn)BUG并且修復(fù)了它,但是在更新版本的時候往往會使用了錯誤的buil...
    景彧閱讀 1,264評論 0 1
  • 其一 我牽掛的人兒蜘拉, 你忙什么去了萨西? 我落寞地等待, 心都快要醉了旭旭。 其二 五一八的晨早好似凄零谎脯, 它已完結(jié)了荒蕪...
    洛安卿藜閱讀 263評論 0 3
  • 現(xiàn)在,買一臺筆記本電腦持寄,已經(jīng)成為很多人們?nèi)粘9ぷ骱蜕钪胁豢扇鄙俚牟糠衷此螅P記本電腦的移動性,方便性稍味,已經(jīng)越來越被更...
    丐幫財神閱讀 7,370評論 48 180
  • 今天剛開始跑步的時候我有點分心咸产,腦子里想的東西太多,一不小心在跑的過程中崴了一下腳仲闽,當(dāng)時感到有一些懊惱,我想難道今...
    湯媚閱讀 206評論 0 0