noExtraBooleanCast
此内容尚不支持你的语言。
Diagnostic Category: lint/complexity/noExtraBooleanCast
Since: v1.0.0
Sources:
- Same as:
no-extra-boolean-cast
Disallow unnecessary boolean casts
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-block.js:1:6 lint/complexity/noExtraBooleanCast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Avoid redundant Boolean
call
> 1 │ if (!Boolean(foo)) {
│ ^^^^^^^^^^^^
2 │ }
3 │
ℹ It is not necessary to use Boolean
call when a value will already be coerced to a boolean.
ℹ Unsafe fix: Remove redundant Boolean
call
1 │ if·(!Boolean(foo))·{
│ -------- -
code-block.js:1:8 lint/complexity/noExtraBooleanCast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Avoid redundant double-negation.
> 1 │ while (!!foo) {}
│ ^^^^^
2 │
ℹ It is not necessary to use double-negation when a value will already be coerced to a boolean.
ℹ Unsafe fix: Remove redundant double-negation
1 │ while·(!!foo)·{}
│ --
code-block.js:4:10 lint/complexity/noExtraBooleanCast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Avoid redundant Boolean
call
2 │ do {
3 │ 1 + 1;
> 4 │ } while (Boolean(x));
│ ^^^^^^^^^^
5 │
ℹ It is not necessary to use Boolean
call when a value will already be coerced to a boolean.
ℹ Unsafe fix: Remove redundant Boolean
call
4 │ }·while·(Boolean(x));
│ -------- -
code-block.js:1:8 lint/complexity/noExtraBooleanCast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Avoid redundant double-negation.
> 1 │ for (; !!foo; ) {}
│ ^^^^^
2 │
ℹ It is not necessary to use double-negation when a value will already be coerced to a boolean.
ℹ Unsafe fix: Remove redundant double-negation
1 │ for·(;·!!foo;·)·{}
│ --
code-block.js:1:13 lint/complexity/noExtraBooleanCast FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Avoid redundant double-negation.
> 1 │ new Boolean(!!x);
│ ^^^
2 │
ℹ It is not necessary to use double-negation when a value will already be coerced to a boolean.
ℹ Unsafe fix: Remove redundant double-negation
1 │ new·Boolean(!!x);
│ --