Boolean return can be simplified
448 * @memberof ComponentAPI
449 */
450 static isCustomType(threeduftypeString: string): boolean {
451 if (threeduftypeString in ComponentAPI.customTypes.keys()) {452 return true;453 }454 return false;
455 }
456
Boolean return can be simplified
254 * @memberof Feature
255 */
256 hasDefaultParam(key: string): boolean {
257 if (this.getDefaults().hasOwnProperty(key)) return true;258 else return false;259 }
260
261 /**
Description
The following pattern:
if (condition) {
return true
}
return false
can be refactored to:
return condition
When condition
is not a boolean value,
it can be cast into one using the Boolean
constructor.
Bad Practice
function isEven(num: number) {
if (num % 2 === 0) return true
return false
}
async function userExists(name: string) {
if (await db.getUser(name)) return true
return false
}
Recommended
function isEven(num: number) {
return num % 2 === 0
}
async function userExists(name: string) {
return Boolean(await db.getUser(name))
}