summaryrefslogtreecommitdiffstats
path: root/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/no-compare-against-boolean-literals.rst
blob: b7785f2fc293abef26bbc2506d9748e45a38a2ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
no-compare-against-boolean-literals
===================================

Checks that boolean expressions do not compare against literal values
of ``true`` or ``false``. This is to prevent overly verbose code such as
``if (isEnabled == true)`` when ``if (isEnabled)`` would suffice.

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

.. code-block:: js

    if (foo == true) {}
    if (foo != false) {}
    if (false == foo) {}

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

.. code-block:: js

	  if (!foo) {}
    if (!!foo) {}