Skip to content

arrayIncludesMethods

Reports using Array#some() with simple equality checks that can be replaced with .includes().

✅ This rule is included in the ts stylistic presets.

Array.prototype.some() is intended for more complex predicate checks. When the callback only performs a simple equality check (x === value or x == value), .includes() is more readable and expressive.

This rule reports when .some() can be simplified to .includes().

declare const array: string[];
array.some((item) => item === "value");
declare const array: string[];
array.some((item) => "value" === item);
declare const array: number[];
declare const target: number;
array.some((element) => element === target);
declare const array: string[];
array.some(function (item) {
return item === "value";
});

This rule is not configurable.

If your codebase uses .some() for consistency even with simple equality checks, or if you have a large number of existing uses that would be difficult to refactor, you might prefer to disable this rule.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.