Home

Awesome

Orange Hill Development JavaScript Style Guide() {

*A mostly reasonable approach to JavaScript forked from airbnb/javascript *

Table of Contents

  1. Types
  2. References
  3. Objects
  4. Arrays
  5. Destructuring
  6. Strings
  7. Functions
  8. Arrow Functions
  9. Classes & Constructors
  10. Modules
  11. Iterators and Generators
  12. Properties
  13. Variables
  14. Hoisting
  15. Comparison Operators & Equality
  16. Blocks
  17. Comments
  18. Whitespace
  19. Commas
  20. Semicolons
  21. Type Casting & Coercion
  22. Naming Conventions
  23. Accessors
  24. Events
  25. jQuery
  26. ECMAScript 5 Compatibility
  27. ECMAScript 6+ (ES 2015+) Styles

Types

<a name="types--primitives"></a><a name="1.1"></a>

<a name="types--complex"></a><a name="1.2"></a>

⬆ back to top

References

<a name="references--prefer-const"></a><a name="2.1"></a>

<a name="references--disallow-var"></a><a name="2.2"></a>

<a name="references--block-scope"></a><a name="2.3"></a>

⬆ back to top

Objects

<a name="objects--no-new"></a><a name="3.1"></a>

<a name="es6-computed-properties"></a><a name="3.4"></a>

<a name="es6-object-shorthand"></a><a name="3.5"></a>

<a name="es6-object-concise"></a><a name="3.6"></a>

<a name="objects--grouped-shorthand"></a><a name="3.7"></a>

<a name="objects--quoted-props"></a><a name="3.8"></a>

<a name="objects--prototype-builtins"></a>

<a name="objects--rest-spread"></a>

⬆ back to top

Arrays

<a name="arrays--literals"></a><a name="4.1"></a>

<a name="arrays--push"></a><a name="4.2"></a>

<a name="es6-array-spreads"></a><a name="4.3"></a>

<a name="arrays--from"></a><a name="4.4"></a>

<a name="arrays--callback-return"></a><a name="4.5"></a>

⬆ back to top

Destructuring

<a name="destructuring--object"></a><a name="5.1"></a>

<a name="destructuring--array"></a><a name="5.2"></a>

<a name="destructuring--object-over-array"></a><a name="5.3"></a>

⬆ back to top

Strings

<a name="strings--quotes"></a><a name="6.1"></a>

<a name="strings--line-length"></a><a name="6.2"></a>

<a name="es6-template-literals"></a><a name="6.4"></a>

<a name="strings--eval"></a><a name="6.5"></a>

<a name="strings--escaping"></a>

⬆ back to top

Functions

<a name="functions--declarations"></a><a name="7.1"></a>

<a name="functions--iife"></a><a name="7.2"></a>

<a name="functions--in-blocks"></a><a name="7.3"></a>

<a name="functions--note-on-blocks"></a><a name="7.4"></a>

<a name="functions--arguments-shadow"></a><a name="7.5"></a>

<a name="es6-rest"></a><a name="7.6"></a>

<a name="es6-default-parameters"></a><a name="7.7"></a>

<a name="functions--default-side-effects"></a><a name="7.8"></a>

<a name="functions--defaults-last"></a><a name="7.9"></a>

<a name="functions--constructor"></a><a name="7.10"></a>

<a name="functions--signature-spacing"></a><a name="7.11"></a>

<a name="functions--mutate-params"></a><a name="7.12"></a>

<a name="functions--reassign-params"></a><a name="7.13"></a>

<a name="functions--spread-vs-apply"></a><a name="7.14"></a>

<a name="functions--signature-invocation-indentation"></a>

⬆ back to top

Arrow Functions

<a name="arrows--use-them"></a><a name="8.1"></a>

<a name="arrows--implicit-return"></a><a name="8.2"></a>

<a name="arrows--paren-wrap"></a><a name="8.3"></a>

<a name="arrows--one-arg-parens"></a><a name="8.4"></a>

<a name="arrows--confusing"></a><a name="8.5"></a>

⬆ back to top

Classes & Constructors

<a name="constructors--use-class"></a><a name="9.1"></a>

<a name="constructors--extends"></a><a name="9.2"></a>

<a name="constructors--chaining"></a><a name="9.3"></a>

<a name="constructors--tostring"></a><a name="9.4"></a>

<a name="constructors--no-useless"></a><a name="9.5"></a>

<a name="classes--no-duplicate-members"></a>

⬆ back to top

Modules

<a name="modules--use-them"></a><a name="10.1"></a>

<a name="modules--no-wildcard"></a><a name="10.2"></a>

<a name="modules--no-export-from-import"></a><a name="10.3"></a>

<a name="modules--no-duplicate-imports"></a>

<a name="modules--no-mutable-exports"></a>

<a name="modules--prefer-default-export"></a>

<a name="modules--imports-first"></a>

<a name="modules--multiline-imports-over-newlines"></a>

<a name="modules--no-webpack-loader-syntax"></a>

⬆ back to top

Iterators and Generators

<a name="iterators--nope"></a><a name="11.1"></a>

<a name="generators--nope"></a><a name="11.2"></a>

<a name="generators--spacing"></a>

⬆ back to top

Properties

<a name="properties--dot"></a><a name="12.1"></a>

<a name="properties--bracket"></a><a name="12.2"></a>

⬆ back to top

Variables

<a name="variables--const"></a><a name="13.1"></a>

<a name="variables--one-const"></a><a name="13.2"></a>

<a name="variables--const-let-group"></a><a name="13.3"></a>

<a name="variables--define-where-used"></a><a name="13.4"></a>

<a name="variables--no-chain-assignment"></a><a name="13.5"></a>

<a name="variables--unary-increment-decrement"></a><a name="13.6"></a>

⬆ back to top

Hoisting

<a name="hoisting--about"></a><a name="14.1"></a>

<a name="hoisting--anon-expressions"></a><a name="14.2"></a>

<a name="hoisting--named-expresions"></a><a name="14.3"></a>

<a name="hoisting--declarations"></a><a name="14.4"></a>

⬆ back to top

Comparison Operators & Equality

<a name="comparison--eqeqeq"></a><a name="15.1"></a>

<a name="comparison--if"></a><a name="15.2"></a>

<a name="comparison--shortcuts"></a><a name="15.3"></a>

<a name="comparison--moreinfo"></a><a name="15.4"></a>

<a name="comparison--switch-blocks"></a><a name="15.5"></a>

<a name="comparison--nested-ternaries"></a><a name="15.6"></a>

<a name="comparison--unneeded-ternary"></a><a name="15.7"></a>

⬆ back to top

Blocks

<a name="blocks--braces"></a><a name="16.1"></a>

<a name="blocks--cuddled-elses"></a><a name="16.2"></a>

⬆ back to top

Comments

<a name="comments--multiline"></a><a name="17.1"></a>

<a name="comments--singleline"></a><a name="17.2"></a>

<a name="comments--actionitems"></a><a name="17.3"></a>

<a name="comments--fixme"></a><a name="17.4"></a>

<a name="comments--todo"></a><a name="17.5"></a>

<a name="comments--todo"></a><a name="17.5"></a>

⬆ back to top

Whitespace

<a name="whitespace--spaces"></a><a name="18.1"></a>

<a name="whitespace--before-blocks"></a><a name="18.2"></a>

<a name="whitespace--around-keywords"></a><a name="18.3"></a>

<a name="whitespace--infix-ops"></a><a name="18.4"></a>

<a name="whitespace--newline-at-end"></a><a name="18.5"></a>

<a name="whitespace--chains"></a><a name="18.6"></a>

<a name="whitespace--after-blocks"></a><a name="18.7"></a>

<a name="whitespace--padded-blocks"></a><a name="18.8"></a>

<a name="whitespace--in-parens"></a><a name="18.9"></a>

<a name="whitespace--in-brackets"></a><a name="18.10"></a>

<a name="whitespace--in-braces"></a><a name="18.11"></a>

<a name="whitespace--max-len"></a><a name="18.12"></a>

⬆ back to top

Commas

<a name="commas--leading-trailing"></a><a name="19.1"></a>

<a name="commas--dangling"></a><a name="19.2"></a>

⬆ back to top

Semicolons

<a name="semicolons--required"></a><a name="20.1"></a>

⬆ back to top

Type Casting & Coercion

<a name="coercion--explicit"></a><a name="21.1"></a>

<a name="coercion--strings"></a><a name="21.2"></a>

<a name="coercion--numbers"></a><a name="21.3"></a>

<a name="coercion--comment-deviations"></a><a name="21.4"></a>

<a name="coercion--bitwise"></a><a name="21.5"></a>

<a name="coercion--booleans"></a><a name="21.6"></a>

⬆ back to top

Naming Conventions

<a name="naming--descriptive"></a><a name="22.1"></a>

<a name="naming--camelCase"></a><a name="22.2"></a>

<a name="naming--PascalCase"></a><a name="22.3"></a>

<a name="naming--leading-underscore"></a><a name="22.4"></a>

<a name="naming--self-this"></a><a name="22.5"></a>

<a name="naming--filename-matches-export"></a><a name="22.6"></a>

<a name="naming--camelCase-default-export"></a><a name="22.7"></a>

<a name="naming--PascalCase-singleton"></a><a name="22.8"></a>

<a name="naming--Acronyms-and-Initialisms"></a>

⬆ back to top

Accessors

<a name="accessors--not-required"></a><a name="23.1"></a>

<a name="accessors--no-getters-setters"></a><a name="23.2"></a>

<a name="accessors--boolean-prefix"></a><a name="23.3"></a>

<a name="accessors--consistent"></a><a name="23.4"></a>

⬆ back to top

Events

<a name="events--hash"></a><a name="24.1"></a>

⬆ back to top

jQuery

<a name="jquery--dollar-prefix"></a><a name="25.1"></a>

<a name="jquery--cache"></a><a name="25.2"></a>

<a name="jquery--queries"></a><a name="25.3"></a>

<a name="jquery--find"></a><a name="25.4"></a>

⬆ back to top

ECMAScript 5 Compatibility

<a name="es5-compat--kangax"></a><a name="26.1"></a>

⬆ back to top

<a name="ecmascript-6-styles"></a>

ECMAScript 6+ (ES 2015+) Styles

<a name="es6-styles"></a><a name="27.1"></a>

  1. Arrow Functions
  2. Classes
  3. Object Shorthand
  4. Object Concise
  5. Object Computed Properties
  6. Template Strings
  7. Destructuring
  8. Default Parameters
  9. Rest
  10. Array Spreads
  11. Let and Const
  12. Iterators and Generators
  13. Modules

<a name="tc39-proposals"></a>

⬆ back to top

};