disallowShorthandArrowFunctions

Require arrow functions to use a block statement (explicit return).

Why enable this rule? Arrow functions' syntax can cause maintenance issues:

  • When you add additional lines to an arrow function's expression body, the function will now return undefined, unless you remember to add an explicit return.
  • The shorthand syntax is ambiguous in terms of returning objects. (name) => {id: name} is interpreted as a longhand arrow function with the label id:.

Type: Boolean

Value: true

Version: ES6

Example

"disallowShorthandArrowFunctions": true
Valid
// block statement
evens.map(v => {
    return v + 1;
});
Invalid
// single expression
evens.map(v => v + 1);
Rule source
Test source