-
Notifications
You must be signed in to change notification settings - Fork 3
Javascript
Zander Martineau edited this page Mar 27, 2018
·
8 revisions
Use npm, but use yarn if possible because of the speed and performance improvements.
Standard style is used for all code. Here are the most relevant rules:
- 2 spaces - for indentation
- Single quotes for strings – except to avoid escaping
- No unused variables – this one catches tons of bugs!
- No semicolons – It's fine. Really!
- Never start a line with
(
,[
, or `- This is the only gotcha with omitting semicolons – automatically checked for you!
- More details
-
Space after keywords
if (condition) { ... }
-
Space after function name
function name (arg) { ... }
- Always use
===
instead of==
– butobj == null
is allowed to checknull || undefined
. - Always handle the node.js
err
function parameter - Always prefix browser globals with
window
– exceptdocument
andnavigator
are okay - Prevents accidental use of poorly-named browser globals like
open
,length
,event
, andname
.
"Standard" plugins for your IDE can easily be found.
Follow AirBnB's comprehensive coding styleguide for best practices. We do not lint against this ruleset.
- Array iteration methods summarized - very useful resource
- ES2015/ES6
import
/export
syntax - DevHints - cheatsheets for many web technologies