Skip to content

Commit 14151b8

Browse files
authored
fix: make ESLint work and fix lint errors that were undetected before (calcom#18639)
* fix eslint config * fix * add it to dev dep * fix * sync eslint version * force ts-node to compile our ESLint plugin's TS files into CommonJS (which ESLint requires) * fix some lint errors * fix lint errors * remove duplicate classname * make @typescript-eslint/ban-types a warn for packages/trpc files * fix lint errors in trpc * fix lint errors in trpc - 2 * fix * fix * fix lint warnings
1 parent 28b757f commit 14151b8

File tree

15 files changed

+39
-27
lines changed

15 files changed

+39
-27
lines changed

apps/web/modules/bookings/views/bookings-listing-view.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"use client";
22

33
import { useAutoAnimate } from "@formkit/auto-animate/react";
4-
import { Fragment, ReactElement, useState } from "react";
5-
import { z } from "zod";
4+
import type { ReactElement } from "react";
5+
import { Fragment, useState } from "react";
6+
import type { z } from "zod";
67

78
import { WipeMyCalActionButton } from "@calcom/app-store/wipemycalother/components";
89
import dayjs from "@calcom/dayjs";
@@ -23,7 +24,7 @@ import useMeQuery from "@lib/hooks/useMeQuery";
2324
import BookingListItem from "@components/booking/BookingListItem";
2425
import SkeletonLoader from "@components/booking/SkeletonLoader";
2526

26-
import { validStatuses } from "~/bookings/lib/validStatuses";
27+
import type { validStatuses } from "~/bookings/lib/validStatuses";
2728

2829
type BookingListingStatus = z.infer<NonNullable<typeof filterQuerySchema>>["status"];
2930
type BookingOutput = RouterOutputs["viewer"]["bookings"]["get"]["bookings"][0];

apps/web/server/lib/[user]/getServerSideProps.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { DehydratedState } from "@tanstack/react-query";
2+
import type { EmbedProps } from "app/WithEmbedSSR";
23
import type { GetServerSideProps } from "next";
34
import { encode } from "querystring";
45
import type { z } from "zod";
@@ -18,7 +19,6 @@ import type { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
1819
import type { UserProfile } from "@calcom/types/UserProfile";
1920

2021
import { getTemporaryOrgRedirect } from "@lib/getTemporaryOrgRedirect";
21-
import type { EmbedProps } from "app/WithEmbedSSR";
2222

2323
import { ssrInit } from "@server/lib/ssr";
2424

example-apps/credential-sync/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"@types/react-dom": "^18",
2323
"autoprefixer": "^10.0.1",
2424
"dotenv": "^16.3.1",
25-
"eslint": "^8",
25+
"eslint": "^8.34.0",
2626
"eslint-config-next": "14.0.4",
2727
"postcss": "^8",
2828
"tailwindcss": "^3.3.0",

packages/app-store/alby/components/AlbyPaymentComponent.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ export const AlbyPaymentComponent = (props: IAlbyPaymentComponentProps) => {
8787
<p className="text-sm">Click or scan the invoice below to pay</p>
8888
<Link
8989
href={`lightning:${paymentRequest}`}
90-
className="inline-flex items-center justify-center rounded-2xl rounded-md border border-transparent p-2 bg-white
91-
font-medium text-black shadow-sm hover:brightness-95 focus:outline-none focus:ring-offset-2 p-2">
90+
className="inline-flex items-center justify-center rounded-2xl rounded-md border border-transparent bg-white p-2 font-medium text-black shadow-sm hover:brightness-95 focus:outline-none focus:ring-offset-2">
9291
<QRCode size={192} value={paymentRequest} />
9392
</Link>
9493

packages/config/eslint-preset.js

+7
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ module.exports = {
8787
"@calcom/eslint/deprecated-imports-next-router": "off",
8888
},
8989
},
90+
{
91+
files: ["packages/trpc/**/*.{tsx,ts}"],
92+
rules: {
93+
"@typescript-eslint/ban-types": "warn",
94+
"@typescript-eslint/no-explicit-any": "warn",
95+
},
96+
},
9097
],
9198
},
9299
{

packages/eslint-plugin/src/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// This registers Typescript compiler instance onto node.js.
22
// Now it is possible to just require typescript files without any compilation steps in the environment run by node
3-
require("ts-node").register();
3+
require("ts-node").register({
4+
compilerOptions: {
5+
module: "commonjs",
6+
},
7+
});
48

59
// re-export our rules so that eslint run by node can understand them
610
module.exports = {

packages/lib/payment/processPaymentRefund.test.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
import prismaMock from "../../../tests/libs/__mocks__/prismaMock";
2+
13
import { describe, it, expect, vi, beforeEach } from "vitest";
24

35
import dayjs from "@calcom/dayjs";
4-
import prismaMock from "../../../tests/libs/__mocks__/prismaMock";
56

67
import { getPaymentAppData } from "../getPaymentAppData";
78
import { handlePaymentRefund } from "./handlePaymentRefund";
89
import { processPaymentRefund } from "./processPaymentRefund";
910
import { RefundPolicy } from "./types";
1011

11-
vi.mock('@calcom/lib/getPaymentAppData', () => ({
12+
vi.mock("@calcom/lib/getPaymentAppData", () => ({
1213
getPaymentAppData: vi.fn(),
1314
}));
1415

@@ -23,7 +24,7 @@ describe("processPaymentRefund", () => {
2324
{
2425
id: 1,
2526
uid: "unique-id-1",
26-
appId: "123",
27+
appId: "123",
2728
bookingId: 456,
2829
amount: 1000,
2930
fee: 50,

packages/platform/examples/base/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"@types/react": "^18",
2323
"@types/react-dom": "^18",
2424
"autoprefixer": "^10.0.1",
25-
"eslint": "^8",
25+
"eslint": "^8.34.0",
2626
"eslint-config-next": "14.0.4",
2727
"postcss": "^8",
2828
"tailwindcss": "^3.3.0",

packages/platform/examples/base/src/pages/payment/[paymentUid].tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ export default function Payment(props: { calUsername: string; calEmail: string }
1818
<Navbar username={props.calUsername} />
1919
<PaymentForm
2020
paymentUid={uid ?? ""}
21-
onPaymentSuccess={(data) => {
21+
onPaymentSuccess={() => {
2222
router.push("/bookings");
2323
}}
24-
onPaymentCancellation={(data) => {
24+
onPaymentCancellation={() => {
2525
router.back();
2626
}}
2727
/>
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { z } from "zod";
22

3-
const ZFindInputSchema = z.object({
3+
export const ZFindInputSchema = z.object({
44
bookingUid: z.string().optional(),
55
});
66

77
export type TFindInputSchema = z.infer<typeof ZFindInputSchema>;
8-
9-
export { ZFindInputSchema };
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { z } from "zod";
22

3-
const ZInstantBookingInputSchema = z.object({
3+
export const ZInstantBookingInputSchema = z.object({
44
bookingId: z.number(),
55
});
66

77
export type TInstantBookingInputSchema = z.infer<typeof ZInstantBookingInputSchema>;
8-
9-
export { ZInstantBookingInputSchema };

packages/trpc/server/routers/viewer/eventTypes/types.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const BaseEventTypeUpdateInput = _EventTypeModel
7575
.partial()
7676
.extend(_EventTypeModel.pick({ id: true }).shape);
7777

78-
const ZUpdateInputSchema = BaseEventTypeUpdateInput.extend({
78+
export const ZUpdateInputSchema = BaseEventTypeUpdateInput.extend({
7979
aiPhoneCallConfig: aiPhoneCallConfig.refine(
8080
(data) => {
8181
if (!data) return true;
@@ -92,6 +92,4 @@ const ZUpdateInputSchema = BaseEventTypeUpdateInput.extend({
9292
),
9393
}).strict();
9494
// only run infer over the simple type, excluding refines/transforms.
95-
type TUpdateInputSchema = z.infer<typeof BaseEventTypeUpdateInput>;
96-
97-
export { ZUpdateInputSchema, type TUpdateInputSchema };
95+
export type TUpdateInputSchema = z.infer<typeof BaseEventTypeUpdateInput>;

packages/trpc/server/routers/viewer/eventTypes/update.handler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { validateBookerLayouts } from "@calcom/lib/validateBookerLayouts";
1515
import type { PrismaClient } from "@calcom/prisma";
1616
import { WorkflowTriggerEvents } from "@calcom/prisma/client";
1717
import { SchedulingType, EventTypeAutoTranslatedField } from "@calcom/prisma/enums";
18+
import { eventTypeAppMetadataOptionalSchema } from "@calcom/prisma/zod-utils";
1819

1920
import { TRPCError } from "@trpc/server";
2021

@@ -27,7 +28,6 @@ import {
2728
handleCustomInputs,
2829
handlePeriodType,
2930
} from "./util";
30-
import { eventTypeAppMetadataOptionalSchema } from "@calcom/prisma/zod-utils";
3131

3232
type SessionUser = NonNullable<TrpcSessionUser>;
3333
type User = {

turbo.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,12 @@
454454
"HUDDLE01_API_TOKEN",
455455
"REPLEXICA_API_KEY",
456456
"DIRECTORY_IDS_TO_LOG",
457-
"NEXT_PUBLIC_SINGLE_ORG_SLUG"
457+
"NEXT_PUBLIC_SINGLE_ORG_SLUG",
458+
"GOOGLE_REFRESH_TOKEN",
459+
"GOOGLE_CLIENT_ID",
460+
"GOOGLE_CLIENT_SECRET",
461+
"ZOOM_REFRESH_TOKEN",
462+
"CALCOM_ADMIN_API_KEY",
463+
"NEXT_PUBLIC_SINGLE_ORG_MODE_ENABLED"
458464
]
459465
}

yarn.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -4059,7 +4059,7 @@ __metadata:
40594059
"@types/react-dom": ^18
40604060
autoprefixer: ^10.0.1
40614061
dotenv: ^16.3.1
4062-
eslint: ^8
4062+
eslint: ^8.34.0
40634063
eslint-config-next: 14.0.4
40644064
next: 14.0.4
40654065
postcss: ^8

0 commit comments

Comments
 (0)