Skip to main content

Require Multiline Condition Groups

Require expanded formatting for parenthesized groups in mixed-operator logical expressions.

Summary

The require-multiline-condition-groups rule checks LogicalExpression nodes that mix operators (e.g., && inside ||). When a logical expression is a parenthesized group within a parent expression using a different operator, each operand in the group must start on its own line. No threshold — groups are always expanded.

This covers every context — if, while, do...while, for, ternary, return, variable declarations, and standalone expressions.

Why Use This Rule?

  1. Parenthesized groups inside mixed-operator expressions compress multiple conditions into a single visual block, hiding logic.
  2. Expanding each operand onto its own line makes the group boundaries and individual conditions scannable at a glance.
  3. Consistent group formatting reduces cognitive load when reading complex boolean logic.

Examples

Configuration

Options

warning

ignoreFiles is an escape hatch for files where this rule genuinely does not apply. It is not intended for routine use.

OptionTypeDefaultDescription
groupStylestring"operator-before-open"Controls where the outer operator sits relative to the closing/opening parens of adjacent groups.
ignoreFilesstring[][]File patterns to skip.

groupStyle Values

ValueFormatDescription
"operator-before-open")
|| (
Closing parenthesis alone, operator + opening parenthesis next line.
"operator-after-close") ||
(
Closing parenthesis + operator together, opening parenthesis next line.
"operator-inline") || (All three on one line (operands within still multiline).

Autofix

Autofix is not available for this rule. Flagged code must be updated manually.

Troubleshooting

  • Warning fires on a single-operator chain — This rule only fires when operators are mixed (e.g., && inside ||). If all operators are the same, the rule does not apply.
  • Group style error when operands are already expanded — Check that the outer operator placement matches your configured groupStyle option.