Require optional chaining instead of repeated logical guard access.
| Property | Value |
|---|---|
| Type | suggestion |
| Fixable | Yes (code) |
| Recommended | warn |
| Strict | error |
Patterns like obj && obj.value or fn && fn() duplicate the same guard expression and make code harder to read. Optional chaining expresses the same intent directly in one expression and removes repetition.
const profile = user?.profile;
const result = fn?.();
const name = account?.owner?.name;const profile = user && user.profile;
const result = fn && fn();
const name = account.owner && account.owner.name;This rule has no options:
'zero-tolerance/require-optional-chaining': 'error'