Ir al contenido

useArraySome

Esta página aún no está disponible en tu idioma.

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  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Prefer .some() over filter(…).length comparison.

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

Using .filter() followed by a length check iterates the entire array unnecessarily. .some() stops at the first match.

Use .some() when you only need to know if 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.

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  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Prefer .some() over findIndex(…) !== -1.

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

Use .some() when you only need to know if 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.

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 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Prefer .some() over find-family used as boolean.

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

Use .some() when you only need to know if 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.find(predicate) != null;
code-block.js:1:1 lint/nursery/useArraySome ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Prefer .some() over find(…) existence comparison.

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

Use .some() when you only need to know if 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  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Prefer .some() over findLastIndex(…) !== -1.

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

Use .some() when you only need to know if 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.

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 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Prefer .some() over find-family used as boolean.

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

Use .some() when you only need to know if 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.some(predicate);