tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

no-compare-against-boolean-literals.rst (598B)


      1 no-compare-against-boolean-literals
      2 ===================================
      3 
      4 Checks that boolean expressions do not compare against literal values
      5 of ``true`` or ``false``. This is to prevent overly verbose code such as
      6 ``if (isEnabled == true)`` when ``if (isEnabled)`` would suffice.
      7 
      8 Examples of incorrect code for this rule:
      9 -----------------------------------------
     10 
     11 .. code-block:: js
     12 
     13    if (foo == true) {}
     14    if (foo != false) {}
     15    if (false == foo) {}
     16 
     17 Examples of correct code for this rule:
     18 ---------------------------------------
     19 
     20 .. code-block:: js
     21 
     22   if (!foo) {}
     23    if (!!foo) {}