Disallow Extra Parens (no-extra-parens)

This rule restricts the use of parentheses to only where they are necessary. It may be restricted to report only function expressions.

Rule Details

Exceptions

A few cases of redundant parentheses are always allowed:

Options

The default behavior of the rule is specified by "all" and it will report unnecessary parentheses around any expression. The following patterns are considered warnings:

a = (b * c)

(a * b) + c

typeof (a)

The following patterns are not considered warnings:

(0).toString()

({}.toString.call())

(function(){} ? a() : b())

(/^a$/).test(var)

If the option is set to "functions", only function expressions will be checked for unnecessary parentheses. The following patterns are considered warnings:

((function foo() {}))();

var y = (function () {return 1;});

The following patterns are not considered warnings:

(0).toString()

({}.toString.call())

(function(){} ? a() : b())

(/^a$/).test(var)

a = (b * c)

(a * b) + c

typeof (a)

Further Reading

Version

This rule was introduced in ESLint 0.1.4.

Resources