Skip to content

Commit ba04533

Browse files
emrysalPeerRichzomarskodiakhq[bot]
authored
Linting fixes round #1 (#2906)
* Fixes round #1 * disabled any warning for intentional typing of AsyncReturnType * Whacked MetaMask add / remove button * types, not great, not terrible, better than any * Fixed typo in CheckboxField and wrapped description in <label> * Feedback Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: zomars <zomars@me.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 547b409 commit ba04533

21 files changed

+87
-85
lines changed

apps/web/components/availability/Schedule.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ const useOptions = () => {
6262
const filter = useCallback(
6363
({ offset, limit, current }: { offset?: ConfigType; limit?: ConfigType; current?: ConfigType }) => {
6464
if (current) {
65-
setFilteredOptions([options.find((option) => option.value === dayjs(current).toDate().valueOf())!]);
65+
const currentOption = options.find((option) => option.value === dayjs(current).toDate().valueOf());
66+
if (currentOption) setFilteredOptions([currentOption]);
6667
} else
6768
setFilteredOptions(
6869
options.filter((option) => {

apps/web/components/pages/eventtypes/CustomInputTypeForm.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const CustomInputTypeForm: FC<Props> = (props) => {
3535
defaultValues,
3636
});
3737
const selectedInputType = useWatch({ name: "type", control });
38-
const selectedInputOption = inputOptions.find((e) => selectedInputType === e.value)!;
38+
const selectedInputOption = inputOptions.find((e) => selectedInputType === e.value);
3939

4040
const onCancel = () => {
4141
props.onCancel();

apps/web/components/team/MemberChangeRoleModal.tsx

+26-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { MembershipRole } from "@prisma/client";
2-
import { useState } from "react";
3-
import React, { SyntheticEvent, useEffect } from "react";
2+
import { SyntheticEvent, useMemo, useState } from "react";
43

54
import { useLocale } from "@calcom/lib/hooks/useLocale";
65
import Button from "@calcom/ui/Button";
@@ -11,12 +10,10 @@ import ModalContainer from "@components/ui/ModalContainer";
1110
import Select from "@components/ui/form/Select";
1211

1312
type MembershipRoleOption = {
13+
label: string;
1414
value: MembershipRole;
15-
label?: string;
1615
};
1716

18-
const options: MembershipRoleOption[] = [{ value: "MEMBER" }, { value: "ADMIN" }, { value: "OWNER" }];
19-
2017
export default function MemberChangeRoleModal(props: {
2118
isOpen: boolean;
2219
currentMember: MembershipRole;
@@ -25,18 +22,32 @@ export default function MemberChangeRoleModal(props: {
2522
initialRole: MembershipRole;
2623
onExit: () => void;
2724
}) {
28-
useEffect(() => {
29-
options.forEach((option, i) => {
30-
options[i].label = t(option.value.toLowerCase());
31-
});
32-
// eslint-disable-next-line react-hooks/exhaustive-deps
33-
}, []);
25+
const { t } = useLocale();
3426

35-
const [role, setRole] = useState(
36-
options.find((option) => option.value === props.initialRole || MembershipRole.MEMBER)!
27+
const options = useMemo(() => {
28+
return [
29+
{
30+
label: t("member"),
31+
value: MembershipRole.MEMBER,
32+
},
33+
{
34+
label: t("admin"),
35+
value: MembershipRole.ADMIN,
36+
},
37+
{
38+
label: t("owner"),
39+
value: MembershipRole.OWNER,
40+
},
41+
].filter(({ value }) => value !== MembershipRole.OWNER || props.currentMember === MembershipRole.OWNER);
42+
}, [t, props.currentMember]);
43+
44+
const [role, setRole] = useState<MembershipRoleOption>(
45+
options.find((option) => option.value === props.initialRole) || {
46+
label: t("member"),
47+
value: MembershipRole.MEMBER,
48+
}
3749
);
3850
const [errorMessage, setErrorMessage] = useState("");
39-
const { t } = useLocale();
4051
const utils = trpc.useContext();
4152

4253
const changeRoleMutation = trpc.useMutation("viewer.teams.changeMemberRole", {
@@ -76,7 +87,7 @@ export default function MemberChangeRoleModal(props: {
7687
{/*<option value="OWNER">{t("owner")}</option> - needs dialog to confirm change of ownership */}
7788
<Select
7889
isSearchable={false}
79-
options={props.currentMember !== MembershipRole.OWNER ? options.slice(0, 2) : options}
90+
options={options}
8091
value={role}
8192
onChange={(option) => option && setRole(option)}
8293
id="role"

apps/web/components/ui/ModalContainer.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import classNames from "classnames";
2-
import React from "react";
2+
import React, { PropsWithChildren } from "react";
33

44
import { Dialog, DialogContent } from "@calcom/ui/Dialog";
55

6-
interface Props extends React.PropsWithChildren<any> {
7-
wide?: boolean;
8-
scroll?: boolean;
9-
noPadding?: boolean;
10-
isOpen: boolean;
11-
onExit: () => void;
12-
}
13-
14-
export default function ModalContainer(props: Props) {
6+
export default function ModalContainer(
7+
props: PropsWithChildren<{
8+
wide?: boolean;
9+
scroll?: boolean;
10+
noPadding?: boolean;
11+
isOpen: boolean;
12+
onExit: () => void;
13+
}>
14+
) {
1515
return (
1616
<div className="flex min-h-screen items-end justify-center px-4 pt-4 pb-20 text-center sm:block sm:p-0">
1717
<Dialog open={props.isOpen} onOpenChange={props.onExit}>

apps/web/ee/lib/helpscout/HelpscoutMenuItem.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
import { ChatAltIcon } from "@heroicons/react/solid";
21
import { useState } from "react";
32
import { HelpScout, useChat } from "react-live-chat-loader";
43

54
import { useLocale } from "@calcom/lib/hooks/useLocale";
6-
import { DropdownMenuItem } from "@calcom/ui/Dropdown";
7-
8-
import classNames from "@lib/classNames";
95

106
export default function HelpscoutMenuItem() {
117
const { t } = useLocale();
128
const [active, setActive] = useState(false);
139

14-
const [state, loadChat] = useChat();
10+
const [, loadChat] = useChat();
1511

1612
function handleClick() {
1713
setActive(true);

apps/web/ee/lib/helpscout/provider.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { FC } from "react";
22
import { LiveChatLoaderProvider } from "react-live-chat-loader";
33

44
const Provider: FC<{ children: React.ReactNode }> = ({ children }) => (
5-
<LiveChatLoaderProvider providerKey={process.env.NEXT_PUBLIC_HELPSCOUT_KEY!} provider="helpScout">
5+
<LiveChatLoaderProvider providerKey={process.env.NEXT_PUBLIC_HELPSCOUT_KEY || ""} provider="helpScout">
66
<>{children}</>
77
</LiveChatLoaderProvider>
88
);

apps/web/ee/lib/intercom/IntercomMenuItem.tsx

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import { ChatAltIcon } from "@heroicons/react/solid";
2-
3-
import { DropdownMenuItem } from "@calcom/ui/Dropdown";
4-
5-
import classNames from "@lib/classNames";
6-
import { useLocale } from "@lib/hooks/useLocale";
1+
import { useLocale } from "@calcom/lib/hooks/useLocale";
72

83
import { useIntercom } from "./useIntercom";
94

apps/web/ee/lib/intercom/provider.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { FC } from "react";
22
import { IntercomProvider } from "react-use-intercom";
33

44
const Provider: FC<{ children: React.ReactNode }> = ({ children }) => (
5-
<IntercomProvider appId={process.env.NEXT_PUBLIC_INTERCOM_APP_ID!}>{children}</IntercomProvider>
5+
<IntercomProvider appId={process.env.NEXT_PUBLIC_INTERCOM_APP_ID || ""}>{children}</IntercomProvider>
66
);
77

88
export default Provider;

apps/web/ee/lib/zendesk/ZendeskMenuItem.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import { ChatAltIcon } from "@heroicons/react/solid";
21
import Script from "next/script";
32
import { useState } from "react";
43

54
import { useLocale } from "@calcom/lib/hooks/useLocale";
6-
import { DropdownMenuItem } from "@calcom/ui/Dropdown";
7-
8-
import classNames from "@lib/classNames";
95

106
const ZENDESK_KEY = process.env.NEXT_PUBLIC_ZENDESK_KEY;
117

apps/web/lib/hooks/useInViewObserver.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from "react";
33
const isInteractionObserverSupported = typeof window !== "undefined" && "IntersectionObserver" in window;
44

55
export const useInViewObserver = (onInViewCallback: () => void) => {
6-
const [node, setRef] = React.useState<any>(null);
6+
const [node, setRef] = React.useState<HTMLElement | null>(null);
77

88
const onInViewCallbackRef = React.useRef(onInViewCallback);
99
onInViewCallbackRef.current = onInViewCallback;

apps/web/lib/queries/teams/index.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ import { baseEventTypeSelect } from "@calcom/prisma";
44

55
import prisma from "@lib/prisma";
66

7-
type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (...args: any) => Promise<infer R>
8-
? R
9-
: any;
10-
11-
export type TeamWithMembers = AsyncReturnType<typeof getTeamWithMembers>;
7+
export type TeamWithMembers = Awaited<ReturnType<typeof getTeamWithMembers>>;
128

139
export async function getTeamWithMembers(id?: number, slug?: string) {
1410
const userSelect = Prisma.validator<Prisma.UserSelect>()({

apps/web/pages/api/import/calendly.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ import { getSession } from "@lib/auth";
55

66
const prisma = new PrismaClient();
77

8+
type CalendlyEventType = {
9+
name: string;
10+
slug: string;
11+
duration: number;
12+
description_plain: string;
13+
secret: boolean;
14+
};
15+
816
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
917
const session = await getSession({ req });
1018
const authenticatedUser = await prisma.user.findFirst({
@@ -50,7 +58,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
5058

5159
const eventTypesData = await eventTypesResult.json();
5260

53-
eventTypesData.collection.forEach(async (eventType: any) => {
61+
eventTypesData.collection.forEach(async (eventType: CalendlyEventType) => {
5462
await prisma.eventType.create({
5563
data: {
5664
title: eventType.name,

apps/web/pages/api/import/savvycal.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ import { getSession } from "@lib/auth";
55

66
const prisma = new PrismaClient();
77

8+
type SavvyCalEventType = {
9+
name: string;
10+
slug: string;
11+
durations: [number];
12+
description: string;
13+
state: "active";
14+
};
15+
816
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
917
const session = await getSession({ req });
1018
const authenticatedUser = await prisma.user.findFirst({
@@ -50,7 +58,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
5058

5159
const eventTypesData = await eventTypesResult.json();
5260

53-
eventTypesData.entries.forEach(async (eventType: any) => {
61+
eventTypesData.entries.forEach(async (eventType: SavvyCalEventType) => {
5462
await prisma.eventType.create({
5563
data: {
5664
title: eventType.name,

apps/web/pages/api/integrations.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getSession } from "@lib/auth";
55
import prisma from "@lib/prisma";
66

77
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
8-
if (!["GET", "DELETE"].includes(req.method!)) {
8+
if (!["GET", "DELETE"].includes(req.method || "")) {
99
return res.status(405).end();
1010
}
1111

apps/web/pages/api/upgrade.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
1313
return res.status(401).json({ message: "Not authenticated" });
1414
}
1515

16-
if (!["GET", "POST"].includes(req.method!)) {
16+
if (!["GET", "POST"].includes(req.method || "")) {
1717
throw new HttpCode({ statusCode: 405, message: "Method Not Allowed" });
1818
}
1919

apps/web/pages/apps/installed.tsx

+9-21
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { ArrowRightIcon, ViewGridIcon } from "@heroicons/react/solid";
22
import Image from "next/image";
3-
import React, { useEffect, useState } from "react";
4-
import { JSONObject } from "superjson/dist/types";
3+
import React from "react";
54

65
import { InstallAppButton } from "@calcom/app-store/components";
76
import { useLocale } from "@calcom/lib/hooks/useLocale";
@@ -186,17 +185,16 @@ function Web3Container() {
186185
function Web3ConnectBtn() {
187186
const { t } = useLocale();
188187
const utils = trpc.useContext();
189-
const [connectionBtn, setConnection] = useState(false);
190188
const result = trpc.useQuery(["viewer.web3Integration"]);
191189
const mutation = trpc.useMutation("viewer.enableOrDisableWeb3", {
192190
onSuccess: async (result) => {
193-
const { key = {} } = result as JSONObject;
194-
195-
if ((key as JSONObject).isWeb3Active) {
191+
const { key } = result;
192+
if ((key as { isWeb3Active: boolean }).isWeb3Active) {
196193
showToast(t("web3_metamask_added"), "success");
197194
} else {
198195
showToast(t("web3_metamask_disconnected"), "success");
199196
}
197+
utils.invalidateQueries("viewer.web3Integration");
200198
},
201199
onError: (err) => {
202200
if (err instanceof HttpError) {
@@ -206,26 +204,16 @@ function Web3ConnectBtn() {
206204
},
207205
});
208206

209-
useEffect(() => {
210-
if (result.data) {
211-
setConnection(result.data.isWeb3Active as boolean);
212-
}
213-
}, [result]);
214-
215-
const enableOrDisableWeb3 = async (mutation: any) => {
216-
const result = await mutation.mutateAsync({});
217-
setConnection(result.key.isWeb3Active);
218-
utils.invalidateQueries("viewer.web3Integration");
219-
};
220-
221207
return (
222208
<Button
223209
loading={mutation.isLoading}
224-
color={connectionBtn ? "warn" : "secondary"}
210+
color={result.data?.isWeb3Active ? "warn" : "secondary"}
225211
disabled={result.isLoading || mutation.isLoading}
226-
onClick={async () => await enableOrDisableWeb3(mutation)}
212+
onClick={() => {
213+
mutation.mutateAsync({});
214+
}}
227215
data-testid="metamask">
228-
{connectionBtn ? t("remove") : t("add")}
216+
{result.data?.isWeb3Active ? t("remove") : t("add")}
229217
</Button>
230218
);
231219
}

apps/web/pages/getting-started.tsx

+3-6
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,9 @@ export default function Onboarding(props: inferSSRProps<typeof getServerSideProp
172172
const handleConfirmStep = async () => {
173173
try {
174174
setSubmitting(true);
175-
if (
176-
steps[currentStep] &&
177-
steps[currentStep].onComplete &&
178-
typeof steps[currentStep].onComplete === "function"
179-
) {
180-
await steps[currentStep].onComplete!();
175+
const onComplete = steps[currentStep]?.onComplete;
176+
if (onComplete) {
177+
await onComplete();
181178
}
182179
incrementStep();
183180
setSubmitting(false);

apps/web/pages/sandbox/Badge.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const page = sandboxPage(function BadgePage() {
3030
)}
3131
</code>
3232
</h3>
33-
<Badge {...(props as any)}>Badge text</Badge>
33+
<Badge {...props}>Badge text</Badge>
3434
</div>
3535
))}
3636
</div>

apps/web/pages/sandbox/Button.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const page = sandboxPage(function ButtonPage() {
5555
)}
5656
</code>
5757
</h3>
58-
<Button {...(props as any)}>Button text</Button>
58+
<Button {...props}>Button text</Button>
5959
</div>
6060
))}
6161
</div>

apps/web/pages/settings/admin.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { TextField } from "@calcom/ui/form/fields";
99
import { getSession } from "@lib/auth";
1010

1111
import SettingsShell from "@components/SettingsShell";
12-
import Shell from "@components/Shell";
1312

1413
function AdminView() {
1514
const { t } = useLocale();

apps/web/server/routers/viewer.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,18 @@ const loggedInViewerRouter = createProtectedRouter()
581581
});
582582

583583
if (web3Credential) {
584-
return ctx.prisma.credential.delete({
584+
const deleted = await ctx.prisma.credential.delete({
585585
where: {
586586
id: web3Credential.id,
587587
},
588588
});
589+
return {
590+
...deleted,
591+
key: {
592+
...(deleted.key as JSONObject),
593+
isWeb3Active: false,
594+
},
595+
};
589596
} else {
590597
return ctx.prisma.credential.create({
591598
data: {

0 commit comments

Comments
 (0)