# no-invalid-remove-event-listener

Rule `unicorn/no-invalid-remove-event-listener`. Prevent calling `EventTarget#removeEventListener()` with the result of an expression.

- Source: unicorn
- Technologies: JavaScript
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 91.3M weekly downloads of presets that enable it
- Trend: +126.8% last quarter
- Rank: #200 by reach, #95 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/no-invalid-remove-event-listener` | no | no | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/no-invalid-remove-event-listener.md) |
| Oxlint | `unicorn/no-invalid-remove-event-listener` | yes | no | plugin `unicorn`, category correctness | [docs](https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-invalid-remove-event-listener.html) |
| Biome | `nursery/noInvalidRemoveEventListener` | yes | no | group nursery, since 2.6.5 | [docs](https://biomejs.dev/linter/rules/no-invalid-remove-event-listener/) |

## Code examples

### Incorrect: the rule reports this

```js
window.removeEventListener('click', listener.bind(window));
```

```js
window.removeEventListener('click', () => {});
```

```js
window.removeEventListener('click', function () {});
```

### Correct: the rule accepts this

```js
window.removeEventListener('click', listener);
```

```js
window.removeEventListener('click', getListener());
```

```js
const listener = () => {};
window.addEventListener('click', listener);
// ...
window.removeEventListener('click', listener);
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import unicorn from "eslint-plugin-unicorn";

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/no-invalid-remove-event-listener": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "unicorn/no-invalid-remove-event-listener": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "noInvalidRemoveEventListener": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Oxlint default](https://lintradar.dev/presets/oxlint-default.md) | Oxlint | `oxlint` | 111 | 50.8M | +183.6% |
| [Biome recommended](https://lintradar.dev/presets/biome-recommended.md) | Biome | `@biomejs/biome` | 491 | 28.5M | +106.8% |
| [Unicorn recommended](https://lintradar.dev/presets/unicorn-recommended.md) | ESLint | `eslint-plugin-unicorn` | 340 | 9.5M | +30.3% |
| [Unicorn unopinionated](https://lintradar.dev/presets/unicorn-unopinionated.md) | ESLint | `eslint-plugin-unicorn` | 236 | 9.5M | +30.3% |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [unicorn/no-invalid-fetch-options](https://lintradar.dev/rules/unicorn/no-invalid-fetch-options.md): Disallow invalid options in `fetch()` and `new Request()`.
- [unicorn/no-single-promise-in-promise-methods](https://lintradar.dev/rules/unicorn/no-single-promise-in-promise-methods.md): Disallow passing single-element arrays to `Promise` methods.
- [unicorn/no-await-in-promise-methods](https://lintradar.dev/rules/unicorn/no-await-in-promise-methods.md): Disallow using `await` in `Promise` method parameters.
- [unicorn/no-thenable](https://lintradar.dev/rules/unicorn/no-thenable.md): Disallow `then` property.
- [unicorn/no-useless-fallback-in-spread](https://lintradar.dev/rules/unicorn/no-useless-fallback-in-spread.md): Disallow useless fallback when spreading in object literals.
- [unicorn/no-useless-length-check](https://lintradar.dev/rules/unicorn/no-useless-length-check.md): Disallow useless array length check.

---

Web page: https://lintradar.dev/rules/unicorn/no-invalid-remove-event-listener. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
