unicorn/prefer-dom-node-remove Pedantic ​
What it does ​
Prefers the use of child.remove() over parentNode.removeChild(child).
Why is this bad? ​
The DOM function Node#remove() is preferred over the indirect removal of an object with Node#removeChild().
Examples ​
Examples of incorrect code for this rule:
javascript
parentNode.removeChild(childNode);Examples of correct code for this rule:
javascript
childNode.remove();How to use ​
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny unicorn/prefer-dom-node-removejson
{
"rules": {
"unicorn/prefer-dom-node-remove": "error"
}
}