sindresorhus/eslint-plugin-unicorn

Support check `.unshift()` in `no-array-push-push`

Chiusa

#1019 aperta il 14 gen 2021

 (1 commento) (4 reazioni) (0 assegnatari)JavaScript (468 fork)user submission
enhancementhelp wanted

Metriche repository

Star
 (5022 stelle)
Metriche merge PR
 (Merge medio 4h 30m) (26 PR mergiate in 30 g)

Descrizione

no-array-push-push was added in #1015, only check .push(), opening a new issue to see if someone need this.

Fail

foo.unshift(1);
foo.unshift(2);

Pass

const length = foo.unshift(1);
foo.unshift(2);

Note: .unshift() is a little different, need change arguments order, and consider side effects in each call.(.push only consider side effect in second call).

Original issue #937

Guida contributor