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-find
rule
#735
Conversation
b328e31
to
661da4c
Compare
The rule should be named |
I thought about this rule name too, I agree it should be |
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
81fcfef
to
bed2aaa
Compare
function foo([bar] = array.filter(baz)) {} This can't fix, right? |
3897a9e
to
b4d57b8
Compare
I'm going to add suggestion to const [foo = bar] = array.filter(fn); Suggestion 1: const foo = array.find(fn) || bar; Suggestion 2: const foo = array.find(fn) ?? bar; God, I thought this is simple, so I started it. |
Following cases not handled. const foo = array.filter(fn);
const bar = foo.shift(); I didn't handle this, because const foo = array.filter(fn);
while (foo.shift()) {} const foo = array.filter(fn);
const [bar] = foo; I didn't handle this, because we need handle/exclude this const foo = array.filter(fn);
const [bar = baz] = foo; I use suggestion for let bar;
const foo = array.filter(fn);
[bar] = foo; Same as second one. let bar;
const foo = array.filter(fn);
[bar = baz] = foo; |
No point in handling that. I have never seen such code in practice. |
@oscarmarcelo Can you help review this? |
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.
Well, I'm not yet that familiar with the intricacies of unicorn
, but for what I've seen here, this looks pretty solid! Congratulations and thank you, @fisker! 👏
Nice work as always, @fisker 👍 |
Fixes #730