-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(eslint-plugin): [prefer-includes] ignore option chaining before indexOfs #3432
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
fix(eslint-plugin): [prefer-includes] ignore option chaining before indexOfs #3432
Conversation
Thanks for the PR, @JoshuaKGoldberg! 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. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day. |
Codecov Report
@@ Coverage Diff @@
## master #3432 +/- ##
==========================================
- Coverage 92.66% 92.65% -0.01%
==========================================
Files 324 324
Lines 11188 11191 +3
Branches 3157 3158 +1
==========================================
+ Hits 10367 10369 +2
Misses 365 365
- Partials 456 457 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
Question: Do we want to keep the reporting but remove the fixer only?
I.e. the user has to evaluate and fix the code as required
|
||
return acc; | ||
}, []); | ||
} |
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 addOptional
wrapper was hiding the test cases from being checked by Prettier... although I could keep it in and remove the output
field, it does feel weird to me to auto-generate them this way when the only difference between the two is checking callNode.parent.parent
vs. callNode.parent
?
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 was just my lazy way of covering all the cases 😅
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.
LGTM - thanks for fixing this!
|
||
return acc; | ||
}, []); | ||
} |
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 was just my lazy way of covering all the cases 😅
Fixes #3341
I was on the fence of whether to just remove the fixer for
?.indexOf
instead, but went with removing it altogether because of the subtle behavior differences:x = undefined
x = ""
x = "y"
x?.indexOf("y") === -1
false
true
false
!x?.includes("y")
true
❌true
false
x?.indexOf("y") !== -1
true
false
true
x?.includes("y")
undefined
❌false
true