From 11ccc37372d801daefc2e3099d19d8727e137f6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20K=C3=B6ssler?= Date: Fri, 6 Dec 2024 10:25:40 +0100 Subject: [PATCH] Fix linting --- library/sources/Hono.test.ts | 7 ++-- .../graphql/extractInputsFromDocument.test.ts | 3 +- library/sources/koa/wrapRouterMiddleware.ts | 40 ------------------- 3 files changed, 4 insertions(+), 46 deletions(-) delete mode 100644 library/sources/koa/wrapRouterMiddleware.ts diff --git a/library/sources/Hono.test.ts b/library/sources/Hono.test.ts index afd3e05f..06f6ae98 100644 --- a/library/sources/Hono.test.ts +++ b/library/sources/Hono.test.ts @@ -12,10 +12,6 @@ import { isLocalhostIP } from "../helpers/isLocalhostIP"; import { createTestAgent } from "../helpers/createTestAgent"; import { addHonoMiddleware } from "../middleware/hono"; import * as fetch from "../helpers/fetch"; -import { - contextStorage as honoContextStorage, - getContext as getHonoContext, -} from "hono/context-storage"; wrap(fetch, "fetch", function mock(original) { return async function mock(this: typeof fetch) { @@ -74,6 +70,9 @@ type Env = { function getApp() { const { Hono } = require("hono") as typeof import("hono"); + const { contextStorage: honoContextStorage, getContext: getHonoContext } = + require("hono/context-storage") as typeof import("hono/context-storage"); + const app = new Hono(); app.use(honoContextStorage()); diff --git a/library/sources/graphql/extractInputsFromDocument.test.ts b/library/sources/graphql/extractInputsFromDocument.test.ts index 053ed94c..2a448526 100644 --- a/library/sources/graphql/extractInputsFromDocument.test.ts +++ b/library/sources/graphql/extractInputsFromDocument.test.ts @@ -11,11 +11,10 @@ import { GraphQLInt, GraphQLInputObjectType, GraphQLID, + visit as visitFn, } from "graphql"; import { extractInputsFromDocument } from "./extractInputsFromDocument"; -import { visit as visitFn } from "graphql"; - const AddressType = new GraphQLObjectType({ name: "Address", fields: { diff --git a/library/sources/koa/wrapRouterMiddleware.ts b/library/sources/koa/wrapRouterMiddleware.ts deleted file mode 100644 index 0411ab22..00000000 --- a/library/sources/koa/wrapRouterMiddleware.ts +++ /dev/null @@ -1,40 +0,0 @@ -import type { Middleware, Context as KoaContext } from "koa"; -import { getContext, updateContext } from "../../agent/Context"; - -export function wrapRouterMiddleware(origMiddleware: Middleware): Middleware { - return function wrapped() { - const applyOriginal = () => { - return origMiddleware.apply( - // @ts-expect-error We don't know the type of this - this, - // @ts-expect-error We don't know the type of arguments - // eslint-disable-next-line prefer-rest-params - arguments - ); - }; - - // eslint-disable-next-line prefer-rest-params - const args = Array.from(arguments); - if ( - typeof args[0] !== "object" || - Array.isArray(args[0]) || - args[0] === null - ) { - return applyOriginal(); - } - - // Context is already set by Koa wrapper, so context should be available - const context = getContext(); - /* c8 ignore next 3 */ - if (!context) { - return applyOriginal(); - } - - const ctx = args[0] as KoaContext; - if (ctx.params) { - updateContext(context, "routeParams", ctx.params); - } - - return applyOriginal(); - }; -}