Skip to content

Commit 9133c1b

Browse files
committed
docs(indent-binary-ops): improve docs, close typescript-eslint#226
1 parent 48b915f commit 9133c1b

File tree

1 file changed

+13
-3
lines changed
  • packages/eslint-plugin-plus/rules/indent-binary-ops

1 file changed

+13
-3
lines changed

packages/eslint-plugin-plus/rules/indent-binary-ops/README.md

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Rule Details
22

33
Indentation for binary operators in multiline expressions.
4-
This is a supplement to the [`indent`](https://eslint.style/rules/default/indent) rule.
4+
This is a supplement to the [`indent`](https://eslint.style/rules/default/indent) rule. They are supposed to be used together with the same indentation size.
55

66
## Options
77

@@ -11,18 +11,28 @@ For example, for 2-space indentation:
1111

1212
```json
1313
{
14-
"indent-binary-ops": ["error", 2]
14+
"@stylistic/indent": ["error", 2],
15+
"@stylistic/indent-binary-ops": ["error", 2]
1516
}
1617
```
1718

1819
Or for tabbed indentation:
1920

2021
```json
2122
{
22-
"indent-binary-ops": ["error", "tab"]
23+
"@stylistic/indent": ["error", "tab"],
24+
"@stylistic/indent-binary-ops": ["error", "tab"]
2325
}
2426
```
2527

28+
This rule works by:
29+
30+
- Only check for binary operations that are multiline.
31+
- Align the indentation of the second line with the same indentation of the first line (handled by the `indent` rule)
32+
- In some conditions (e.g. last line ends with an open bracket), the indentation of the second line will be one level increased to the first line's indentation.
33+
34+
## Examples
35+
2636
Examples of **incorrect** code for this rule:
2737

2838
:::incorrect

0 commit comments

Comments
 (0)