Repository: eslint/eslint
File: lib/rules/no-extra-parens.js (JavaScript)

Code before:
                }

                checkBinaryLogical(node);
            },

            CallExpression: checkCallNew,

            ConditionalExpression(node) {
                if (isReturnAssignException(node)) {
                    return;
                }

                const availableType = new Set(["BinaryExpression", "LogicalExpression"]);

                if (isCondTernaryException(node)) {
                    if (!availableType.has(node.test.type) && isParenthesised(node.test)) {
                        report(node.test);
                    }
                    if (!availableType.has(node.consequent.type) && isParenthesised(node.consequent)) {
                        report(node.consequent);
                    }
                    if (!availableType.has(node.alternate.type) && isParenthesised(node.alternate)) {
                        report(node.alternate);
                    }
                    return;
                }

                if (
                    !isCondAssignException(node) &&
                    hasExcessParensWithPrecedence(node.test, precedence({ type: "LogicalExpression", operator: "||" }))
                ) {
                    report(node.test);
                }

                if (hasExcessParensWithPrecedence(node.consequent, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
                    report(node.consequent);
                }

                if (hasExcessParensWithPrecedence(node.alternate, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
                    report(node.alternate);
                }
            },

            DoWhileStatement(node) {
                if (hasExcessParens(node.test) && !isCondAssignException(node)) {
                    report(node.test);
                }
            },

            ExportDefaultDeclaration: node => checkExpressionOrExportStatement(node.declaration),
            ExpressionStatement: node => checkExpressionOrExportStatement(node.expression),

Review comment (suggestion):
These would be false positives:

```js
/* eslint no-extra-parens: ["error", "all", { conditionalTernary: false }] */

(a, b) ? (c, d) : (e, f); // false positives

```

We should just add the new logic into the existing conditionals below, for example:

```diff
-if (hasExcessParensWithPrecedence(node.alternate, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
+if (
+    !(EXCEPT_COND_TERNARY && availableType.has(node.alternate.type)) &&
+    hasExcessParensWithPrecedence(node.alternate, PRECEDENCE_OF_ASSIGNMENT_EXPR)
+) {
    report(node.alternate);
}
```

Code after:
                }

                const availableTypes = new Set(["BinaryExpression", "LogicalExpression"]);

                if (
                    !(EXCEPT_COND_TERNARY && availableTypes.has(node.test.type)) &&
                    !isCondAssignException(node) &&
                    hasExcessParensWithPrecedence(node.test, precedence({ type: "LogicalExpression", operator: "||" }))
                ) {
                    report(node.test);
                }

                if (
                    !(EXCEPT_COND_TERNARY && availableTypes.has(node.consequent.type)) &&
                    hasExcessParensWithPrecedence(node.consequent, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
                    report(node.consequent);
                }

                if (
                    !(EXCEPT_COND_TERNARY && availableTypes.has(node.alternate.type)) &&
                    hasExcessParensWithPrecedence(node.alternate, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
                    report(node.alternate);
                }
            },

            DoWhileStatement(node) {
                if (hasExcessParens(node.test) && !isCondAssignException(node)) {
                    report(node.test);
                }
            },

            ExportDefaultDeclaration: node => checkExpressionOrExportStatement(node.declaration),
            ExpressionStatement: node => checkExpressionOrExportStatement(node.expression),

            ForInStatement(node) {
                if (node.left.type !== "VariableDeclaration") {
                    const firstLeftToken = sourceCode.getFirstToken(node.left, astUtils.isNotOpeningParenToken);

                    if (
                        firstLeftToken.value === "let" &&
                        astUtils.isOpeningBracketToken(
                            sourceCode.getTokenAfter(firstLeftToken, astUtils.isNotClosingParenToken)
                        )
                    ) {

                        // ForInStatement#left expression cannot start with `let[`.
                        tokensToIgnore.add(firstLeftToken);
                    }
                }

                if (hasExcessParens(node.left)) {