sindresorhus/eslint-plugin-unicorn

Rule proposal: Extend `prefer-modern-dom-apis` with `insertBefore` => `prepend`

Aperta

#1715 aperta il 4 feb 2022

 (2 commenti) (3 reazioni) (0 assegnatari)JavaScript (468 fork)user submission
help wantednew rule

Metriche repository

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

Descrizione

Description

Any usage of element.insertBefore(child, element.firstChild) can be converted to element.prepend(child).

(Note, this isn't safe with element.firstChildElement)

Fail

element.insertBefore(child, element.firstChild);

Pass

element.prepend(child)

Guida contributor