summaryrefslogtreecommitdiffstats
path: root/docs/code-quality/lint/linters/eslint-plugin-mozilla/balanced-listeners.rst
blob: f53c11e7aa3f27d2e96a0375e310ea84b95c0608 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
balanced-listeners
==================

Checks that for every occurrence of 'addEventListener' or 'on' there is an
occurrence of 'removeEventListener' or 'off' with the same event name.

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

.. code-block:: js

    elt.addEventListener('click', handler, false);

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

.. code-block:: js

		elt.addEventListener('event', handler);
		elt.removeEventListener('event', handler);