Saw splice
being used instead of push
/pop
/shift
/unshift
in some projects. AFAIK it brings no performance gain and is harder to read/understand than the latter ones.
Basically bans:
array.splice(index, 0)
(can be removed as no-op)array.splice(0, 1)
(as substitutable by array.shift()
)array.splice(0, 0, element)
(as substitutable by array.unshift(element)
- for 1 or more elements)array.splice(array.length - 1, 1)
(as substitutable by array.pop()
)array.splice(array.length, 0, element)
(as substitutable by array.push(element)
- for 1 or more elements)Should be easy to implement auto-fixer for those replacements.
array.splice(start, 0)
array.splice(0, 1)
array.splice(array.length, 0, element)
array.shift()
array.push(element)
no-unnecessary-splice
Happy to work on this once accepted (already have a stub).
This would make #2165 not needed any more
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too