Prefer childNode.remove() over parentNode.removeChild(childNode) ​
💼 This rule is enabled in the ✅ recommended config.
🔧💡 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().
Fail ​
js
parentNode.removeChild(foo);
parentNode.removeChild(this);Pass ​
js
foo.remove();
this.remove();