sindresorhus / eslint-plugin-unicorn

More than 100 powerful ESLint rules
MIT License
4.19k stars 361 forks source link

`no-length-as-slice-end`: Forbid use `.length` as the `end` argument of `{Array,String,TypedArray}#slice()` #2387

Closed fisker closed 2 months ago

fisker commented 3 months ago

Description

Forbid use .length as the end argument of {Array,String,TypedArray}#slice()

Fail

array.slice(start, array.length)
array?.slice(start, array.length)

Pass

array.slice(start)
array?.slice(start)

Additional Info

No response

fisker commented 2 months ago

accepted