Home

Awesome

Nerdery JavaScript Standards() {

A sensible style guide for writing JavaScript. This is a living, breathing document that will continue to evolve as new language features are unveiled.

Following these conventions will:

This document is not intended to:

ESLint Config for the Nerdery JavaScript Standards

Table of Contents

  1. Types
  2. Variables
  3. Objects
  4. Arrays
  5. Destructuring
  6. Strings
  7. Functions
  8. Arrow Functions
  9. Classes
  10. Modules
  11. Iterators and Generators
  12. Properties
  13. Comparison
  14. Comments
  15. Whitespace
  16. Commas
  17. Semicolons
  18. Naming Conventions
  19. Accessors
  20. Events
  21. DOM Interaction
  22. Asynchronous Operations
  23. Deployment
  24. License

Types

<a name="types--assign-consistent"></a><a name="1.1"></a>

<a name="types--return-consistent"></a><a name="1.2"></a>

<a name="types--coercion-explicit"></a><a name="1.3"></a>

<a name="types--coercion-strings"></a><a name="1.4"></a>

<a name="types--coercion-numbers"></a><a name="1.5"></a>

<a name="types--coercion-booleans"></a><a name="1.6"></a>

<a name="types--comment-deviations"></a><a name="1.7"></a>

<a name="types--exceptions"></a><a name="1.8"></a>

⬆ back to top

Variables

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

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

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

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

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

<a name="variables--always-declare"></a><a name="2.6"></a>

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

⬆ back to top

Objects

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

<a name="objects--reserved-words"></a><a name="3.2"></a>

<a name="objects--computed-properties"></a><a name="3.3"></a>

<a name="objects--shorthand"></a><a name="3.4"></a>

<a name="objects--concise"></a><a name="3.5"></a>

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

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

<a name="objects--rest-spread"></a><a name="3.8"></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="arrays--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>

<a name="arrays--bracket-newline"></a><a name="4.6"></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="strings--template-literals"></a><a name="6.4"></a>

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

<a name="strings--sanitize"></a><a name="6.6"></a>

⬆ back to top

Functions

<a name="functions--mutate-parameters"></a><a name="7.1"></a>

<a name="functions--reassign-parameters"></a><a name="7.2"></a>

<a name="functions--default-parameters"></a><a name="7.3"></a>

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

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

<a name="functions--too-many-parameters"></a><a name="7.6"></a>

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

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

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

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

<a name="functions--exit-early"></a><a name="7.11"></a>

<a name="functions--exit-early"></a><a name="7.12"></a>

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

⬆ back to top

Arrow Functions

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

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

⬆ back to top

Classes

<a name="classes--use-them"></a><a name="9.1"></a>

<a name="classes--static"></a><a name="9.2"></a>

<a name="classes--extends"></a><a name="9.3"></a>

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

⬆ back to top

Modules

<a name="modules--separate"></a><a name="10.1"></a>

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

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

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

<a name="modules--self-host"></a><a name="10.5"></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>

⬆ 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

Comparison

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

<a name="comparison--eqeq-null"></a><a name="13.2"></a>

<a name="comparison--no-shortcuts"></a><a name="13.3"></a>

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

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

⬆ back to top

Blocks

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

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

⬆ back to top

Comments

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

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

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

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

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

⬆ back to top

Whitespace

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

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

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

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

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

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

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

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

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

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

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

<a name="whitespace--signature-invocation-indentation"></a><a name="16.12"></a>

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

⬆ back to top

Commas

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

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

⬆ back to top

Semicolons

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

⬆ back to top

Naming Conventions

<a name="naming--verbs-nouns"></a><a name="19.1"></a>

<a name="naming--boolean-prefix"></a><a name="19.2"></a>

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

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

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

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

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

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

<a name="naming--constants"></a><a name="19.9"></a>

<a name="naming--constants-grouping"></a><a name="19.10"></a>

<a name="naming--symbols"></a><a name="19.11"></a>

⬆ back to top

Accessors

<a name="accessors--use-them"></a><a name="20.1"></a>

<a name="accessors--no-side-effects"></a><a name="20.2"></a>

⬆ back to top

Events

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

⬆ back to top

DOM Interaction

<a name="dom--dollar-prefix"></a><a name="22.1"></a>

<a name="dom--selector-prefix"></a><a name="22.2"></a>

<a name="dom--selector-match"></a><a name="22.3"></a>

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

⬆ back to top

Asynchronous Operations

<a name="asynchronous--promise-spec"></a><a name="23.1"></a>

<a name="asynchronous--nested-promises"></a><a name="23.2"></a>

<a name="asynchronous--catch"></a><a name="23.3"></a>

⬆ back to top

Deployment

<a name="deployment--minify"></a><a name="24.1"></a>

License

(The MIT License)

Copyright (c) 2014-2017 Airbnb

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

⬆ back to top

};