diff --git a/apps/api/src/routes/v1_identities_getIdentity.ts b/apps/api/src/routes/v1_identities_getIdentity.ts index f47b02b719..2e6904d6be 100644 --- a/apps/api/src/routes/v1_identities_getIdentity.ts +++ b/apps/api/src/routes/v1_identities_getIdentity.ts @@ -80,7 +80,7 @@ export const registerV1IdentitiesGetIdentity = (app: App) => const { identityId, externalId } = c.req.valid("query"); const { db } = c.get("services"); - if (!identityId && !externalId) { + if (!(identityId || externalId)) { throw new UnkeyApiError({ code: "BAD_REQUEST", message: "Provide either identityId or externalId", diff --git a/apps/api/src/routes/v1_identities_updateIdentity.ts b/apps/api/src/routes/v1_identities_updateIdentity.ts index fbe9ab4c08..1db17f4d04 100644 --- a/apps/api/src/routes/v1_identities_updateIdentity.ts +++ b/apps/api/src/routes/v1_identities_updateIdentity.ts @@ -140,7 +140,7 @@ export const registerV1IdentitiesUpdateIdentity = (app: App) => const { db, cache } = c.get("services"); - if (!req.identityId && !req.externalId) { + if (!(req.identityId || req.externalId)) { throw new UnkeyApiError({ code: "BAD_REQUEST", message: "Provide either identityId or externalId", @@ -234,14 +234,14 @@ export const registerV1IdentitiesUpdateIdentity = (app: App) => const updateRatelimits: Ratelimit[] = []; for (const rl of identity.ratelimits) { const newRl = req.ratelimits.find((r) => r.name === rl.name); - if (!newRl) { - deleteRatelimits.push(rl); - } else { + if (newRl) { updateRatelimits.push({ ...rl, limit: newRl.limit, duration: newRl.duration, }); + } else { + deleteRatelimits.push(rl); } } for (const newRl of req.ratelimits) { diff --git a/apps/api/src/routes/v1_keys_getVerifications.ts b/apps/api/src/routes/v1_keys_getVerifications.ts index 9ede996662..6f0237af0e 100644 --- a/apps/api/src/routes/v1_keys_getVerifications.ts +++ b/apps/api/src/routes/v1_keys_getVerifications.ts @@ -303,7 +303,7 @@ export const registerV1KeysGetVerifications = (app: App) => function transformData( data: VerificationTimeseriesDataPoint[] | undefined, ): CacheNamespaces["verificationsByKeyId"] { - if (!data || !data.length) { + if (!data?.length) { return []; } diff --git a/apps/api/src/routes/v1_migrations_createKey.ts b/apps/api/src/routes/v1_migrations_createKey.ts index 44de7e65b0..5e22379e2b 100644 --- a/apps/api/src/routes/v1_migrations_createKey.ts +++ b/apps/api/src/routes/v1_migrations_createKey.ts @@ -402,7 +402,7 @@ export const registerV1MigrationsCreateKeys = (app: App) => }); } - if (!key.hash && !key.plaintext) { + if (!(key.hash || key.plaintext)) { throw new UnkeyApiError({ code: "BAD_REQUEST", message: "provide either `hash` or `plaintext`", diff --git a/apps/api/src/routes/v1_ratelimits_deleteOverride.ts b/apps/api/src/routes/v1_ratelimits_deleteOverride.ts index 386216997e..cbe563a72f 100644 --- a/apps/api/src/routes/v1_ratelimits_deleteOverride.ts +++ b/apps/api/src/routes/v1_ratelimits_deleteOverride.ts @@ -66,7 +66,7 @@ export const registerV1RatelimitDeleteOverride = (app: App) => c, buildUnkeyQuery(({ or }) => or("*", "ratelimit.*.delete_override")), ); - if (!namespaceId && !namespaceName) { + if (!(namespaceId || namespaceName)) { throw new UnkeyApiError({ code: "BAD_REQUEST", message: "You must provide a namespaceId or a namespaceName", diff --git a/apps/api/src/routes/v1_ratelimits_getOverride.ts b/apps/api/src/routes/v1_ratelimits_getOverride.ts index a3f3151da4..054d0a5a8d 100644 --- a/apps/api/src/routes/v1_ratelimits_getOverride.ts +++ b/apps/api/src/routes/v1_ratelimits_getOverride.ts @@ -72,7 +72,7 @@ export const registerV1RatelimitGetOverride = (app: App) => message: "Missing required permission: ratelimit.*.read_override", }); } - if (!namespaceId && !namespaceName) { + if (!(namespaceId || namespaceName)) { throw new UnkeyApiError({ code: "BAD_REQUEST", message: "You must provide a namespaceId or a namespaceName", diff --git a/apps/api/src/routes/v1_ratelimits_listOverrides.ts b/apps/api/src/routes/v1_ratelimits_listOverrides.ts index baa3afcdfc..36be0ab516 100644 --- a/apps/api/src/routes/v1_ratelimits_listOverrides.ts +++ b/apps/api/src/routes/v1_ratelimits_listOverrides.ts @@ -74,7 +74,7 @@ export const registerV1RatelimitListOverrides = (app: App) => app.openapi(route, async (c) => { const { namespaceId, namespaceName, limit, cursor } = c.req.valid("query"); const { db } = c.get("services"); - if (!namespaceId && !namespaceName) { + if (!(namespaceId || namespaceName)) { throw new UnkeyApiError({ code: "BAD_REQUEST", message: "You must provide a namespaceId or a namespaceName", diff --git a/apps/api/src/routes/v1_ratelimits_setOverride.ts b/apps/api/src/routes/v1_ratelimits_setOverride.ts index 1073d31087..0b58fc523c 100644 --- a/apps/api/src/routes/v1_ratelimits_setOverride.ts +++ b/apps/api/src/routes/v1_ratelimits_setOverride.ts @@ -81,7 +81,7 @@ export type V1RatelimitSetOverrideResponse = z.infer< export const registerV1RatelimitSetOverride = (app: App) => app.openapi(route, async (c) => { const req = c.req.valid("json"); - if (!req.namespaceId && !req.namespaceName) { + if (!(req.namespaceId || req.namespaceName)) { throw new UnkeyApiError({ code: "BAD_REQUEST", message: "You must provide a namespaceId or a namespaceName", diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/expiration-setup.tsx b/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/expiration-setup.tsx index fb79d6ddba..dfdfc5b190 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/expiration-setup.tsx +++ b/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/expiration-setup.tsx @@ -123,8 +123,7 @@ export const ExpirationSetup = () => { // Calculate date for showing warning about close expiry (less than 1 hour) const isExpiringVerySoon = - currentExpiryDate && - new Date(currentExpiryDate).getTime() - new Date().getTime() < 60 * 60 * 1000; + currentExpiryDate && new Date(currentExpiryDate).getTime() - Date.now() < 60 * 60 * 1000; const getExpiryDescription = () => { if (isExpiringVerySoon) { diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/metadata-setup.tsx b/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/metadata-setup.tsx index 72ce2f2194..cac62562d5 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/metadata-setup.tsx +++ b/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/metadata-setup.tsx @@ -100,7 +100,7 @@ export const MetadataSetup = () => { rows={15} {...register("metadata.data", { validate: (value) => { - if (metadataEnabled && (!value || !validateJSON(value))) { + if (metadataEnabled && !(value && validateJSON(value))) { return "Must be valid JSON"; } return true; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.schema.ts b/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.schema.ts index 3dcf53cb0d..40af92373b 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.schema.ts +++ b/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.schema.ts @@ -209,7 +209,7 @@ export const expirationValidationSchema = z.object({ }) .refine( (date) => { - const minDate = new Date(new Date().getTime() + 2 * 60000); + const minDate = new Date(Date.now() + 2 * 60000); return date >= minDate; }, { diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.utils.ts b/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.utils.ts index 945cd2e729..dabbbd1667 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.utils.ts +++ b/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.utils.ts @@ -48,13 +48,13 @@ export const formValuesToApiInput = (formValues: FormValues, keyAuthId: string): export const isFeatureEnabled = (sectionId: SectionName, values: FormValues): boolean => { switch (sectionId) { case "metadata": - return values.metadata?.enabled || false; + return Boolean(values.metadata?.enabled); case "ratelimit": - return values.ratelimit?.enabled || false; + return Boolean(values.ratelimit?.enabled); case "credits": - return values.limit?.enabled || false; + return Boolean(values.limit?.enabled); case "expiration": - return values.expiration?.enabled || false; + return Boolean(values.expiration?.enabled); case "general": return true; default: diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/create-identity-options.tsx b/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/create-identity-options.tsx index 95303df934..66d88d73a8 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/create-identity-options.tsx +++ b/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/create-identity-options.tsx @@ -65,7 +65,19 @@ export function createIdentityOptions({ Metadata {/* Content - Different based on metadata presence */} - {!isMetaEmpty(identity.meta) ? ( + {isMetaEmpty(identity.meta) ? ( +
+
+
+
+
+                          No metadata available
+                        
+
+
+
+
+ ) : (
@@ -90,18 +102,6 @@ export function createIdentityOptions({
- ) : ( -
-
-
-
-
-                          No metadata available
-                        
-
-
-
-
)} diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/controls/components/logs-datetime/index.tsx b/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/controls/components/logs-datetime/index.tsx index 37028a61a8..b6fa7d847a 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/controls/components/logs-datetime/index.tsx +++ b/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/controls/components/logs-datetime/index.tsx @@ -67,9 +67,7 @@ export const LogsDateTime = () => { }} initialTitle={title ?? ""} onSuggestionChange={setTitle} - customOptions={DEFAULT_OPTIONS.filter( - (option) => !option.value || !option.value.endsWith("m"), - )} + customOptions={DEFAULT_OPTIONS.filter((option) => !option.value?.endsWith("m"))} >
diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls/components/batch-edit-external-id.tsx b/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls/components/batch-edit-external-id.tsx index 181f1b534e..1ad43e810e 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls/components/batch-edit-external-id.tsx +++ b/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls/components/batch-edit-external-id.tsx @@ -47,7 +47,7 @@ export const BatchEditExternalId = ({ return; } - if (!isConfirmPopoverOpen && !open) { + if (!(isConfirmPopoverOpen || open)) { onClose(); } }; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/hooks/use-keys-list-query.ts b/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/hooks/use-keys-list-query.ts index 964507d8ed..f6e69ff10b 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/hooks/use-keys-list-query.ts +++ b/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/hooks/use-keys-list-query.ts @@ -24,7 +24,7 @@ export function useKeysListQuery({ keyAuthId }: UseKeysListQueryParams) { }; filters.forEach((filter) => { - if (!keysListFilterFieldNames.includes(filter.field) || !params[filter.field]) { + if (!(keysListFilterFieldNames.includes(filter.field) && params[filter.field])) { return; } diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/keys-list.tsx b/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/keys-list.tsx index 939399687f..17f12ffcc9 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/keys-list.tsx +++ b/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/keys-list.tsx @@ -98,7 +98,7 @@ export const KeysList = ({ ) : ( <> {/* Show icon when not selected and not hovered */} - {!isSelected && !isHovered && ( + {!(isSelected || isHovered) && ( // biome-ignore lint/complexity/noUselessFragments: <> {identity ? ( @@ -279,7 +279,7 @@ export const KeysList = ({ } // Early exit if we already found a mix - if (!allEnabled && !allDisabled) { + if (!(allEnabled || allDisabled)) { break; } } diff --git a/apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-protection.tsx b/apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-protection.tsx index 43b0707618..124eb60d97 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-protection.tsx +++ b/apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-protection.tsx @@ -140,7 +140,7 @@ export const DeleteProtection: React.FC = ({ api }) => { : "Enable API Delete Protection"}
- This setting can be {!api.deleteProtection ? "disabled" : "re-enabled"} at any time + This setting can be {api.deleteProtection ? "re-enabled" : "disabled"} at any time
} @@ -148,9 +148,9 @@ export const DeleteProtection: React.FC = ({ api }) => {

Important: - {!api.deleteProtection - ? "Enabling this prevents the API from being deleted. This setting can be disabled at any time. " - : "Disabling this allows API deletion. This setting can be re-enabled at any time. "} + {api.deleteProtection + ? "Disabling this allows API deletion. This setting can be re-enabled at any time. " + : "Enabling this prevents the API from being deleted. This setting can be disabled at any time. "} { size="md" className={cn( "group-data-[state=open]:bg-gray-4 px-2 rounded-lg", - !title ? "opacity-50" : "", + title ? "" : "opacity-50", title !== "Last 12 hours" ? "bg-gray-4" : "", )} aria-label="Filter logs by time" diff --git a/apps/dashboard/app/(app)/audit/components/controls/components/logs-datetime/index.tsx b/apps/dashboard/app/(app)/audit/components/controls/components/logs-datetime/index.tsx index 30a679743e..ca034d3507 100644 --- a/apps/dashboard/app/(app)/audit/components/controls/components/logs-datetime/index.tsx +++ b/apps/dashboard/app/(app)/audit/components/controls/components/logs-datetime/index.tsx @@ -73,7 +73,7 @@ export const LogsDateTime = () => { size="md" className={cn( "group-data-[state=open]:bg-gray-4 px-2 rounded-lg", - !title ? "opacity-50" : "", + title ? "" : "opacity-50", title !== "Last 12 hours" ? "bg-gray-4" : "", )} aria-label="Filter logs by time" diff --git a/apps/dashboard/app/(app)/authorization/roles/[roleId]/page.tsx b/apps/dashboard/app/(app)/authorization/roles/[roleId]/page.tsx index 027cd7dc70..f13d032c4f 100644 --- a/apps/dashboard/app/(app)/authorization/roles/[roleId]/page.tsx +++ b/apps/dashboard/app/(app)/authorization/roles/[roleId]/page.tsx @@ -64,7 +64,7 @@ export default async function RolePage(props: Props) { }, }, }); - if (!role || !role.workspace) { + if (!role?.workspace) { return notFound(); } if (role.workspace.orgId !== orgId) { diff --git a/apps/dashboard/app/(app)/logs/components/controls/components/logs-datetime/index.tsx b/apps/dashboard/app/(app)/logs/components/controls/components/logs-datetime/index.tsx index 30a679743e..ca034d3507 100644 --- a/apps/dashboard/app/(app)/logs/components/controls/components/logs-datetime/index.tsx +++ b/apps/dashboard/app/(app)/logs/components/controls/components/logs-datetime/index.tsx @@ -73,7 +73,7 @@ export const LogsDateTime = () => { size="md" className={cn( "group-data-[state=open]:bg-gray-4 px-2 rounded-lg", - !title ? "opacity-50" : "", + title ? "" : "opacity-50", title !== "Last 12 hours" ? "bg-gray-4" : "", )} aria-label="Filter logs by time" diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/controls/components/logs-datetime/index.tsx b/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/controls/components/logs-datetime/index.tsx index 30a679743e..ca034d3507 100644 --- a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/controls/components/logs-datetime/index.tsx +++ b/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/controls/components/logs-datetime/index.tsx @@ -73,7 +73,7 @@ export const LogsDateTime = () => { size="md" className={cn( "group-data-[state=open]:bg-gray-4 px-2 rounded-lg", - !title ? "opacity-50" : "", + title ? "" : "opacity-50", title !== "Last 12 hours" ? "bg-gray-4" : "", )} aria-label="Filter logs by time" diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-datetime/index.tsx b/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-datetime/index.tsx index 30a679743e..ca034d3507 100644 --- a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-datetime/index.tsx +++ b/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-datetime/index.tsx @@ -73,7 +73,7 @@ export const LogsDateTime = () => { size="md" className={cn( "group-data-[state=open]:bg-gray-4 px-2 rounded-lg", - !title ? "opacity-50" : "", + title ? "" : "opacity-50", title !== "Last 12 hours" ? "bg-gray-4" : "", )} aria-label="Filter logs by time" diff --git a/apps/dashboard/app/(app)/ratelimits/_components/controls/components/logs-datetime/index.tsx b/apps/dashboard/app/(app)/ratelimits/_components/controls/components/logs-datetime/index.tsx index b65acc5e14..395df5462e 100644 --- a/apps/dashboard/app/(app)/ratelimits/_components/controls/components/logs-datetime/index.tsx +++ b/apps/dashboard/app/(app)/ratelimits/_components/controls/components/logs-datetime/index.tsx @@ -73,7 +73,7 @@ export const LogsDateTime = () => { size="md" className={cn( "group-data-[state=open]:bg-gray-4 px-2 rounded-lg", - !title ? "opacity-50" : "", + title ? "" : "opacity-50", title !== "Last 12 hours" ? "bg-gray-4" : "", )} aria-label="Filter logs by time" diff --git a/apps/dashboard/app/(app)/settings/billing/client.tsx b/apps/dashboard/app/(app)/settings/billing/client.tsx index 94ff98f3dc..6c52072096 100644 --- a/apps/dashboard/app/(app)/settings/billing/client.tsx +++ b/apps/dashboard/app/(app)/settings/billing/client.tsx @@ -77,8 +77,9 @@ export const Client: React.FC = (props) => { props.subscription && ["active", "trialing"].includes(props.subscription.status) && !props.subscription.cancelAt; - const isFreeTier = - !props.subscription || !["active", "trialing"].includes(props.subscription.status); + const isFreeTier = !( + props.subscription && ["active", "trialing"].includes(props.subscription.status) + ); const selectedProductIndex = allowUpdate ? props.products.findIndex((p) => p.id === props.currentProductId) : -1; diff --git a/apps/dashboard/app/(app)/settings/team/client.tsx b/apps/dashboard/app/(app)/settings/team/client.tsx index 5f573f16ba..237125878f 100644 --- a/apps/dashboard/app/(app)/settings/team/client.tsx +++ b/apps/dashboard/app/(app)/settings/team/client.tsx @@ -52,7 +52,7 @@ export default function TeamPageClient({ team }: { team: boolean }) { const [tab, setTab] = useState("members"); // make typescript happy - if (!user || !organization || !userMemberships || !currentOrgMembership) { + if (!(user && organization && userMemberships && currentOrgMembership)) { return null; } diff --git a/apps/dashboard/app/(app)/settings/team/invite.tsx b/apps/dashboard/app/(app)/settings/team/invite.tsx index 8691191bdc..a45f3a1cc9 100644 --- a/apps/dashboard/app/(app)/settings/team/invite.tsx +++ b/apps/dashboard/app/(app)/settings/team/invite.tsx @@ -59,7 +59,7 @@ export const InviteButton = ({ user, organization, ...rest }: InviteButtonProps) }); // If user or organization isn't available yet, return null or a loading state - if (!user!.orgId || !organization) { + if (!(user!.orgId && organization)) { return null; } diff --git a/apps/dashboard/app/auth/sign-up/email-signup.tsx b/apps/dashboard/app/auth/sign-up/email-signup.tsx index 82f918788e..dac6eaa884 100644 --- a/apps/dashboard/app/auth/sign-up/email-signup.tsx +++ b/apps/dashboard/app/auth/sign-up/email-signup.tsx @@ -111,10 +111,12 @@ export const EmailSignUp: React.FC = ({ setVerification }) => { className="flex items-center justify-center h-10 gap-2 px-4 mt-8 text-sm font-semibold text-black duration-200 bg-white border border-white rounded-lg hover:border-white/30 hover:bg-black hover:text-white" disabled={isLoading} > - {!clientLoaded ? ( - "Sign Up with Email" - ) : isLoading ? ( - + {clientLoaded ? ( + isLoading ? ( + + ) : ( + "Sign Up with Email" + ) ) : ( "Sign Up with Email" )} diff --git a/apps/dashboard/app/integrations/vercel/callback/client.tsx b/apps/dashboard/app/integrations/vercel/callback/client.tsx index 7490ed2c62..3ee3a5200d 100644 --- a/apps/dashboard/app/integrations/vercel/callback/client.tsx +++ b/apps/dashboard/app/integrations/vercel/callback/client.tsx @@ -47,8 +47,10 @@ export const Client: React.FC = ({ }); const router = useRouter(); - const disabled = - !projectId || !(selectedApis.development || selectedApis.preview || selectedApis.production); + const disabled = !( + projectId && + (selectedApis.development || selectedApis.preview || selectedApis.production) + ); const create = trpc.vercel.setupProject.useMutation({ onSuccess: () => { diff --git a/apps/dashboard/app/new/create-ratelimit.tsx b/apps/dashboard/app/new/create-ratelimit.tsx index 8efabeb551..3a088f1da6 100644 --- a/apps/dashboard/app/new/create-ratelimit.tsx +++ b/apps/dashboard/app/new/create-ratelimit.tsx @@ -15,7 +15,7 @@ export const CreateRatelimit: React.FC = async (props) => { const user = await getCurrentUser(); // make typescript happy - if (!user || !user.orgId || !user.role) { + if (!(user?.orgId && user.role)) { return null; } diff --git a/apps/dashboard/components/banner.tsx b/apps/dashboard/components/banner.tsx index 84ed0e539b..37360726cc 100644 --- a/apps/dashboard/components/banner.tsx +++ b/apps/dashboard/components/banner.tsx @@ -29,9 +29,9 @@ export const Banner: React.FC> = ({ const bannerHeightRef = useRef(0); const bannerRef = useRef(null); - const [visible, setVisible] = !persistChoice - ? useState(true) - : useLocalStorage(`unkey_banner_${persistChoice}`, true, { initializeWithValue: false }); + const [visible, setVisible] = persistChoice + ? useLocalStorage(`unkey_banner_${persistChoice}`, true, { initializeWithValue: false }) + : useState(true); useResizeObserver({ ref: bannerRef, diff --git a/apps/dashboard/components/logs/chart/index.tsx b/apps/dashboard/components/logs/chart/index.tsx index 1a3dd41133..96b3f9b7a3 100644 --- a/apps/dashboard/components/logs/chart/index.tsx +++ b/apps/dashboard/components/logs/chart/index.tsx @@ -94,7 +94,7 @@ export function LogsTimeseriesBarChart({ return; } if (selection.start && selection.end && onSelectionChange) { - if (!selection.startTimestamp || !selection.endTimestamp) { + if (!(selection.startTimestamp && selection.endTimestamp)) { return; } @@ -154,7 +154,7 @@ export function LogsTimeseriesBarChart({ strokeOpacity: 0.7, }} content={({ active, payload, label }) => { - if (!active || !payload?.length || payload?.[0]?.payload.total === 0) { + if (!(active && payload?.length) || payload?.[0]?.payload.total === 0) { return null; } diff --git a/apps/dashboard/components/logs/details/request-response-details.tsx b/apps/dashboard/components/logs/details/request-response-details.tsx index e29e039ed4..c6bfc32217 100644 --- a/apps/dashboard/components/logs/details/request-response-details.tsx +++ b/apps/dashboard/components/logs/details/request-response-details.tsx @@ -69,7 +69,7 @@ export const RequestResponseDetails = ({ fields, className "border-b", field.className, )} - onClick={!field.skipTooltip ? () => handleClick(field) : undefined} + onClick={field.skipTooltip ? undefined : () => handleClick(field)} > {field.label} diff --git a/apps/dashboard/components/logs/details/resizable-panel.tsx b/apps/dashboard/components/logs/details/resizable-panel.tsx index 9ff8a7b259..755c422a6f 100644 --- a/apps/dashboard/components/logs/details/resizable-panel.tsx +++ b/apps/dashboard/components/logs/details/resizable-panel.tsx @@ -38,7 +38,7 @@ export const ResizablePanel = ({ const handleMouseMove = useCallback( (e: MouseEvent) => { - if (!isDragging || !panelRef.current) { + if (!(isDragging && panelRef.current)) { return; } diff --git a/apps/dashboard/components/logs/hooks/use-bookmarked-filters.ts b/apps/dashboard/components/logs/hooks/use-bookmarked-filters.ts index f16792e30d..c3c5118c3a 100644 --- a/apps/dashboard/components/logs/hooks/use-bookmarked-filters.ts +++ b/apps/dashboard/components/logs/hooks/use-bookmarked-filters.ts @@ -31,7 +31,7 @@ export function useBookmarkedFilters({ }, [localStorageName]); useEffect(() => { - if (!filters.length || !isBrowser) { + if (!(filters.length && isBrowser)) { return; } diff --git a/apps/dashboard/components/logs/overview-charts/overview-area-chart.tsx b/apps/dashboard/components/logs/overview-charts/overview-area-chart.tsx index 15cef9361d..a8fcb0926d 100644 --- a/apps/dashboard/components/logs/overview-charts/overview-area-chart.tsx +++ b/apps/dashboard/components/logs/overview-charts/overview-area-chart.tsx @@ -79,7 +79,7 @@ export const OverviewAreaChart = ({ }; const handleMouseMove = (e: any) => { - if (!enableSelection || !selection.start) { + if (!(enableSelection && selection.start)) { return; } const timestamp = e?.activePayload?.[0]?.payload?.originalTimestamp; @@ -95,7 +95,7 @@ export const OverviewAreaChart = ({ return; } if (selection.start && selection.end && onSelectionChange) { - if (!selection.startTimestamp || !selection.endTimestamp) { + if (!(selection.startTimestamp && selection.endTimestamp)) { return; } const [start, end] = [selection.startTimestamp, selection.endTimestamp].sort((a, b) => a - b); @@ -230,7 +230,7 @@ export const OverviewAreaChart = ({ strokeOpacity: 0.7, }} content={({ active, payload, label }) => { - if (!active || !payload?.length) { + if (!(active && payload?.length)) { return null; } return ( diff --git a/apps/dashboard/components/logs/overview-charts/overview-bar-chart.tsx b/apps/dashboard/components/logs/overview-charts/overview-bar-chart.tsx index 7f1f3d8261..f0fde0039b 100644 --- a/apps/dashboard/components/logs/overview-charts/overview-bar-chart.tsx +++ b/apps/dashboard/components/logs/overview-charts/overview-bar-chart.tsx @@ -96,7 +96,7 @@ export function OverviewBarChart({ return; } if (selection.start && selection.end && onSelectionChange) { - if (!selection.startTimestamp || !selection.endTimestamp) { + if (!(selection.startTimestamp && selection.endTimestamp)) { return; } const [start, end] = [selection.startTimestamp, selection.endTimestamp].sort((a, b) => a - b); @@ -188,7 +188,7 @@ export function OverviewBarChart({ strokeOpacity: 0.7, }} content={({ active, payload, label }) => { - if (!active || !payload?.length || payload?.[0]?.payload.total === 0) { + if (!(active && payload?.length) || payload?.[0]?.payload.total === 0) { return null; } return ( diff --git a/apps/dashboard/components/logs/overview-charts/utils.tsx b/apps/dashboard/components/logs/overview-charts/utils.tsx index 6f7a43f8d8..201d52ff83 100644 --- a/apps/dashboard/components/logs/overview-charts/utils.tsx +++ b/apps/dashboard/components/logs/overview-charts/utils.tsx @@ -23,7 +23,7 @@ export function createTimeIntervalFormatter(data?: TimeseriesData[], timeFormat const formattedCurrentTimestamp = format(new Date(currentTimestamp), timeFormat); // If we don't have necessary data, fallback to displaying just the current point - if (!currentTimestamp || !data?.length) { + if (!(currentTimestamp && data?.length)) { return (

{formattedCurrentTimestamp} diff --git a/apps/dashboard/components/logs/queries/queries-popover.tsx b/apps/dashboard/components/logs/queries/queries-popover.tsx index 0f3d524e6e..7ad0167164 100644 --- a/apps/dashboard/components/logs/queries/queries-popover.tsx +++ b/apps/dashboard/components/logs/queries/queries-popover.tsx @@ -40,16 +40,16 @@ export function QueriesPopover { - if (!open && !isDisabled) { - setOpen(true); - setSelectedQueryIndex(0); - setFocusedTabIndex(0); - setIsDisabled(filters.length === 0); - } else { + if (open || isDisabled) { setIsDisabled(filters.length === 0); setOpen(false); setFocusedTabIndex(0); setSelectedQueryIndex(0); + } else { + setOpen(true); + setSelectedQueryIndex(0); + setFocusedTabIndex(0); + setIsDisabled(filters.length === 0); } }); diff --git a/apps/dashboard/components/logs/validation/utils/nuqs-parsers.ts b/apps/dashboard/components/logs/validation/utils/nuqs-parsers.ts index 95b3a928bb..2727cc75a7 100644 --- a/apps/dashboard/components/logs/validation/utils/nuqs-parsers.ts +++ b/apps/dashboard/components/logs/validation/utils/nuqs-parsers.ts @@ -74,7 +74,7 @@ export const parseAsSortArray = (): Parser< try { return str.split(",").map((item) => { const [column, direction] = item.split(":"); - if (!column || !direction) { + if (!(column && direction)) { throw new Error("Invalid sort format"); } if (!VALID_DIRECTIONS.includes(direction as SortDirection)) { diff --git a/apps/dashboard/components/navigation/copyable-id-button.tsx b/apps/dashboard/components/navigation/copyable-id-button.tsx index 7e5c6a90af..2ba96e6f96 100644 --- a/apps/dashboard/components/navigation/copyable-id-button.tsx +++ b/apps/dashboard/components/navigation/copyable-id-button.tsx @@ -45,12 +45,12 @@ export const CopyableIDButton = ({ value, className = "" }: CopyableIDButtonProp const handleClick = (e: React.MouseEvent) => { // Only handle click if it wasn't a long press - if (!window.getSelection()?.toString()) { - // Programmatically click the CopyButton if text isn't selected - copyButtonRef.current?.click(); - } else { + if (window.getSelection()?.toString()) { // If text is selected, don't trigger the copy e.stopPropagation(); + } else { + // Programmatically click the CopyButton if text isn't selected + copyButtonRef.current?.click(); } }; diff --git a/apps/dashboard/components/navigation/sidebar/app-sidebar/components/nav-items/nested-nav-item.tsx b/apps/dashboard/components/navigation/sidebar/app-sidebar/components/nav-items/nested-nav-item.tsx index b9b00d7fa1..7a01b7a5ce 100644 --- a/apps/dashboard/components/navigation/sidebar/app-sidebar/components/nav-items/nested-nav-item.tsx +++ b/apps/dashboard/components/navigation/sidebar/app-sidebar/components/nav-items/nested-nav-item.tsx @@ -43,7 +43,7 @@ export const NestedNavItem = ({ const hasChildren = item.items && item.items.length > 0; useLayoutEffect(() => { - if (!hasChildren || !pathname) { + if (!(hasChildren && pathname)) { return; } @@ -76,14 +76,14 @@ export const NestedNavItem = ({ // If the item has a href, navigate to it if (item.href) { - if (!item.external) { + if (item.external) { + // For external links, open in new tab + window.open(item.href, "_blank"); + } else { // Show loading state ONLY for parent startParentTransition(() => { router.push(item.href); }); - } else { - // For external links, open in new tab - window.open(item.href, "_blank"); } } }; diff --git a/apps/dashboard/components/navigation/sidebar/team-switcher.tsx b/apps/dashboard/components/navigation/sidebar/team-switcher.tsx index 45feb67b6a..c6037ebcc4 100644 --- a/apps/dashboard/components/navigation/sidebar/team-switcher.tsx +++ b/apps/dashboard/components/navigation/sidebar/team-switcher.tsx @@ -109,7 +109,7 @@ export const WorkspaceSwitcher: React.FC = (props): JSX.Element => { {isUserMembershipsLoading ? ( - ) : !isCollapsed ? ( + ) : isCollapsed ? null : ( @@ -120,7 +120,7 @@ export const WorkspaceSwitcher: React.FC = (props): JSX.Element => { {props.workspace.name} - ) : null} + )}
{!isCollapsed && ( diff --git a/apps/dashboard/components/stats-card/components/chart/stats-chart.tsx b/apps/dashboard/components/stats-card/components/chart/stats-chart.tsx index b32be9f4a5..7f531d2c78 100644 --- a/apps/dashboard/components/stats-card/components/chart/stats-chart.tsx +++ b/apps/dashboard/components/stats-card/components/chart/stats-chart.tsx @@ -67,7 +67,7 @@ export function StatsTimeseriesBarChart({ strokeOpacity: 0.7, }} content={({ active, payload, label }) => { - if (!active || !payload?.length || payload?.[0]?.payload.total === 0) { + if (!(active && payload?.length) || payload?.[0]?.payload.total === 0) { return null; } return ( diff --git a/apps/dashboard/components/ui/chart.tsx b/apps/dashboard/components/ui/chart.tsx index 88b573460c..c91ee2d38c 100644 --- a/apps/dashboard/components/ui/chart.tsx +++ b/apps/dashboard/components/ui/chart.tsx @@ -73,6 +73,7 @@ const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => { return (