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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rule proposal: prefer-array-some
#736
Comments
Update: on second thought, |
I wouldn't specifically suggest BTW, I did a rule to eslint proposal regarding a general unused return values rule a while ago, maybe it is worth exploring here, #741. |
I like the idea of suggesting
@silverwind What is the connection? In this case, the return value is being used, so what exactly do you mean? |
There's no real connection, my mistake. Return value is used here (thought wrongly). |
My issue with |
Why are you thinking about breaking loop? When use |
Yeah it might just be me and function hasBiggerThan10(array) {
return array.some(element => element > 10);
}
function hasBiggerThan10(array) {
for (const element of array) {
if (element > 10) return true;
}
return false;
} |
const isBiggerThan10 = element => element > 10;
function hasBiggerThan10(array) {
return array.some(isBiggerThan10);
}
function allBiggerThan10(array) {
return array.every(isBiggerThan10);
} Readable to me , and I don't see why should think about breaking loop. |
Maybe I've expressed myself badly but the "hard" part is remembering to return a truthy value in the callback. One distinct advantage |
Yes, I agree in some case loop better, some also useful to avoid use |
Although this could be a taste issue, Array.from(new Set([ 1, 2, 3, 2 ])).some(...)
Array.from('abc').some(...)
Array.from(document.querySelectorAll('div')).some(...) |
This is accepted. |
WIP |
Fail
Pass
Just experienced one few days ago, and kind of follow up for #730
The text was updated successfully, but these errors were encountered: