💼 This rule is enabled in the ✅ recommended
config.
🔧 This rule is automatically fixable by the --fix
CLI option.
When calling {String,Array,TypedArray}#slice(start, end)
, omitting the end
argument defaults it to the object's .length
. Passing it explicitly or using Infinity
is unnecessary.
// ❌
const foo = string.slice(1, string.length);
// ✅
const foo = string.slice(1);
// ❌
const foo = string.slice(1, Infinity);
// ✅
const foo = string.slice(1);
// ❌
const foo = string.slice(1, Number.POSITIVE_INFINITY);
// ✅
const foo = string.slice(1);