-
-
Notifications
You must be signed in to change notification settings - Fork 364
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
Add prefer-array-some
rule
#887
Conversation
Is it possible to add autofixing? |
It's possible, but not safe. const array = [""]
// find `""`, falsely
if (array.find(element => typeof element !== 'number'));
// true
if (array.some(element => typeof element !== 'number')); |
Note to my self, forgot negative test if (!foo.find(fn)){} |
After a second thought, this rule, should not related to const foo = !array.find(element => element === foo); Should be reported too. The same thing is missing in And it seems hard to implement. Maybe I'll use some logic from |
…nicorn into prefer-array-some
97d4fb5
to
8d3e7fb
Compare
Ready for review. |
Nice! I really like how simple the rule logic is because it's just using a reusable utility. 👍🏻 |
Fixes #736