Skip to content

Commit

Permalink
fix(eslint-plugin): revert #5266 (#5564)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradzacher committed Aug 29, 2022
1 parent 81450ed commit 7a8afe2
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 465 deletions.
12 changes: 1 addition & 11 deletions packages/eslint-plugin/docs/rules/prefer-optional-chain.md
@@ -1,5 +1,5 @@
---
description: 'Enforce using concise optional chain expressions instead of chained logical ands, negated logical ors, or empty objects.'
description: 'Enforce using concise optional chain expressions instead of chained logical ands.'
---

> 🛑 This file is source code, not the primary documentation location! 🛑
Expand Down Expand Up @@ -65,15 +65,9 @@ foo && foo.a && foo.a.b && foo.a.b.c;
foo && foo['a'] && foo['a'].b && foo['a'].b.c;
foo && foo.a && foo.a.b && foo.a.b.method && foo.a.b.method();

// With empty objects
(((foo || {}).a || {}).b || {}).c;
(((foo || {})['a'] || {}).b || {}).c;

// With negated `or`s
!foo || !foo.bar;
!foo || !foo[bar];
!foo || !foo.bar || !foo.bar.baz || !foo.bar.baz();

// this rule also supports converting chained strict nullish checks:
foo &&
foo.a != null &&
Expand All @@ -91,10 +85,6 @@ foo?.['a']?.b?.c;
foo?.a?.b?.method?.();

foo?.a?.b?.c?.d?.e;

!foo?.bar;
!foo?.[bar];
!foo?.bar?.baz?.();
```

**Note:** there are a few edge cases where this rule will false positive. Use your best judgement when evaluating reported errors.
Expand Down

0 comments on commit 7a8afe2

Please sign in to comment.