85 }
86 }
87 const tagRemovable = (tag: PostTags): boolean => {
88 if (tag === 'working-on' || tag === 'done' || tag == 'under-review') { 89 return true 90 } 91 return false
92 }
93 const isImg = (fileUrl: string) => {
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.
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
}
function isEven(num: number) {
return num % 2 === 0
}
async function userExists(name: string) {
return Boolean(await db.getUser(name))
}