sindresorhus/eslint-plugin-unicorn

Rule proposal: `prefer-unshift`

Closed

#2,165 opened on Jul 6, 2023

 (2 comments) (2 reactions) (0 assignees)JavaScript (468 forks)user submission
help wantednew rule

Repository metrics

Stars
 (5,022 stars)
PR merge metrics
 (Avg merge 1d 16h) (399 merged PRs in 30d)

Description

Description

I see my newbine team member write following code when I code review:

 sItems.splice(0, 0, { itemType: 'Ungroup' });

Fail

arr.splice(0, 0, {})

Pass

arr.unshift({})

Additional Info

maybe another proposal to suggest:

arr.splice(0, 1)

to:

arr.shift()

Contributor guide