Skip to content

Commit

Permalink
fix: make ESLint work and fix lint errors that were undetected before (
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
hbjORbj authored Jan 14, 2025
1 parent 28b757f commit 14151b8
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 27 deletions.
7 changes: 4 additions & 3 deletions apps/web/modules/bookings/views/bookings-listing-view.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use client";

import { useAutoAnimate } from "@formkit/auto-animate/react";
import { Fragment, ReactElement, useState } from "react";
import { z } from "zod";
import type { ReactElement } from "react";
import { Fragment, useState } from "react";
import type { z } from "zod";

import { WipeMyCalActionButton } from "@calcom/app-store/wipemycalother/components";
import dayjs from "@calcom/dayjs";
Expand All @@ -23,7 +24,7 @@ import useMeQuery from "@lib/hooks/useMeQuery";
import BookingListItem from "@components/booking/BookingListItem";
import SkeletonLoader from "@components/booking/SkeletonLoader";

import { validStatuses } from "~/bookings/lib/validStatuses";
import type { validStatuses } from "~/bookings/lib/validStatuses";

type BookingListingStatus = z.infer<NonNullable<typeof filterQuerySchema>>["status"];
type BookingOutput = RouterOutputs["viewer"]["bookings"]["get"]["bookings"][0];
Expand Down
2 changes: 1 addition & 1 deletion apps/web/server/lib/[user]/getServerSideProps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { DehydratedState } from "@tanstack/react-query";
import type { EmbedProps } from "app/WithEmbedSSR";
import type { GetServerSideProps } from "next";
import { encode } from "querystring";
import type { z } from "zod";
Expand All @@ -18,7 +19,6 @@ import type { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
import type { UserProfile } from "@calcom/types/UserProfile";

import { getTemporaryOrgRedirect } from "@lib/getTemporaryOrgRedirect";
import type { EmbedProps } from "app/WithEmbedSSR";

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

Expand Down
2 changes: 1 addition & 1 deletion example-apps/credential-sync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"dotenv": "^16.3.1",
"eslint": "^8",
"eslint": "^8.34.0",
"eslint-config-next": "14.0.4",
"postcss": "^8",
"tailwindcss": "^3.3.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/app-store/alby/components/AlbyPaymentComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ export const AlbyPaymentComponent = (props: IAlbyPaymentComponentProps) => {
<p className="text-sm">Click or scan the invoice below to pay</p>
<Link
href={`lightning:${paymentRequest}`}
className="inline-flex items-center justify-center rounded-2xl rounded-md border border-transparent p-2 bg-white
font-medium text-black shadow-sm hover:brightness-95 focus:outline-none focus:ring-offset-2 p-2">
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">
<QRCode size={192} value={paymentRequest} />
</Link>

Expand Down
7 changes: 7 additions & 0 deletions packages/config/eslint-preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ module.exports = {
"@calcom/eslint/deprecated-imports-next-router": "off",
},
},
{
files: ["packages/trpc/**/*.{tsx,ts}"],
rules: {
"@typescript-eslint/ban-types": "warn",
"@typescript-eslint/no-explicit-any": "warn",
},
},
],
},
{
Expand Down
6 changes: 5 additions & 1 deletion packages/eslint-plugin/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// This registers Typescript compiler instance onto node.js.
// Now it is possible to just require typescript files without any compilation steps in the environment run by node
require("ts-node").register();
require("ts-node").register({
compilerOptions: {
module: "commonjs",
},
});

// re-export our rules so that eslint run by node can understand them
module.exports = {
Expand Down
7 changes: 4 additions & 3 deletions packages/lib/payment/processPaymentRefund.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import prismaMock from "../../../tests/libs/__mocks__/prismaMock";

import { describe, it, expect, vi, beforeEach } from "vitest";

import dayjs from "@calcom/dayjs";
import prismaMock from "../../../tests/libs/__mocks__/prismaMock";

import { getPaymentAppData } from "../getPaymentAppData";
import { handlePaymentRefund } from "./handlePaymentRefund";
import { processPaymentRefund } from "./processPaymentRefund";
import { RefundPolicy } from "./types";

vi.mock('@calcom/lib/getPaymentAppData', () => ({
vi.mock("@calcom/lib/getPaymentAppData", () => ({
getPaymentAppData: vi.fn(),
}));

Expand All @@ -23,7 +24,7 @@ describe("processPaymentRefund", () => {
{
id: 1,
uid: "unique-id-1",
appId: "123",
appId: "123",
bookingId: 456,
amount: 1000,
fee: 50,
Expand Down
2 changes: 1 addition & 1 deletion packages/platform/examples/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"eslint": "^8",
"eslint": "^8.34.0",
"eslint-config-next": "14.0.4",
"postcss": "^8",
"tailwindcss": "^3.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export default function Payment(props: { calUsername: string; calEmail: string }
<Navbar username={props.calUsername} />
<PaymentForm
paymentUid={uid ?? ""}
onPaymentSuccess={(data) => {
onPaymentSuccess={() => {
router.push("/bookings");
}}
onPaymentCancellation={(data) => {
onPaymentCancellation={() => {
router.back();
}}
/>
Expand Down
4 changes: 1 addition & 3 deletions packages/trpc/server/routers/viewer/bookings/find.schema.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { z } from "zod";

const ZFindInputSchema = z.object({
export const ZFindInputSchema = z.object({
bookingUid: z.string().optional(),
});

export type TFindInputSchema = z.infer<typeof ZFindInputSchema>;

export { ZFindInputSchema };
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { z } from "zod";

const ZInstantBookingInputSchema = z.object({
export const ZInstantBookingInputSchema = z.object({
bookingId: z.number(),
});

export type TInstantBookingInputSchema = z.infer<typeof ZInstantBookingInputSchema>;

export { ZInstantBookingInputSchema };
6 changes: 2 additions & 4 deletions packages/trpc/server/routers/viewer/eventTypes/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const BaseEventTypeUpdateInput = _EventTypeModel
.partial()
.extend(_EventTypeModel.pick({ id: true }).shape);

const ZUpdateInputSchema = BaseEventTypeUpdateInput.extend({
export const ZUpdateInputSchema = BaseEventTypeUpdateInput.extend({
aiPhoneCallConfig: aiPhoneCallConfig.refine(
(data) => {
if (!data) return true;
Expand All @@ -92,6 +92,4 @@ const ZUpdateInputSchema = BaseEventTypeUpdateInput.extend({
),
}).strict();
// only run infer over the simple type, excluding refines/transforms.
type TUpdateInputSchema = z.infer<typeof BaseEventTypeUpdateInput>;

export { ZUpdateInputSchema, type TUpdateInputSchema };
export type TUpdateInputSchema = z.infer<typeof BaseEventTypeUpdateInput>;
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { validateBookerLayouts } from "@calcom/lib/validateBookerLayouts";
import type { PrismaClient } from "@calcom/prisma";
import { WorkflowTriggerEvents } from "@calcom/prisma/client";
import { SchedulingType, EventTypeAutoTranslatedField } from "@calcom/prisma/enums";
import { eventTypeAppMetadataOptionalSchema } from "@calcom/prisma/zod-utils";

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

Expand All @@ -27,7 +28,6 @@ import {
handleCustomInputs,
handlePeriodType,
} from "./util";
import { eventTypeAppMetadataOptionalSchema } from "@calcom/prisma/zod-utils";

type SessionUser = NonNullable<TrpcSessionUser>;
type User = {
Expand Down
8 changes: 7 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,12 @@
"HUDDLE01_API_TOKEN",
"REPLEXICA_API_KEY",
"DIRECTORY_IDS_TO_LOG",
"NEXT_PUBLIC_SINGLE_ORG_SLUG"
"NEXT_PUBLIC_SINGLE_ORG_SLUG",
"GOOGLE_REFRESH_TOKEN",
"GOOGLE_CLIENT_ID",
"GOOGLE_CLIENT_SECRET",
"ZOOM_REFRESH_TOKEN",
"CALCOM_ADMIN_API_KEY",
"NEXT_PUBLIC_SINGLE_ORG_MODE_ENABLED"
]
}
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4059,7 +4059,7 @@ __metadata:
"@types/react-dom": ^18
autoprefixer: ^10.0.1
dotenv: ^16.3.1
eslint: ^8
eslint: ^8.34.0
eslint-config-next: 14.0.4
next: 14.0.4
postcss: ^8
Expand Down

0 comments on commit 14151b8

Please sign in to comment.