removeChild() makes you find a node's parent before you can remove the node, and it throws if that isn't the node's parent. You call remove() on the node itself.
removeChild() returns the node it removed and remove() returns undefined. If you need the node afterwards, keep your own reference to it.
The rule doesn't know types. It reports every call to a method named removeChild with one argument that could be a node.
Configure
Off by default. To turn it on:
bunfig.toml
[lint.rules]
"unicorn/prefer-dom-node-remove" = "error" # or "warn"
Examples
Reported:
item.parentNode.removeChild(item);
list.removeChild(list.firstChild);
Not reported:
item.remove();
list.firstChild.remove();