Require parens in arrow function arguments (arrow-parens)

The --fix option on the command line can automatically fix some of the problems reported by this rule.

Arrow functions can omit parentheses when they have exactly one parameter. In all other cases the parameter(s) must
be wrapped in parentheses. This rule enforces the consistent use of parentheses in arrow functions.

Rule Details

This rule enforces parentheses around arrow function parameters regardless of arity. For example:

/*eslint-env es6*/// Bada=>{}// Good(a)=>{}

Following this style will help you find arrow functions (=>) which may be mistakenly included in a condition
when a comparison such as >= was the intent.

/*eslint-env es6*/// Badif(a=>2){}// Goodif(a>=2){}

The rule can also be configured to discourage the use of parens when they are not required:

/*eslint-env es6*/// Bad(a)=>{}// Gooda=>{}

Options

This rule has a string option and an object one.

String options are:

"always" (default) requires parens around arguments in all cases.

"as-needed" allows omitting parens when there is only one argument.

Object properties for variants of the "as-needed" option:

"requireForBlockBody": true modifies the as-needed rule in order to require parens if the function body is in an instructions block (surrounded by braces).

always

Examples of incorrect code for this rule with the default "always" option: