---
title: "unicorn/prefer-dom-node-remove"
description: "Require `child.remove()` instead of `parent.removeChild(child)`"
# Generated by src/codegen/lint-rule-docs.ts. Do not edit below this line.
plugin: "unicorn"
aliases: []
kind: "suggestion"
category: "pedantic"
default: "off"
fixable: "no"
typeAware: false
deprecated: false
---

`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.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"unicorn/prefer-dom-node-remove" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 2} */}
```js
item.parentNode.removeChild(item);
list.removeChild(list.firstChild);
```

Not reported:

{/* good */}
```js
item.remove();
list.firstChild.remove();
```
