sindresorhus/eslint-plugin-unicorn

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

开放

#1,715 创建于 2022年2月4日

 (2 条评论) (3 个反应) (0 位负责人)JavaScript (468 个派生)user submission
help wantednew rule

仓库指标

星标
 (5,022 个星标)
PR 合并指标
 (平均合并 4小时 30分钟) (30 天内合并 26 个 PR)

描述

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)

贡献者指南