The prefer-array-some
rule is not triggered when the .find()
result is assigned to a variable:
const arr = [];
const hasFoo = arr.find(val => val === 'foo');
if (hasFoo) console.log('foo');
Obviously it shouldn't be triggered if hasFoo
were to be used elsewhere for anything other than element existence checks, but if that's all it's used for, I'd expect it to trigger the rule.
Variable assignment of these element existence checks is useful when the predicate function is long, but also to generally make code read more prose-like.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too