Skip to content

useArraySome

biome.json
{
"linter": {
"rules": {
"nursery": {
"useArraySome": "error"
}
}
}
}

Prefer Array.prototype.some() over verbose existence checks.

array.filter(predicate).length > 0;
code-block.js:1:1 lint/nursery/useArraySome  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This expression uses .filter() and then checks whether the result is empty.

> 1 │ array.filter(predicate).length > 0;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

.some() matches that intent better and can stop as soon as it finds a match.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

Unsafe fix: Use .some() instead.

1 - array.filter(predicate).length·>·0;
1+ array.some(predicate);
2 2

array.findIndex(predicate) !== -1;
code-block.js:1:1 lint/nursery/useArraySome  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This expression uses .findIndex() to test whether any array element matches.

> 1 │ array.findIndex(predicate) !== -1;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

.some() makes that intent clearer because it returns a boolean directly.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

Unsafe fix: Use .some() instead.

1 - array.findIndex(predicate)·!==·-1;
1+ array.some(predicate);
2 2

if (array.find(predicate)) {}
code-block.js:1:5 lint/nursery/useArraySome ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This expression uses a .find()-style call as a boolean test.

> 1 │ if (array.find(predicate)) {}
^^^^^^^^^^^^^^^^^^^^^
2 │

.some() makes that intent clearer because it returns a boolean directly.

Use .some() instead.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

array.find(predicate) != null;
code-block.js:1:1 lint/nursery/useArraySome ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This expression uses .find() only to check whether an array element exists.

> 1 │ array.find(predicate) != null;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

.some() makes that intent clearer because it returns a boolean directly.

Use .some() if you only need to know whether any element matches.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

array.findLastIndex(predicate) !== -1;
code-block.js:1:1 lint/nursery/useArraySome  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This expression uses .findLastIndex() to test whether any array element matches.

> 1 │ array.findLastIndex(predicate) !== -1;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

.some() makes that intent clearer because it returns a boolean directly.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

Unsafe fix: Use .some() instead.

1 - array.findLastIndex(predicate)·!==·-1;
1+ array.some(predicate);
2 2

if (array.findLast(predicate)) {}
code-block.js:1:5 lint/nursery/useArraySome ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This expression uses a .find()-style call as a boolean test.

> 1 │ if (array.findLast(predicate)) {}
^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

.some() makes that intent clearer because it returns a boolean directly.

Use .some() instead.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

array.some(predicate);