Skip to content

Commit 8af3eba

Browse files
committed
early-exit: add docs for "ignore-constructor"
1 parent b4c6c1b commit 8af3eba

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

docs/early-exit.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ for (const x of xs) {
5656
}
5757
```
5858

59-
An options object as in `"early-exit": [true, { "max-length": 4 }]` may be provided to configure what makes a block count as "large". The default is 2 lines.
59+
An options object as in `"early-exit": [true, { "max-length": 4, "ignore-constructor": true }]` may be provided.
60+
61+
`"max-length"` configures what makes a block count as "large". The default is 2 lines.
6062

6163
If you set `"max-length"` to `0`, the rule will always suggest an early return, regardless of the line count. For example:
6264

@@ -90,3 +92,6 @@ for (const x of xs) {
9092
bar();
9193
}
9294
```
95+
96+
In addition you can choose to ignore `if` statements within class constructors with `"ignore-constructor": true` which defaults to `false`.
97+
Enabling this option prevents potential mistakes by overriding the constructed object with a non-primitive return value.

0 commit comments

Comments
 (0)