Registry / testing / eslint-plugin-listeners

eslint-plugin-listeners

JSON →
library1.5.1jsnpmunverified

ESLint plugin that provides rules to prevent memory leaks caused by event listeners that are not removed. Current stable version is 1.5.1, with infrequent releases. It checks for missing removeEventListener calls, mismatched add/remove listener functions, and inline function listeners. Unlike generic linting approaches, this plugin is purpose-built for event listener hygiene in JavaScript/TypeScript projects.

npm install eslint-plugin-listeners
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-LIST
E
eslint-plugin-listeners
testingjavascriptv1.5.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

no-missing-remove-event-listener
{ "rules": { "listeners/no-missing-remove-event-listener": "error" } }
{ "rules": { "eslint-plugin-listeners/no-missing-remove-event-listener": "error" } }
In ESLint config, prefix the rule name with 'listeners/' not 'eslint-plugin-listeners/'.
matching-remove-event-listener
{ "rules": { "listeners/matching-remove-event-listener": "error" } }
{ "rules": { "matching-remove-event-listener": "error" } }
When using the plugin, rules must be prefixed with 'listeners/'.
plugin:listeners/recommended
{ "extends": ["plugin:listeners/recommended"] }
{ "extends": ["listeners/recommended"] }
Must include the 'plugin:' prefix when extending a config from an ESLint plugin.

Quickstart showing installation, configuration, and a rule violation detection using the plugin.

// Install: // npm install --save-dev eslint eslint-plugin-listeners // .eslintrc.json: { "plugins": ["listeners"], "extends": ["plugin:listeners/recommended"], "rules": { "listeners/no-inline-function-event-listener": "error" } } // Example code that flags: document.addEventListener('click', function() { // inline function console.log('clicked'); });
Debug
Known issues
gotchaRule 'no-missing-remove-event-listener' requires add and remove functions to be called within the same scope. Cross-scope patterns (e.g., storing listener reference) may be missed.
fix
Ensure addEventListener and removeEventListener calls are in the same function scope or use proper references.
affects: >=0.0.0
gotchaThe plugin does not detect removals via removeAllListeners by default. Ensure to configure custom remove functions if using removeAllListeners.
fix
Use the 'removeAllListeners' option in rule configuration to include removeAllListeners calls.
affects: >=1.5.0
gotchaVersion 1.4.0 introduced TypeScript support via TSESLint. If using an older version, TypeScript AST may not be fully supported.
fix
Upgrade to >=1.4.0 for proper TypeScript support.
affects: <1.4.0
gotchaThe plugin relies on ESLint's AST analysis and may not catch all dynamic listener additions/removals (e.g., using variables for function references).
fix
Use static function references whenever possible; manually review dynamic cases.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Failed to load plugin 'listeners' declared in '.eslintrc.json': Cannot find module 'eslint-plugin-listeners'
The plugin is not installed or is installed globally while ESLint is local (or vice versa).
fix
Run `npm install --save-dev eslint-plugin-listeners` in the project directory.
TypeError: Cannot read property 'map' of undefined (eslint-plugin-listeners)
Rule configuration missing required options or using an unsupported format.
fix
Check rule configuration in .eslintrc; ensure it's an object with severity string (e.g., 'error') or array with options.
Upgrade
Version history
1.5.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
eslint-plugin-listeners — npm install eslint-plugin-listeners · libregistry