-
Notifications
You must be signed in to change notification settings - Fork 2
Linting
davidjamesstone edited this page Sep 24, 2016
·
1 revision
standard.js is used to lint both the server-side and client-side javascript code.
One Style to Rule Them All. No decisions to make. No .eslintrc, .jshintrc, or .jscsrc files to manage. It just works.
It's defined as a build task and can be run using npm run lint
.
Some of the highlights of standard.js are:
- 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!
-
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
.
- Prevents accidental use of poorly-named browser globals like