--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: invalid.js --- # Input ```jsx if (Boolean(foo)) { } if (!!Boolean(foo)) { } if (!Boolean(foo)) { } while (!!foo) {} let x = 1; do { 1 + 1; } while (Boolean(x)); for (; !!foo; ) {} new Boolean(!!x); !!!x; !Boolean(x); ``` # Diagnostics ``` invalid.js:1:5 lint/complexity/noExtraBooleanCast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Avoid redundant `Boolean` call > 1 │ if (Boolean(foo)) { │ ^^^^^^^^^^^^ 2 │ } 3 │ i It is not necessary to use `Boolean` call when a value will already be coerced to a boolean. i Unsafe fix: Remove redundant `Boolean` call 1 │ if·(Boolean(foo))·{ │ -------- - ``` ``` invalid.js:4:5 lint/complexity/noExtraBooleanCast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Avoid redundant double-negation. 2 │ } 3 │ > 4 │ if (!!Boolean(foo)) { │ ^^^^^^^^^^^^^^ 5 │ } 6 │ i It is not necessary to use double-negation when a value will already be coerced to a boolean. i Unsafe fix: Remove redundant double-negation 4 │ if·(!!Boolean(foo))·{ │ -- ``` ``` invalid.js:4:7 lint/complexity/noExtraBooleanCast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Avoid redundant `Boolean` call 2 │ } 3 │ > 4 │ if (!!Boolean(foo)) { │ ^^^^^^^^^^^^ 5 │ } 6 │ i It is not necessary to use `Boolean` call when a value will already be coerced to a boolean. i Unsafe fix: Remove redundant `Boolean` call 4 │ if·(!!Boolean(foo))·{ │ -------- - ``` ``` invalid.js:7:6 lint/complexity/noExtraBooleanCast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Avoid redundant `Boolean` call 5 │ } 6 │ > 7 │ if (!Boolean(foo)) { │ ^^^^^^^^^^^^ 8 │ } 9 │ i It is not necessary to use `Boolean` call when a value will already be coerced to a boolean. i Unsafe fix: Remove redundant `Boolean` call 7 │ if·(!Boolean(foo))·{ │ -------- - ``` ``` invalid.js:10:8 lint/complexity/noExtraBooleanCast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Avoid redundant double-negation. 8 │ } 9 │ > 10 │ while (!!foo) {} │ ^^^^^ 11 │ 12 │ let x = 1; i It is not necessary to use double-negation when a value will already be coerced to a boolean. i Unsafe fix: Remove redundant double-negation 10 │ while·(!!foo)·{} │ -- ``` ``` invalid.js:15:10 lint/complexity/noExtraBooleanCast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Avoid redundant `Boolean` call 13 │ do { 14 │ 1 + 1; > 15 │ } while (Boolean(x)); │ ^^^^^^^^^^ 16 │ 17 │ for (; !!foo; ) {} i It is not necessary to use `Boolean` call when a value will already be coerced to a boolean. i Unsafe fix: Remove redundant `Boolean` call 15 │ }·while·(Boolean(x)); │ -------- - ``` ``` invalid.js:17:8 lint/complexity/noExtraBooleanCast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Avoid redundant double-negation. 15 │ } while (Boolean(x)); 16 │ > 17 │ for (; !!foo; ) {} │ ^^^^^ 18 │ 19 │ new Boolean(!!x); i It is not necessary to use double-negation when a value will already be coerced to a boolean. i Unsafe fix: Remove redundant double-negation 17 │ for·(;·!!foo;·)·{} │ -- ``` ``` invalid.js:19:13 lint/complexity/noExtraBooleanCast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Avoid redundant double-negation. 17 │ for (; !!foo; ) {} 18 │ > 19 │ new Boolean(!!x); │ ^^^ 20 │ 21 │ !!!x; i It is not necessary to use double-negation when a value will already be coerced to a boolean. i Unsafe fix: Remove redundant double-negation 19 │ new·Boolean(!!x); │ -- ``` ``` invalid.js:21:2 lint/complexity/noExtraBooleanCast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Avoid redundant double-negation. 19 │ new Boolean(!!x); 20 │ > 21 │ !!!x; │ ^^^ 22 │ 23 │ !Boolean(x); i It is not necessary to use double-negation when a value will already be coerced to a boolean. i Unsafe fix: Remove redundant double-negation 21 │ !!!x; │ -- ``` ``` invalid.js:23:2 lint/complexity/noExtraBooleanCast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Avoid redundant `Boolean` call 21 │ !!!x; 22 │ > 23 │ !Boolean(x); │ ^^^^^^^^^^ i It is not necessary to use `Boolean` call when a value will already be coerced to a boolean. i Unsafe fix: Remove redundant `Boolean` call 23 │ !Boolean(x); │ -------- - ```