diff --git a/apps/landing/src/lib/api.ts b/apps/landing/src/lib/api.ts index cc43534a2..ac0e4bb45 100644 --- a/apps/landing/src/lib/api.ts +++ b/apps/landing/src/lib/api.ts @@ -1,6 +1,6 @@ -import fs from "fs"; +import fs from "node:fs"; import matter from "gray-matter"; -import { join } from "path"; +import { join } from "node:path"; const postsDirectory = join(process.cwd(), "src", "posts"); diff --git a/apps/web/next-i18next.config.js b/apps/web/next-i18next.config.js index 8423aef44..46c9b0c51 100644 --- a/apps/web/next-i18next.config.js +++ b/apps/web/next-i18next.config.js @@ -1,5 +1,5 @@ const ICU = require("i18next-icu/i18nextICU.js"); -const path = require("path"); +const path = require("node:path"); const i18n = require("./i18n.config.js"); module.exports = { diff --git a/apps/web/src/app/[locale]/(admin)/events/event-list.tsx b/apps/web/src/app/[locale]/(admin)/events/event-list.tsx index f6f8a6fc5..0a7a35382 100644 --- a/apps/web/src/app/[locale]/(admin)/events/event-list.tsx +++ b/apps/web/src/app/[locale]/(admin)/events/event-list.tsx @@ -55,7 +55,7 @@ export function EventList({ data }: { data: ScheduledEvent[] }) { style={{ background: generateGradient(row.original.id), }} - > + />

{row.original.title}

diff --git a/apps/web/src/components/forms/poll-options-form/month-calendar/month-calendar.tsx b/apps/web/src/components/forms/poll-options-form/month-calendar/month-calendar.tsx index 35e876f93..166a3b104 100644 --- a/apps/web/src/components/forms/poll-options-form/month-calendar/month-calendar.tsx +++ b/apps/web/src/components/forms/poll-options-form/month-calendar/month-calendar.tsx @@ -81,7 +81,7 @@ const MonthCalendar: React.FunctionComponent = ({ const datepickerSelection = React.useMemo(() => { return Object.keys(optionsByDay).map( - (dateString) => new Date(dateString + "T12:00:00"), + (dateString) => new Date(`${dateString}T12:00:00`), ); }, [optionsByDay]); @@ -192,7 +192,7 @@ const MonthCalendar: React.FunctionComponent = ({ ? "border-primary-300 group-hover:border-primary-400 border-dashed shadow-sm" : "border-dashed border-transparent group-hover:border-gray-400 group-active:bg-gray-200", )} - > + /> {day.day} @@ -272,7 +272,7 @@ const MonthCalendar: React.FunctionComponent = ({ className="space-y-3 p-3 sm:flex sm:items-start sm:space-x-4 sm:space-y-0 sm:p-4" >
{optionsForDay.map(({ option, index }) => { diff --git a/apps/web/src/components/poll/desktop-poll/participant-row.tsx b/apps/web/src/components/poll/desktop-poll/participant-row.tsx index 161f85a56..53de6f559 100644 --- a/apps/web/src/components/poll/desktop-poll/participant-row.tsx +++ b/apps/web/src/components/poll/desktop-poll/participant-row.tsx @@ -95,7 +95,7 @@ export const ParticipantRowView: React.FunctionComponent<{ ); })} - + ); }; @@ -109,7 +109,7 @@ const ParticipantRow: React.FunctionComponent = ({ const { user, ownsObject } = useUser(); const { getVote, optionIds } = usePoll(); - const isYou = user && ownsObject(participant) ? true : false; + const isYou = !!(user && ownsObject(participant) ); const { canEditParticipant } = usePermissions(); const canEdit = canEditParticipant(participant.id); diff --git a/apps/web/src/components/poll/desktop-poll/poll-header.tsx b/apps/web/src/components/poll/desktop-poll/poll-header.tsx index 46adaabf2..f7240f936 100644 --- a/apps/web/src/components/poll/desktop-poll/poll-header.tsx +++ b/apps/web/src/components/poll/desktop-poll/poll-header.tsx @@ -50,9 +50,9 @@ const TimelineRow = ({ + /> {children} - + ); }; diff --git a/apps/web/src/components/poll/manage-poll.tsx b/apps/web/src/components/poll/manage-poll.tsx index 56fe19505..280390dd6 100644 --- a/apps/web/src/components/poll/manage-poll.tsx +++ b/apps/web/src/components/poll/manage-poll.tsx @@ -93,7 +93,7 @@ function PauseResumeToggle() { ); - } else { + } return ( { @@ -119,7 +119,6 @@ function PauseResumeToggle() { ); - } } const ManagePoll: React.FunctionComponent<{ @@ -189,8 +188,7 @@ const ManagePoll: React.FunctionComponent<{ - <> - {poll.status === "finalized" ? ( + {poll.status === "finalized" ? ( { reopen.mutate({ pollId: poll.id }); @@ -227,7 +225,6 @@ const ManagePoll: React.FunctionComponent<{ )} - diff --git a/apps/web/src/components/poll/truncated-linkify.tsx b/apps/web/src/components/poll/truncated-linkify.tsx index 6efa8b3a7..c77ba3ecc 100644 --- a/apps/web/src/components/poll/truncated-linkify.tsx +++ b/apps/web/src/components/poll/truncated-linkify.tsx @@ -23,7 +23,7 @@ export const truncateLink = (href: string, text: string, key: number) => { {finalText} ); - } else { + } finalText += "…"; return ( @@ -42,7 +42,6 @@ export const truncateLink = (href: string, text: string, key: number) => { ); - } }; const TruncatedLinkify = ({ children }: { children: React.ReactNode }) => { diff --git a/apps/web/src/components/register-link.tsx b/apps/web/src/components/register-link.tsx index 9aa1db4eb..e8daad45b 100644 --- a/apps/web/src/components/register-link.tsx +++ b/apps/web/src/components/register-link.tsx @@ -16,7 +16,7 @@ export const RegisterLink = React.forwardRef< onClick={async (e) => { e.preventDefault(); props.onClick?.(e); - router.push("/register?callbackUrl=" + encodeURIComponent(pathname)); + router.push(`/register?callbackUrl=${encodeURIComponent(pathname)}`); }} > {children} diff --git a/apps/web/src/components/vote-summary-progress-bar.tsx b/apps/web/src/components/vote-summary-progress-bar.tsx index 1ed6a12d6..942185eb9 100644 --- a/apps/web/src/components/vote-summary-progress-bar.tsx +++ b/apps/web/src/components/vote-summary-progress-bar.tsx @@ -33,7 +33,7 @@ export const VoteSummaryProgressBar = (props: {
@@ -46,7 +46,7 @@ export const VoteSummaryProgressBar = (props: {
@@ -59,7 +59,7 @@ export const VoteSummaryProgressBar = (props: {
diff --git a/apps/web/src/contexts/posthog.tsx b/apps/web/src/contexts/posthog.tsx index 7a9fbaf1e..f0f42c391 100644 --- a/apps/web/src/contexts/posthog.tsx +++ b/apps/web/src/contexts/posthog.tsx @@ -34,7 +34,7 @@ function usePostHogPageView() { if (pathname && posthog) { let url = window.origin + pathname; if (searchParams?.toString()) { - url = url + `?${searchParams.toString()}`; + url = `${url}?${searchParams.toString()}`; } if (previousUrl.current !== url) { posthog.capture("$pageview", { diff --git a/apps/web/src/pages/[locale]/auth/disable-notifications.tsx b/apps/web/src/pages/[locale]/auth/disable-notifications.tsx index 571213817..24fcfaeec 100644 --- a/apps/web/src/pages/[locale]/auth/disable-notifications.tsx +++ b/apps/web/src/pages/[locale]/auth/disable-notifications.tsx @@ -20,7 +20,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { props: {}, redirect: { destination: - "/login?callbackUrl=" + encodeURIComponent(ctx.req.url ?? "/"), + `/login?callbackUrl=${encodeURIComponent(ctx.req.url ?? "/")}`, }, }; } diff --git a/apps/web/src/pages/_document.tsx b/apps/web/src/pages/_document.tsx index 98e16e854..ff2ee355a 100644 --- a/apps/web/src/pages/_document.tsx +++ b/apps/web/src/pages/_document.tsx @@ -103,7 +103,7 @@ export default function Document() {
-
+
); diff --git a/apps/web/src/pages/api/paddle.ts b/apps/web/src/pages/api/paddle.ts index 43f82378b..5b63d6f59 100644 --- a/apps/web/src/pages/api/paddle.ts +++ b/apps/web/src/pages/api/paddle.ts @@ -1,6 +1,6 @@ // Original source: https://gist.github.com/dsumer/3594cda57e84a93a9019cddc71831882 import { prisma } from "@rallly/database"; -import crypto from "crypto"; +import crypto from "node:crypto"; import type { NextApiRequest, NextApiResponse } from "next"; import * as Serialize from "php-serialize"; @@ -50,7 +50,7 @@ export function validateWebhook(req: NextApiRequest) { // Grab p_signature const mySig = Buffer.from(jsonObj.p_signature, "base64"); // Remove p_signature from object - not included in array of fields used in verification. - delete jsonObj.p_signature; + jsonObj.p_signature = undefined; // Need to sort array by key in ascending order jsonObj = ksort(jsonObj); for (const property in jsonObj) { @@ -113,7 +113,7 @@ export default async function handler( passthrough = JSON.parse(payload.passthrough) as PaddlePassthrough; } catch {} if (!passthrough) { - res.status(400).send("Invalid passthrough: " + payload.passthrough); + res.status(400).send(`Invalid passthrough: ${payload.passthrough}`); return; } @@ -204,6 +204,5 @@ export default async function handler( // If everything went well, send a 200 OK return res.status(200).json({ success: true }); - } else { } } diff --git a/apps/web/src/trpc/routers/polls.ts b/apps/web/src/trpc/routers/polls.ts index 7cd8bb78e..364a45f2f 100644 --- a/apps/web/src/trpc/routers/polls.ts +++ b/apps/web/src/trpc/routers/polls.ts @@ -142,7 +142,7 @@ export const polls = router({ let nextCursor: typeof cursor | undefined = undefined; if (polls.length > input.limit) { const nextItem = polls.pop(); - nextCursor = nextItem!.id; + nextCursor = nextItem?.id; } return { polls, @@ -304,12 +304,11 @@ export const polls = router({ duration: dayjs(end).diff(dayjs(start), "minute"), pollId, }; - } else { - return { - startTime: dayjs(start).utc(true).toDate(), - pollId, - }; } + return { + startTime: dayjs(start).utc(true).toDate(), + pollId, + }; }), }); } @@ -513,9 +512,8 @@ export const polls = router({ if (ctx.user.id === res.userId || res.adminUrlId === input.adminToken) { return { ...res, inviteLink }; - } else { - return { ...res, adminUrlId: "", inviteLink }; } + return { ...res, adminUrlId: "", inviteLink }; }), transfer: possiblyPublicProcedure .input( @@ -876,104 +874,104 @@ export const polls = router({ code: "INTERNAL_SERVER_ERROR", message: "Failed to generate ics", }); - } else { - const timeZoneAbbrev = poll.timeZone - ? getTimeZoneAbbreviation(eventStart.toDate(), poll.timeZone) - : ""; - const date = eventStart.format("dddd, MMMM D, YYYY"); - const day = eventStart.format("D"); - const dow = eventStart.format("ddd"); - const startTime = eventStart.format("hh:mm A"); - const endTime = eventEnd.format("hh:mm A"); - - const time = - option.duration > 0 - ? `${startTime} - ${endTime} ${timeZoneAbbrev}` - : "All-day"; - - const participantsToEmail: Array<{ - name: string; - email: string; - locale: string | undefined; - }> = []; - - if (input.notify === "all") { - poll.participants.forEach((p) => { - if (p.email) { - participantsToEmail.push({ - name: p.name, - email: p.email, - locale: p.locale ?? undefined, - }); - } - }); - } - - if (input.notify === "attendees") { - attendees.forEach((p) => { - if (p.email) { - participantsToEmail.push({ - name: p.name, - email: p.email, - locale: p.locale ?? undefined, - }); - } - }); - } - - ctx.user.getEmailClient().queueTemplate("FinalizeHostEmail", { - to: poll.user.email, - props: { - name: poll.user.name, - pollUrl: absoluteUrl(`/poll/${poll.id}`), - location: poll.location, - title: poll.title, - attendees: poll.participants - .filter((p) => - p.votes.some( - (v) => v.optionId === input.optionId && v.type !== "no", - ), - ) - .map((p) => p.name), - date, - day, - dow, - time, - }, - attachments: [{ filename: "event.ics", content: event.value }], - }); - - for (const p of participantsToEmail) { - getEmailClient(p.locale ?? undefined).queueTemplate( - "FinalizeParticipantEmail", - { - to: p.email, - props: { - pollUrl: absoluteUrl(`/invite/${poll.id}`), - title: poll.title, - hostName: poll.user?.name ?? "", - date, - day, - dow, - time, - }, - attachments: [{ filename: "event.ics", content: event.value }], - }, - ); - } - - posthog?.capture({ - distinctId: ctx.user.id, - event: "finalize poll", - properties: { - poll_id: poll.id, - poll_time_zone: poll.timeZone, - number_of_participants: poll.participants.length, - number_of_attendees: attendees.length, - days_since_created: dayjs().diff(poll.createdAt, "day"), - }, - }); } + + const timeZoneAbbrev = poll.timeZone + ? getTimeZoneAbbreviation(eventStart.toDate(), poll.timeZone) + : ""; + const date = eventStart.format("dddd, MMMM D, YYYY"); + const day = eventStart.format("D"); + const dow = eventStart.format("ddd"); + const startTime = eventStart.format("hh:mm A"); + const endTime = eventEnd.format("hh:mm A"); + + const time = + option.duration > 0 + ? `${startTime} - ${endTime} ${timeZoneAbbrev}` + : "All-day"; + + const participantsToEmail: Array<{ + name: string; + email: string; + locale: string | undefined; + }> = []; + + // if (input.notify === "all") { + // poll.participants.forEach((p) => { + // if (p.email) { + // participantsToEmail.push({ + // name: p.name, + // email: p.email, + // locale: p.locale ?? undefined, + // }); + // } + // }); + // } + + // if (input.notify === "attendees") { + // attendees.forEach((p) => { + // if (p.email) { + // participantsToEmail.push({ + // name: p.name, + // email: p.email, + // locale: p.locale ?? undefined, + // }); + // } + // }); + // } + + ctx.user.getEmailClient().queueTemplate("FinalizeHostEmail", { + to: poll.user.email, + props: { + name: poll.user.name, + pollUrl: absoluteUrl(`/poll/${poll.id}`), + location: poll.location, + title: poll.title, + attendees: poll.participants + .filter((p) => + p.votes.some( + (v) => v.optionId === input.optionId && v.type !== "no", + ), + ) + .map((p) => p.name), + date, + day, + dow, + time, + }, + attachments: [{ filename: "event.ics", content: event.value }], + }); + + for (const p of participantsToEmail) { + getEmailClient(p.locale ?? undefined).queueTemplate( + "FinalizeParticipantEmail", + { + to: p.email, + props: { + pollUrl: absoluteUrl(`/invite/${poll.id}`), + title: poll.title, + hostName: poll.user?.name ?? "", + date, + day, + dow, + time, + }, + attachments: [{ filename: "event.ics", content: event.value }], + }, + ); + } + + posthog?.capture({ + distinctId: ctx.user.id, + event: "finalize poll", + properties: { + poll_id: poll.id, + poll_time_zone: poll.timeZone, + number_of_participants: poll.participants.length, + number_of_attendees: attendees.length, + days_since_created: dayjs().diff(poll.createdAt, "day"), + }, + }); }), reopen: possiblyPublicProcedure .input( diff --git a/apps/web/src/utils/absolute-url.ts b/apps/web/src/utils/absolute-url.ts index 734e2b928..df99cd578 100644 --- a/apps/web/src/utils/absolute-url.ts +++ b/apps/web/src/utils/absolute-url.ts @@ -21,7 +21,7 @@ export function objectToQueryString(obj: Record) { if (obj.hasOwnProperty(key)) { const value = obj[key]; if (value !== undefined) { - parts.push(encodeURIComponent(key) + "=" + encodeURIComponent(value)); + parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`); } } } diff --git a/apps/web/src/utils/color-hash.ts b/apps/web/src/utils/color-hash.ts index e096cafcb..d636f81b1 100644 --- a/apps/web/src/utils/color-hash.ts +++ b/apps/web/src/utils/color-hash.ts @@ -26,7 +26,7 @@ const avatarBackgroundColors: RGBColor[] = [ function isBright(color: RGBColor): boolean { const [r, g, b] = color; const L = (0.2126 * r) / 255 + (0.7152 * g) / 255 + (0.0722 * b) / 255; - return L > 0.6 ? true : false; + return L > 0.6; } export const getRandomAvatarColor = (str: string) => { diff --git a/apps/web/src/utils/dayjs.tsx b/apps/web/src/utils/dayjs.tsx index 57de8084f..fa7e09625 100644 --- a/apps/web/src/utils/dayjs.tsx +++ b/apps/web/src/utils/dayjs.tsx @@ -224,9 +224,8 @@ export const DayjsProvider: React.FunctionComponent<{ (date: dayjs.ConfigType, localTime = false) => { if (!localTime) { return dayjs(date).tz(preferredTimeZone); - } else { - return dayjs(date).utc(); } + return dayjs(date).utc(); }, [preferredTimeZone], ); diff --git a/apps/web/vitest.config.mts b/apps/web/vitest.config.mts index 8ae27b7e9..55e9cafc7 100644 --- a/apps/web/vitest.config.mts +++ b/apps/web/vitest.config.mts @@ -1,4 +1,4 @@ -import path from "path"; +import path from "node:path"; import { defineConfig } from "vitest/config"; export default defineConfig({ diff --git a/packages/billing/src/scripts/normalize-subscription-metadata.ts b/packages/billing/src/scripts/normalize-subscription-metadata.ts index 8067421c7..20014196e 100644 --- a/packages/billing/src/scripts/normalize-subscription-metadata.ts +++ b/packages/billing/src/scripts/normalize-subscription-metadata.ts @@ -25,9 +25,8 @@ async function getSubscriptionsWithMissingMetadata( subscriptions.data[subscriptions.data.length - 1].id, )), ]; - } else { - return res; } + return res; } async function normalizeSubscriptionMetadata() {