> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# no-invalid-remove-event-listener

[Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2)
## Configuration

| Preset                              | Configured Value |
| ----------------------------------- | ---------------- |
| ✅ unicornPlugin.configs.recommended | `"error"`        |


```ts title=rslint.config.ts
import { defineConfig, unicornPlugin } from '@rslint/core';

export default defineConfig([
  unicornPlugin.configs.recommended,
  {
    rules: {
      'unicorn/no-invalid-remove-event-listener': 'error',
    },
  },
]);
```

## Rule Details

Prevent calling `EventTarget#removeEventListener()` with an inline function or
the result of an inline `.bind()` call. `removeEventListener()` must receive the
same function reference that was passed to `addEventListener()`.

Examples of **incorrect** code for this rule:

```javascript
window.removeEventListener("click", listener.bind(window));
window.removeEventListener("click", () => {});
window.removeEventListener("click", function () {});
```

Examples of **correct** code for this rule:

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

## Original Documentation

- [eslint-plugin-unicorn: no-invalid-remove-event-listener](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v73.0.0/docs/rules/no-invalid-remove-event-listener.md)
- [Source code](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v73.0.0/rules/no-invalid-remove-event-listener.js)
