From 9048df415f0e31450c589d8d1de21e61a8ddbb95 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Sun, 8 Oct 2023 16:32:26 +0200 Subject: [PATCH] chore: fix linting (#168) --- package.json | 2 +- test/internal/testService.js | 4 ++-- types/index.d.ts | 7 +++++-- types/index.test-d.ts | 22 +++++++++++----------- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 816fe64..ab82673 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "test:unit": "npm run test:jest && npm run test:tap", "test:typescript": "tsd", "lint": "eslint \"test/**/*.js\" \"test-tap/**/*.js\" index.js", - "prettier": "prettier --write \"{lib,test,test-tap}/**/*.js\" index.js index.d.ts" + "prettier": "prettier --write \"{lib,test,test-tap}/**/*.js\" index.js \"types/**/*.ts\"" }, "dependencies": { "fastify-plugin": "^4.0.0" diff --git a/test/internal/testService.js b/test/internal/testService.js index 1339203..746e091 100644 --- a/test/internal/testService.js +++ b/test/internal/testService.js @@ -12,13 +12,13 @@ class TestService { const testValueFromLib = requestContext.get('testKey') if (testValueFromApp !== `testValue${requestId}`) { throw new Error( - `Wrong value retrieved from app context for request ${requestId}: ${testValueFromApp}` + `Wrong value retrieved from app context for request ${requestId}: ${testValueFromApp}`, ) } if (testValueFromLib !== `testValue${requestId}`) { throw new Error( - `Wrong value retrieved from lib context for request ${requestId}: ${testValueFromLib}` + `Wrong value retrieved from lib context for request ${requestId}: ${testValueFromLib}`, ) } }) diff --git a/types/index.d.ts b/types/index.d.ts index 4ecc842..ecd9cce 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,6 +1,7 @@ import { FastifyPluginCallback, FastifyRequest } from 'fastify' -type FastifyRequestContext = FastifyPluginCallback +type FastifyRequestContext = + FastifyPluginCallback declare module 'fastify' { interface FastifyRequest { @@ -60,5 +61,7 @@ declare namespace fastifyRequestContext { export { fastifyRequestContext as default } } -declare function fastifyRequestContext(...params: Parameters): ReturnType +declare function fastifyRequestContext( + ...params: Parameters +): ReturnType export = fastifyRequestContext diff --git a/types/index.test-d.ts b/types/index.test-d.ts index 230f8e1..d0f88e1 100644 --- a/types/index.test-d.ts +++ b/types/index.test-d.ts @@ -15,7 +15,7 @@ app.register(fastifyRequestContext) declare module './index' { interface RequestContextData { - a?: string, + a?: string log?: FastifyBaseLogger } } @@ -30,8 +30,8 @@ expectAssignable({ }) expectAssignable({ defaultStoreValues: () => ({ - a: 'dummy' - }) + a: 'dummy', + }), }) expectError({ @@ -43,21 +43,21 @@ expectError({ }) expectAssignable(() => ({ - a: 'dummy' + a: 'dummy', })) expectAssignable({ - defaultStoreValues: req => ({ - log: req.log.child({ childLog: true }) - }) + defaultStoreValues: (req) => ({ + log: req.log.child({ childLog: true }), + }), }) -expectAssignable(req => ({ - log: req.log.child({ childLog: true }) +expectAssignable((req) => ({ + log: req.log.child({ childLog: true }), })) -expectError(req => ({ bar: 'dummy' })) -expectError(req => ({ log: 'dummy' })) +expectError((req) => ({ bar: 'dummy' })) +expectError((req) => ({ log: 'dummy' })) expectType(app.requestContext) expectType(requestContext)