-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(eslint-plugin): [no-unnecessary-condition] don't report on unnecessary optional array index access when noUncheckedIndexedAccess
is enabled
#10961
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for the PR, @ronami! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
View your CI Pipeline Execution ↗ for commit e3a479c.
☁️ Nx Cloud last updated this comment at |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #10961 +/- ##
==========================================
+ Coverage 87.58% 87.97% +0.38%
==========================================
Files 470 470
Lines 16095 16710 +615
Branches 4668 4711 +43
==========================================
+ Hits 14097 14700 +603
- Misses 1642 1664 +22
+ Partials 356 346 -10
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
noUncheckedIndexedAccess
is enablednoUncheckedIndexedAccess
is enabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice and clean! 🧹
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great!! I definitely like the behavior that the test cases demonstrate 🙂
3241e46
into
typescript-eslint:main
PR Checklist
noUncheckedIndexedAccess
is enabled #10960Overview
This PR addresses #10960 and disables the special-casing of optional array index access when
noUncheckedIndexedAccess
is enabled.This makes the rule report cases like the following:
Note that this also causes the rule to report on unnecessary optional index access that's deeper in the chain (only when
noUncheckedIndexedAccess
is turned on):I've added a couple of tests to verify the rule handles these cases correctly when
noUncheckedIndexedAccess
is enabled.