Skip to content

@stylistic/

indent-binary-ops

Rule Details

Indentation for binary operators in multiline expressions. This is a supplement to the indent rule.

Options

Same as the indent rule, it takes an option for the indentation size.

For example, for 2-space indentation:

json
{
  "indent-binary-ops": ["error", 2]
}

Or for tabbed indentation:

json
{
  "indent-binary-ops": ["error", "tab"]
}

Examples of incorrect code for this rule:

ts
/*eslint @stylistic/indent-binary-ops: ["error", 2]*/

if (a
    && b
      && c
    && (d
          || e
            || f
          )
) {
  foo()
}
incorrect

Examples of correct code for this rule:

ts
/*eslint @stylistic/indent-binary-ops: ["error", 2]*/

if (a
  && b
  && c
  && (d
    || e
    || f
  )
) {
  foo()
}
correct

Released under the MIT License.