Skip to content

Latest commit

Β 

History

History
30 lines (20 loc) Β· 1.12 KB

File metadata and controls

30 lines (20 loc) Β· 1.12 KB

prefer-dom-node-remove

πŸ“ Prefer childNode.remove() over parentNode.removeChild(childNode).

πŸ’Ό This rule is enabled in the following configs: βœ… recommended, β˜‘οΈ unopinionated.

πŸ”§πŸ’‘ This rule is automatically fixable by the --fix CLI option and manually fixable by editor suggestions.

Enforces the use of, for example, child.remove(); over child.parentNode.removeChild(child);. The DOM function Node#remove() is preferred over the indirect removal of an object with Node#removeChild().

Examples

// ❌
parentNode.removeChild(foo);

// βœ…
foo.remove();
// ❌
parentNode.removeChild(this);

// βœ…
this.remove();