Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(eslint-plugin): [prefer-optional-chain] support suggesting!foo || !foo.bar as a valid match for the rule#5594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
11 commits
Select commitHold shift + click to select a range
54f7470
feat/issue5245-negated-or-optional-chaining---fixed
Sep 3, 2022
c9e72c5
Not supported mixing with TSNonNullExpression
Sep 3, 2022
b628915
complex computed properties
Sep 3, 2022
a7a6d5b
Merge branch 'main' into feat/issue5245-negated-or-optional-chaining-…
Sep 26, 2022
585e197
Merge remote-tracking branch 'upstream/main' into feat/issue5245-nega…
Sep 29, 2022
befa01f
CR fix comment on unsupported cases and remove TODO comments
Sep 29, 2022
61751cd
Merge branch 'main' into feat/issue5245-negated-or-optional-chaining-…
Oct 4, 2022
4b33cab
Merge branch 'main' into feat/issue5245-negated-or-optional-chaining-…
Oct 19, 2022
b83107d
Merge branch 'main' into feat/issue5245-negated-or-optional-chaining-…
Nov 5, 2022
c2dc3bc
Merge remote-tracking branch 'upstream/main' into feat/issue5245-nega…
Nov 7, 2022
afdf2e7
CR: Remove unreachable uncovered check
Nov 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletionpackages/eslint-plugin/docs/rules/prefer-optional-chain.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
---
description: 'Enforce using concise optional chain expressions instead of chained logical ands.'
description: 'Enforce using concise optional chain expressions instead of chained logical ands, negated logical ors, or empty objects.'
---

> 🛑 This file is source code, not the primary documentation location! 🛑
Expand All@@ -23,9 +23,15 @@ 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@@ -43,6 +49,10 @@ foo?.['a']?.b?.c;
foo?.a?.b?.method?.();

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

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

<!--/tabs-->
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp