Skip to content

unicorn/prefer-array-some Pedantic

🛠️ An auto-fix is available for this rule.

What it does

Prefers using Array#some over Array#find(), Array#findLast() and a non-zero length check on the result of Array#filter()

Why is this bad?

Using .some() is more idiomatic and easier to read.

Example

Examples of incorrect code for this rule:

javascript
const foo = array.find(fn) ? bar : baz;

Examples of correct code for this rule:

javascript
const foo = array.some(fn) ? bar : baz;

References

Released under the MIT License.