sindresorhus/eslint-plugin-unicorn

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

Open

#1,715 opened on Feb 4, 2022

View on GitHub
 (2 comments) (3 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

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)

Contributor guide