π Disallow using .length or Infinity as the deleteCount or skipCount argument of Array#{splice,toSpliced}().
πΌ This rule is enabled in the following configs: β
recommended, βοΈ unopinionated.
π§ This rule is automatically fixable by the --fix CLI option.
When calling Array#splice(start, deleteCount) and Array#toSpliced(start, skipCount), omitting the deleteCount and skipCount argument will delete or skip all elements after start. Using .length or Infinity is unnecessary.
// β
const foo = array.toSpliced(1, string.length);
// β
const foo = array.toSpliced(1);// β
const foo = array.toSpliced(1, Infinity);
// β
const foo = array.toSpliced(1);// β
const foo = array.toSpliced(1, Number.POSITIVE_INFINITY);
// β
const foo = array.toSpliced(1);// β
array.splice(1, string.length);
// β
array.splice(1);// β
array.splice(1, Infinity);
// β
array.splice(1);// β
array.splice(1, Number.POSITIVE_INFINITY);
// β
array.splice(1);