no-extra-boolean-cast
eslint
Safe autofixRecommended
eslint.config.js
export default [
{
rules: {
"no-extra-boolean-cast": "error",
},
},
];const foo = !!!bar;
const foo1 = !!bar ? baz : bat;
const foo2 = Boolean(!!bar);
const foo3 = new Boolean(!!bar);
if (!!foo) {
// ...
}
if (Boolean(foo)) {
// ...
}
while (!!foo) {
// ...
}
do {
// ...
} while (Boolean(foo));
for (; !!foo; ) {
// ...
}const foo = !!bar;
const foo1 = Boolean(bar);
function qux() {
return !!bar;
}
foo = bar ? !!baz : !!bat;Examples from the ESLint documentation.
no-extra-boolean-cast
eslint
export default [
{
rules: {
"no-extra-boolean-cast": "error",
},
},
];no-extra-boolean-cast
eslint plugin · correctness
{
"rules": {
"no-extra-boolean-cast": "error"
}
}complexity/noExtraBooleanCast
complexity · since 1.0.0
{
"linter": {
"rules": {
"complexity": {
"noExtraBooleanCast": "error"
}
}
}
}Disallow this/super before calling super() in constructors
Disallow unreachable code after return, throw, continue, and break statements
Disallow irregular whitespace
Disallow calling global object properties as functions
Disallow negating the left operand of relational operators