Changes between Version 24 and Version 25 of WebInspectorCodingStyleGuide


Ignore:
Timestamp:
Jan 2, 2017 1:20:43 PM (5 years ago)
Author:
BJ Burg
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WebInspectorCodingStyleGuide

    v24 v25  
    1515* Calling a constructor with no arguments should have no parenthesis `'()'`. eg. `var map = new Map;`
    1616* Put anonymous functions inline if they are not used as a subroutine.
     17* Prefer `let` to `var`, unless the variable is not used in a block scoping manner. Be careful when using `let` with `case` switches, as [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_dead_zone_and_errors_with_let all switch cases share the same block by default].
    1718* Use arrow functions when possible, unless it makes code less readable. See below for examples.
    1819* For default parameters, add a space around the default assignment: `function foo(isGood = false)`
     
    8889Never use option (1), because it is a special case that only applies when the function has one argument, reducing predictability.
    8990
    90 In cases where the return value is used and the expression is a constant ("foo"), a variable (foo), or a member (this.foo), use option (2). Never use braces though, because implicit return only works if there are no braces around the single expression.
     91In cases where the return value is used and the single expression is a constant ("foo"), a variable (foo), a member (this.foo), or evaluates to a Promise, use option (2). Never use braces though, because implicit return only works if there are no braces around the single expression.
    9192
    9293In cases where the expression computes a value (a + 42) or performs a side effect (++a), prefer option (4).