From 5f252cd81459be311d08b53240e5c0d6edf7292e Mon Sep 17 00:00:00 2001 From: Xevion Date: Sun, 18 Dec 2022 00:05:47 -0600 Subject: [PATCH] Switch from relative imports to absolute imports --- src/components/BoxTable.tsx | 4 ++-- src/pages/_app.tsx | 4 ++-- src/pages/api/trpc/[trpc].ts | 6 +++--- src/pages/index.tsx | 2 +- src/server/trpc/router/_app.ts | 4 ++-- src/server/trpc/router/example.ts | 2 +- src/server/trpc/trpc.ts | 2 +- src/utils/trpc.ts | 2 +- tsconfig.json | 6 +++++- 9 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/components/BoxTable.tsx b/src/components/BoxTable.tsx index bbc7f6f..311df5a 100644 --- a/src/components/BoxTable.tsx +++ b/src/components/BoxTable.tsx @@ -1,5 +1,5 @@ -import {classNames, range} from "../utils/helpers"; -import BoxGraphic from "./BoxGraphic"; +import {classNames, range} from "@/utils/helpers"; +import BoxGraphic from "@/components/BoxGraphic"; import Xarrow from "react-xarrows"; import Chance from "chance"; diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 5d58257..8923a53 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -1,8 +1,8 @@ import { type AppType } from "next/app"; -import { trpc } from "../utils/trpc"; +import { trpc } from "@/utils/trpc"; -import "../styles/globals.scss"; +import "@/styles/globals.scss"; const MyApp: AppType = ({ Component, pageProps }) => { return ; diff --git a/src/pages/api/trpc/[trpc].ts b/src/pages/api/trpc/[trpc].ts index f69201d..9698f2e 100644 --- a/src/pages/api/trpc/[trpc].ts +++ b/src/pages/api/trpc/[trpc].ts @@ -1,8 +1,8 @@ import { createNextApiHandler } from "@trpc/server/adapters/next"; -import { env } from "../../../env/server.mjs"; -import { createContext } from "../../../server/trpc/context"; -import { appRouter } from "../../../server/trpc/router/_app"; +import { env } from "@/env/server.mjs"; +import { createContext } from "@/server/trpc/context"; +import { appRouter } from "@/server/trpc/router/_app"; // export API handler export default createNextApiHandler({ diff --git a/src/pages/index.tsx b/src/pages/index.tsx index ec76e6c..bae5c6e 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,6 +1,6 @@ import {type NextPage} from "next"; import Head from "next/head"; -import BoxTable from "../components/BoxTable"; +import BoxTable from "@/components/BoxTable"; import NoSSR from "react-no-ssr"; import Link from "next/link"; diff --git a/src/server/trpc/router/_app.ts b/src/server/trpc/router/_app.ts index 673135d..6966ffe 100644 --- a/src/server/trpc/router/_app.ts +++ b/src/server/trpc/router/_app.ts @@ -1,5 +1,5 @@ -import { router } from "../trpc"; -import { exampleRouter } from "./example"; +import { router } from "@/server/trpc/trpc"; +import { exampleRouter } from "@/server/trpc/router/example"; export const appRouter = router({ example: exampleRouter, diff --git a/src/server/trpc/router/example.ts b/src/server/trpc/router/example.ts index 086a723..47311c9 100644 --- a/src/server/trpc/router/example.ts +++ b/src/server/trpc/router/example.ts @@ -1,6 +1,6 @@ import { z } from "zod"; -import { router, publicProcedure } from "../trpc"; +import { router, publicProcedure } from "@/server/trpc/trpc"; export const exampleRouter = router({ hello: publicProcedure diff --git a/src/server/trpc/trpc.ts b/src/server/trpc/trpc.ts index b4a9527..b68a497 100644 --- a/src/server/trpc/trpc.ts +++ b/src/server/trpc/trpc.ts @@ -1,7 +1,7 @@ import { initTRPC } from "@trpc/server"; import superjson from "superjson"; -import { type Context } from "./context"; +import { type Context } from "@/server/trpc/context"; const t = initTRPC.context().create({ transformer: superjson, diff --git a/src/utils/trpc.ts b/src/utils/trpc.ts index 2391cbc..70aac1c 100644 --- a/src/utils/trpc.ts +++ b/src/utils/trpc.ts @@ -3,7 +3,7 @@ import { createTRPCNext } from "@trpc/next"; import { type inferRouterInputs, type inferRouterOutputs } from "@trpc/server"; import superjson from "superjson"; -import { type AppRouter } from "../server/trpc/router/_app"; +import { type AppRouter } from "@/server/trpc/router/_app"; const getBaseUrl = () => { if (typeof window !== "undefined") return ""; // browser should use relative url diff --git a/tsconfig.json b/tsconfig.json index 658068a..e715e13 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,11 @@ "isolatedModules": true, "jsx": "preserve", "incremental": true, - "noUncheckedIndexedAccess": true + "noUncheckedIndexedAccess": true, + "baseUrl": "./src", + "paths": { + "@/*": ["./*"] + } }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.cjs", "**/*.mjs"], "exclude": ["node_modules"]