Boolean(slug)
instead 56 select: (serviceInfoResult) => serviceInfoResult.length !== 0,
57 }
58 )
59 const { data: alertData } = api.organization.getAlerts.useQuery({ slug }, { enabled: !!slug }) 60 const hasAlerts = Array.isArray(alertData) && alertData.length > 0
61 const { ref, width } = useElementSize()
62 const { searchState } = useSearchState()
Boolean(data?.id)
instead 52 const { data: hasRemote } = api.service.forServiceInfoCard.useQuery(
53 { parentId: data?.id ?? '', remoteOnly: true },
54 {
55 enabled: !!data?.id && data?.locations?.length > 1, 56 select: (serviceInfoResult) => serviceInfoResult.length !== 0,
57 }
58 )
Boolean(attrCat)
instead182
183 const inputContainerWithSkeleton = useCallback(
184 (children: ReactNode) => (
185 <Skeleton visible={!!attrCat && attributesByCategoryApi.isLoading} radius='md'>186 {children}
187 </Skeleton>
188 ),
Boolean(id)
instead 66 const { data: initialData, isFetching } = api.orgEmail.forEditDrawer.useQuery(
67 { id: emailId },
68 {
69 enabled: !!orgId && (!!id || !createNew), 70 select: (data) => (data ? { ...data, orgId: orgId ?? '' } : data),
71 }
72 )
Boolean(orgId)
instead 66 const { data: initialData, isFetching } = api.orgEmail.forEditDrawer.useQuery(
67 { id: emailId },
68 {
69 enabled: !!orgId && (!!id || !createNew), 70 select: (data) => (data ? { ...data, orgId: orgId ?? '' } : data),
71 }
72 )
Prefer using explicit casts by calling Number
, Boolean
, or String
over using operators like +
, !!
or "" +
.
This is considered best practice as it improves readability.
const b = !!foo;
// The `+` operator does not change the value of its operand
// unless it's already a number.
let n = +foo;
n = 1 * foo;
const s = "" + foo;
const b = Boolean(foo);
const n = Number(foo);
const s = String(foo);