10个最佳的JavaScript风格指南.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.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 213,864评论 6 494
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,175评论 3 387
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 159,401评论 0 349
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,170评论 1 286
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,276评论 6 385
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,364评论 1 292
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,401评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,179评论 0 269
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,604评论 1 306
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,902评论 2 328
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,070评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,751评论 4 337
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,380评论 3 319
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,077评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,312评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,924评论 2 365
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,957评论 2 351

推荐阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,444评论 0 23
  • 在开发过程中或者是在测试过程中会发现应用程序出现BUG并且修复了它,但是在更新版本的时候往往会使用了错误的buil...
    景彧阅读 1,256评论 0 1
  • 其一 我牵挂的人儿, 你忙什么去了? 我落寞地等待, 心都快要醉了。 其二 五一八的晨早好似凄零, 它已完结了荒芜...
    洛安卿藜阅读 260评论 0 3
  • 现在,买一台笔记本电脑,已经成为很多人们日常工作和生活中不可缺少的部分,笔记本电脑的移动性,方便性,已经越来越被更...
    丐帮财神阅读 7,367评论 48 180
  • 今天刚开始跑步的时候我有点分心,脑子里想的东西太多,一不小心在跑的过程中崴了一下脚,当时感到有一些懊恼,我想难道今...
    汤媚阅读 205评论 0 0