From 13f7fbd300c8df1e27157e94332a5c3b06db2bb7 Mon Sep 17 00:00:00 2001 From: Jonas Hungershausen Date: Fri, 15 Nov 2024 17:42:13 +0100 Subject: [PATCH] chore: fix example linting --- examples/nextjs-app-router/.eslintrc.json | 10 +++++++++- examples/nextjs-app-router/app/auth/login/page.tsx | 3 +-- examples/nextjs-app-router/app/auth/recovery/page.tsx | 4 ++-- .../nextjs-app-router/app/auth/registration/page.tsx | 3 +-- .../nextjs-app-router/app/auth/verification/page.tsx | 4 ++-- examples/nextjs-app-router/app/page.tsx | 3 ++- examples/nextjs-pages-router/.eslintrc.json | 10 +++++++++- examples/nextjs-pages-router/pages/api/hello.ts | 2 +- examples/nextjs-pages-router/pages/index.tsx | 1 + packages/nextjs/src/app/utils.ts | 4 ++-- 10 files changed, 30 insertions(+), 14 deletions(-) diff --git a/examples/nextjs-app-router/.eslintrc.json b/examples/nextjs-app-router/.eslintrc.json index 37224185..28c34da3 100644 --- a/examples/nextjs-app-router/.eslintrc.json +++ b/examples/nextjs-app-router/.eslintrc.json @@ -1,3 +1,11 @@ { - "extends": ["next/core-web-vitals", "next/typescript"] + "extends": ["next/core-web-vitals", "next/typescript"], + "overrides": [ + { + "files": ["*.ts", "*.tsx"], + "parserOptions": { + "project": ["./examples/nextjs-app-router/tsconfig.json"] + } + } + ] } diff --git a/examples/nextjs-app-router/app/auth/login/page.tsx b/examples/nextjs-app-router/app/auth/login/page.tsx index eceeaacc..ed43ef37 100644 --- a/examples/nextjs-app-router/app/auth/login/page.tsx +++ b/examples/nextjs-app-router/app/auth/login/page.tsx @@ -2,11 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 import { Login } from "@ory/elements-react/theme" -import { getLoginFlow, OryPageParams } from "@ory/nextjs/app" import { enhanceConfig } from "@ory/nextjs" +import { getLoginFlow, OryPageParams } from "@ory/nextjs/app" import config from "@/ory.config" -import CustomCardHeader from "@/components/custom-card-header" export default async function LoginPage(props: OryPageParams) { const flow = await getLoginFlow(props.searchParams) diff --git a/examples/nextjs-app-router/app/auth/recovery/page.tsx b/examples/nextjs-app-router/app/auth/recovery/page.tsx index 67718d65..1a18e046 100644 --- a/examples/nextjs-app-router/app/auth/recovery/page.tsx +++ b/examples/nextjs-app-router/app/auth/recovery/page.tsx @@ -2,11 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 import { Recovery } from "@ory/elements-react/theme" -import { getRecoveryFlow, OryPageParams } from "@ory/nextjs/app" import { enhanceConfig } from "@ory/nextjs" +import { getRecoveryFlow, OryPageParams } from "@ory/nextjs/app" -import config from "@/ory.config" import CustomCardHeader from "@/components/custom-card-header" +import config from "@/ory.config" export default async function RecoveryPage(props: OryPageParams) { const flow = await getRecoveryFlow(props.searchParams) diff --git a/examples/nextjs-app-router/app/auth/registration/page.tsx b/examples/nextjs-app-router/app/auth/registration/page.tsx index bfbf218a..f2ba1ca9 100644 --- a/examples/nextjs-app-router/app/auth/registration/page.tsx +++ b/examples/nextjs-app-router/app/auth/registration/page.tsx @@ -2,11 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 import { Registration } from "@ory/elements-react/theme" -import { getRegistrationFlow, OryPageParams } from "@ory/nextjs/app" import { enhanceConfig } from "@ory/nextjs" +import { getRegistrationFlow, OryPageParams } from "@ory/nextjs/app" import config from "@/ory.config" -import CustomCardHeader from "@/components/custom-card-header" export default async function RegistrationPage(props: OryPageParams) { const flow = await getRegistrationFlow(props.searchParams) diff --git a/examples/nextjs-app-router/app/auth/verification/page.tsx b/examples/nextjs-app-router/app/auth/verification/page.tsx index 05730345..02c4ad24 100644 --- a/examples/nextjs-app-router/app/auth/verification/page.tsx +++ b/examples/nextjs-app-router/app/auth/verification/page.tsx @@ -2,11 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 import { Verification } from "@ory/elements-react/theme" -import { getVerificationFlow, OryPageParams } from "@ory/nextjs/app" import { enhanceConfig } from "@ory/nextjs" +import { getVerificationFlow, OryPageParams } from "@ory/nextjs/app" -import config from "@/ory.config" import CustomCardHeader from "@/components/custom-card-header" +import config from "@/ory.config" export default async function VerificationPage(props: OryPageParams) { const flow = await getVerificationFlow(props.searchParams) diff --git a/examples/nextjs-app-router/app/page.tsx b/examples/nextjs-app-router/app/page.tsx index 0c2d5fdf..f5dfd24a 100644 --- a/examples/nextjs-app-router/app/page.tsx +++ b/examples/nextjs-app-router/app/page.tsx @@ -2,12 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 "use client" -import Link from "next/link" import { useSession } from "@ory/elements-react/client" +import Link from "next/link" export default function RootLayout() { const { session } = useSession() if (session) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access return "Hello: " + session.identity?.traits.email } return ( diff --git a/examples/nextjs-pages-router/.eslintrc.json b/examples/nextjs-pages-router/.eslintrc.json index 37224185..16ccd3a5 100644 --- a/examples/nextjs-pages-router/.eslintrc.json +++ b/examples/nextjs-pages-router/.eslintrc.json @@ -1,3 +1,11 @@ { - "extends": ["next/core-web-vitals", "next/typescript"] + "extends": ["next/core-web-vitals", "next/typescript"], + "overrides": [ + { + "files": ["*.ts", "*.tsx"], + "parserOptions": { + "project": ["./examples/nextjs-pages-router/tsconfig.json"] + } + } + ] } diff --git a/examples/nextjs-pages-router/pages/api/hello.ts b/examples/nextjs-pages-router/pages/api/hello.ts index f945f205..56afe46e 100644 --- a/examples/nextjs-pages-router/pages/api/hello.ts +++ b/examples/nextjs-pages-router/pages/api/hello.ts @@ -4,7 +4,7 @@ // Next.js API route support: https://nextjs.org/docs/api-routes/introduction import type { NextApiRequest, NextApiResponse } from "next" -type Data = { +interface Data { name: string } diff --git a/examples/nextjs-pages-router/pages/index.tsx b/examples/nextjs-pages-router/pages/index.tsx index 9e9ab9e2..a6a3e28b 100644 --- a/examples/nextjs-pages-router/pages/index.tsx +++ b/examples/nextjs-pages-router/pages/index.tsx @@ -8,6 +8,7 @@ import { useSession } from "@ory/elements-react/client" export default function Home() { const { session } = useSession() if (session) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access return "Hello: " + session.identity?.traits.email } return ( diff --git a/packages/nextjs/src/app/utils.ts b/packages/nextjs/src/app/utils.ts index 850181ea..46336e25 100644 --- a/packages/nextjs/src/app/utils.ts +++ b/packages/nextjs/src/app/utils.ts @@ -8,7 +8,7 @@ import { QueryParams } from "../types" import { toFlowParams as baseToFlowParams } from "../utils/utils" export async function getCookieHeader() { - const h = await headers() + const h = headers() return h.get("cookie") ?? undefined } @@ -21,7 +21,7 @@ export async function toFlowParams(params: QueryParams) { } export async function getPublicUrl() { - const h = await headers() + const h = headers() const host = h.get("host") const protocol = h.get("x-forwarded-proto") || "http" return `${protocol}://${host}`