Consider to disallow extra boolean casts |
In contexts such as an if statement's test where the result of the expression will already be coerced to a Boolean, casting to a Boolean via double negation (!!) is unnecessary.
CheckId | SPC018905 |
---|---|
TypeName | NoExtraBooleanCasts |
Severity | Warning |
Type | JavaScriptFile |
Bad Practice
if(!!foo) {
return false;
}
return false;
}
Good Practice
if(foo) {
return true;
}
if(!foo) {
return false;
}
return true;
}
if(!foo) {
return false;
}
Disclaimer: The views and opinions expressed in this documentation and in SPCAF do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. SPCAF and RENCORE are registered trademarks of Rencore. All other trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners.