Skip to content

Commit

Permalink
chore: change option name to ternaryOperandBinaryExpressions
Browse files Browse the repository at this point in the history
  • Loading branch information
kecrily committed Jun 20, 2023
1 parent e0f4748 commit 02c3469
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/rules/no-extra-parens.js
Expand Up @@ -46,7 +46,7 @@ module.exports = {
type: "object",
properties: {
conditionalAssign: { type: "boolean" },
conditionalTernary: { type: "boolean" },
ternaryOperandBinaryExpressions: { type: "boolean" },
nestedBinaryExpressions: { type: "boolean" },
returnAssign: { type: "boolean" },
ignoreJSX: { enum: ["none", "all", "single-line", "multi-line"] },
Expand Down Expand Up @@ -77,7 +77,7 @@ module.exports = {
const precedence = astUtils.getPrecedence;
const ALL_NODES = context.options[0] !== "functions";
const EXCEPT_COND_ASSIGN = ALL_NODES && context.options[1] && context.options[1].conditionalAssign === false;
const EXCEPT_COND_TERNARY = ALL_NODES && context.options[1] && context.options[1].conditionalTernary === false;
const EXCEPT_COND_TERNARY = ALL_NODES && context.options[1] && context.options[1].ternaryOperandBinaryExpressions === false;
const NESTED_BINARY = ALL_NODES && context.options[1] && context.options[1].nestedBinaryExpressions === false;
const EXCEPT_RETURN_ASSIGN = ALL_NODES && context.options[1] && context.options[1].returnAssign === false;
const IGNORE_JSX = ALL_NODES && context.options[1] && context.options[1].ignoreJSX;
Expand Down
20 changes: 10 additions & 10 deletions tests/lib/rules/no-extra-parens.js
Expand Up @@ -303,12 +303,12 @@ ruleTester.run("no-extra-parens", rule, {
{ code: "while (((foo = bar()))) {}", options: ["all", { conditionalAssign: false }] },
{ code: "var a = (((b = c))) ? foo : bar;", options: ["all", { conditionalAssign: false }] },

// ["all", { conditionalTernary: false }] enables extra parens around conditional ternary
{ code: "(a && b) ? foo : bar", options: ["all", { conditionalTernary: false }] },
{ code: "(a - b > a) ? foo : bar", options: ["all", { conditionalTernary: false }] },
{ code: "foo ? (bar || baz) : qux", options: ["all", { conditionalTernary: false }] },
{ code: "foo ? bar : (baz || qux)", options: ["all", { conditionalTernary: false }] },
{ code: "(a, b) ? (c, d) : (e, f)", options: ["all", { conditionalTernary: false }] },
// ["all", { ternaryOperandBinaryExpressions: false }] enables extra parens around conditional ternary
{ code: "(a && b) ? foo : bar", options: ["all", { ternaryOperandBinaryExpressions: false }] },
{ code: "(a - b > a) ? foo : bar", options: ["all", { ternaryOperandBinaryExpressions: false }] },
{ code: "foo ? (bar || baz) : qux", options: ["all", { ternaryOperandBinaryExpressions: false }] },
{ code: "foo ? bar : (baz || qux)", options: ["all", { ternaryOperandBinaryExpressions: false }] },
{ code: "(a, b) ? (c, d) : (e, f)", options: ["all", { ternaryOperandBinaryExpressions: false }] },

// ["all", { nestedBinaryExpressions: false }] enables extra parens around conditional assignments
{ code: "a + (b * c)", options: ["all", { nestedBinaryExpressions: false }] },
Expand Down Expand Up @@ -922,10 +922,10 @@ ruleTester.run("no-extra-parens", rule, {
invalid("a ? b : (c = d)", "a ? b : c = d", "AssignmentExpression"),
invalid("(c = d) ? (b) : c", "(c = d) ? b : c", "Identifier", null, { options: ["all", { conditionalAssign: false }] }),
invalid("(c = d) ? b : (c)", "(c = d) ? b : c", "Identifier", null, { options: ["all", { conditionalAssign: false }] }),
invalid("(a) ? foo : bar", "a ? foo : bar", "Identifier", null, { options: ["all", { conditionalTernary: false }] }),
invalid("(a()) ? foo : bar", "a() ? foo : bar", "CallExpression", null, { options: ["all", { conditionalTernary: false }] }),
invalid("(a.b) ? foo : bar", "a.b ? foo : bar", "MemberExpression", null, { options: ["all", { conditionalTernary: false }] }),
invalid("(a || b) ? foo : (bar)", "(a || b) ? foo : bar", "Identifier", null, { options: ["all", { conditionalTernary: false }] }),
invalid("(a) ? foo : bar", "a ? foo : bar", "Identifier", null, { options: ["all", { ternaryOperandBinaryExpressions: false }] }),
invalid("(a()) ? foo : bar", "a() ? foo : bar", "CallExpression", null, { options: ["all", { ternaryOperandBinaryExpressions: false }] }),
invalid("(a.b) ? foo : bar", "a.b ? foo : bar", "MemberExpression", null, { options: ["all", { ternaryOperandBinaryExpressions: false }] }),
invalid("(a || b) ? foo : (bar)", "(a || b) ? foo : bar", "Identifier", null, { options: ["all", { ternaryOperandBinaryExpressions: false }] }),
invalid("f((a = b))", "f(a = b)", "AssignmentExpression"),
invalid("a, (b = c)", "a, b = c", "AssignmentExpression"),
invalid("a = (b * c)", "a = b * c", "BinaryExpression"),
Expand Down

0 comments on commit 02c3469

Please sign in to comment.