Set#has()
is faster than Array#includes()
.
This rule is fixable.
const array = [1, 2, 3];
const hasValue = value => array.includes(value);
const set = new Set([1, 2, 3]);
const hasValue = value => set.has(value);
// This array is not only checking existence.
const array = [1, 2];
const hasValue = value => array.includes(value);
array.push(3);
// This array is only checked once.
const array = [1, 2, 3];
const hasOne = array.includes(1);