prefer-boolean-length-check.rst (604B)
1 prefer-boolean-length-check 2 =========================== 3 4 Prefers using a boolean length check rather than comparing against zero. 5 6 Examples of incorrect code for this rule: 7 ----------------------------------------- 8 9 .. code-block:: js 10 11 if (foo.length == 0) {} 12 if (foo.length > 0) {} 13 if (foo && foo.length == 0) {} 14 function bar() { return foo.length > 0 } 15 16 Examples of correct code for this rule: 17 --------------------------------------- 18 19 .. code-block:: js 20 21 if (foo.length && foo.length) {} 22 if (!foo.length) {} 23 var a = foo.length > 0 24 function bar() { return !!foo.length }