Skip to content

Commit f2eebe9

Browse files
authored
chore: Adds deprecated-imports-next-router (#14486)
1 parent 3084013 commit f2eebe9

9 files changed

Lines changed: 46 additions & 13 deletions

File tree

apps/web/components/settings/organizations/platform/oauth-clients/OAuthClientForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useRouter } from "next/router";
1+
import { useRouter } from "next/navigation";
22
import type { FC } from "react";
33
import React, { useState, useCallback, useEffect } from "react";
44
import { useForm, useFieldArray } from "react-hook-form";

apps/web/pages/settings/organizations/platform/oauth-clients/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
2-
import { useRouter } from "next/router";
2+
import { useRouter } from "next/navigation";
33
import React from "react";
44

55
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";

packages/eslint-plugin/src/configs/recommended.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const recommended = {
33
parserOptions: { sourceType: "module" },
44
rules: {
55
"@calcom/eslint/deprecated-imports": "error",
6+
"@calcom/eslint/deprecated-imports-next-router": "error",
67
"@calcom/eslint/avoid-web-storage": "error",
78
"@calcom/eslint/avoid-prisma-client-import-for-enums": "error",
89
},
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { ESLintUtils } from "@typescript-eslint/utils";
2+
3+
const createRule = ESLintUtils.RuleCreator((name) => `https://developer.cal.com/eslint/rule/${name}`);
4+
5+
const rule = createRule({
6+
name: "deprecated-imports-next-router",
7+
meta: {
8+
fixable: "code",
9+
docs: {
10+
description: "Importing router from 'next/router' is deprecated, use 'next/navigation' instead",
11+
recommended: "error",
12+
},
13+
messages: {
14+
"deprecated-next-router":
15+
"Importing router from 'next/router' is deprecated, use 'next/navigation' instead",
16+
},
17+
type: "problem",
18+
schema: [],
19+
},
20+
defaultOptions: [],
21+
create(context) {
22+
return {
23+
ImportDeclaration(node) {
24+
if (node.source.value === "next/router") {
25+
context.report({
26+
node,
27+
messageId: "deprecated-next-router",
28+
fix: function (fixer) {
29+
return fixer.replaceText(node.source, "'next/navigation'");
30+
},
31+
});
32+
}
33+
},
34+
};
35+
},
36+
});
37+
38+
export default rule;

packages/eslint-plugin/src/rules/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export default {
55
"deprecated-imports": require("./deprecated-imports").default,
66
"avoid-web-storage": require("./avoid-web-storage").default,
77
"avoid-prisma-client-import-for-enums": require("./avoid-prisma-client-import-for-enums").default,
8+
"deprecated-imports-next-router": require("./deprecated-imports-next-router").default,
89
} as ESLint.Plugin["rules"];

packages/lib/next-seo.config.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { DefaultSeoProps, NextSeoProps } from "next-seo";
2-
import type { Router } from "next/router";
32

43
import { APP_NAME, SEO_IMG_DEFAULT, SEO_IMG_OGIMG } from "@calcom/lib/constants";
54

@@ -47,12 +46,6 @@ export const seoConfig: {
4746
* @param path NextJS' useRouter().asPath
4847
* @returns
4948
*/
50-
export const buildCanonical = ({
51-
origin,
52-
path,
53-
}: {
54-
origin: Location["origin"];
55-
path: Router["asPath"] | null;
56-
}) => {
49+
export const buildCanonical = ({ origin, path }: { origin: Location["origin"]; path: string | null }) => {
5750
return `${origin}${path === "/" ? "" : path}`.split("?")[0];
5851
};

packages/platform/examples/base/src/pages/[bookingUid].tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Navbar } from "@/components/Navbar";
22
import { CheckCircle2Icon } from "lucide-react";
33
import { X } from "lucide-react";
44
import { Inter } from "next/font/google";
5-
import { useRouter } from "next/router";
5+
import { useRouter } from "next/navigation";
66

77
import { useGetBooking, useCancelBooking } from "@calcom/atoms";
88
import dayjs from "@calcom/dayjs";

packages/platform/examples/base/src/pages/booking.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Navbar } from "@/components/Navbar";
22
import { Inter } from "next/font/google";
3-
import { useRouter } from "next/router";
3+
import { useRouter } from "next/navigation";
44
import { useState } from "react";
55

66
import { Booker, useEventTypesPublic } from "@calcom/atoms";

packages/platform/examples/base/src/pages/bookings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Navbar } from "@/components/Navbar";
22
import { Inter } from "next/font/google";
3-
import { useRouter } from "next/router";
3+
import { useRouter } from "next/navigation";
44

55
import { useGetBookings } from "@calcom/atoms";
66
import dayjs from "@calcom/dayjs";

0 commit comments

Comments
 (0)