src/content/docs/linter/rules/use-array-some.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> :::caution This rule is part of the [nursery](/linter/#nursery) group. This means that it is experimental and the behavior can change at any time. ::: ## Summary - Rule available since: `v2.4.5` - Diagnostic Category: [`lint/nursery/useArraySome`](/reference/diagnostics#diagnostic-category) - This rule has an [**unsafe**](/linter/#unsafe-fixes) fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - Sources: - Inspired from [`unicorn/prefer-array-some`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-some.md){
"linter": {
"rules": {
"nursery": {
"useArraySome": "error"
}
}
}
}
Prefer Array.prototype.some() over verbose existence checks.
array.filter(predicate).length > 0;
array.findIndex(predicate) !== -1;
if (array.find(predicate)) {}
array.find(predicate) != null;
array.findLastIndex(predicate) !== -1;
if (array.findLast(predicate)) {}
array.some(predicate);