Rules
no-leaked-event-listener
Full Name in eslint-plugin-react-web-api
Full Name in @eslint-react/eslint-plugin
Features
🔍
Presets
web-api
recommended
recommended-typescript
recommended-type-checked
What it does
Enforces that every addEventListener
in a component or custom Hook has a corresponding removeEventListener
.
Adding an event listener without removing it can lead to memory leaks and unexpected behavior. This is because the event listener will continue to exist even after the component or hook is unmounted.