You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/early-exit.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,7 +56,9 @@ for (const x of xs) {
56
56
}
57
57
```
58
58
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.
60
62
61
63
If you set `"max-length"` to `0`, the rule will always suggest an early return, regardless of the line count. For example:
62
64
@@ -90,3 +92,6 @@ for (const x of xs) {
90
92
bar();
91
93
}
92
94
```
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