diff --git a/package.json b/package.json index ae41be04..d722ff42 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,9 @@ "build:oauth-providers": "yarn workspace @hono/oauth-providers build", "build": "run-p 'build:*'", "lint": "eslint 'packages/**/*.{ts,tsx}'", - "lint:fix": "eslint --fix 'packages/**/*.{ts,tsx}'" + "lint:fix": "eslint --fix 'packages/**/*.{ts,tsx}'", + "format": "prettier --check 'packages/**/*.{ts,tsx}'", + "format:fix": "prettier --write 'packages/**/*.{ts,tsx}'" }, "license": "MIT", "private": true, @@ -59,4 +61,4 @@ "typescript": "^5.2.2" }, "packageManager": "yarn@4.0.2" -} +} \ No newline at end of file diff --git a/packages/oauth-providers/src/providers/github/githubAuth.ts b/packages/oauth-providers/src/providers/github/githubAuth.ts index 665da022..8d864c76 100644 --- a/packages/oauth-providers/src/providers/github/githubAuth.ts +++ b/packages/oauth-providers/src/providers/github/githubAuth.ts @@ -44,7 +44,9 @@ export function githubAuth(options: { // OAuth apps can't have multiple callback URLs, but GitHub Apps can. // As such, we want to make sure we call back to the same location // for GitHub apps and not the first configured callbackURL in the app config. - return c.redirect(auth.redirect().concat(options.oauthApp ? '' : `&redirect_uri=${c.req.url}`)) + return c.redirect( + auth.redirect().concat(options.oauthApp ? '' : `&redirect_uri=${c.req.url}`) + ) } // Retrieve user data from github diff --git a/packages/swagger-ui/test/option-renderer.test.ts b/packages/swagger-ui/test/option-renderer.test.ts index 0d2541b3..50175152 100644 --- a/packages/swagger-ui/test/option-renderer.test.ts +++ b/packages/swagger-ui/test/option-renderer.test.ts @@ -6,7 +6,7 @@ describe('SwaggerUIOption Rendering', () => { renderSwaggerUIOptions({ configUrl: 'https://petstore3.swagger.io/api/v3/openapi.json', }) - ).toEqual('configUrl: \'https://petstore3.swagger.io/api/v3/openapi.json\'') + ).toEqual("configUrl: 'https://petstore3.swagger.io/api/v3/openapi.json'") }) it('renders correctly with presets', () => { @@ -59,7 +59,7 @@ describe('SwaggerUIOption Rendering', () => { renderSwaggerUIOptions({ url: 'https://petstore3.swagger.io/api/v3/openapi.json', }) - ).toEqual('url: \'https://petstore3.swagger.io/api/v3/openapi.json\'') + ).toEqual("url: 'https://petstore3.swagger.io/api/v3/openapi.json'") }) it('renders correctly with urls', () => { @@ -82,7 +82,7 @@ describe('SwaggerUIOption Rendering', () => { renderSwaggerUIOptions({ layout: 'StandaloneLayout', }) - ).toEqual('layout: \'StandaloneLayout\'') + ).toEqual("layout: 'StandaloneLayout'") }) it('renders correctly with docExpansion', () => { @@ -90,7 +90,7 @@ describe('SwaggerUIOption Rendering', () => { renderSwaggerUIOptions({ docExpansion: 'list', }) - ).toEqual('docExpansion: \'list\'') + ).toEqual("docExpansion: 'list'") }) it('renders correctly with maxDisplayedTags', () => { diff --git a/packages/zod-openapi/test/index.test-d.ts b/packages/zod-openapi/test/index.test-d.ts index d8cd0071..ed8c20e8 100644 --- a/packages/zod-openapi/test/index.test-d.ts +++ b/packages/zod-openapi/test/index.test-d.ts @@ -75,28 +75,36 @@ describe('Types', () => { describe('Input types', () => { const ParamsSchema = z.object({ - id: z.string().transform(Number).openapi({ - param: { - name: 'id', - in: 'path', - }, - example: 123, - }), + id: z + .string() + .transform(Number) + .openapi({ + param: { + name: 'id', + in: 'path', + }, + example: 123, + }), }) const QuerySchema = z.object({ - age: z.string().transform(Number).openapi({ - param: { - name: 'age', - in: 'query', - }, - example: 42 - }), + age: z + .string() + .transform(Number) + .openapi({ + param: { + name: 'age', + in: 'query', + }, + example: 42, + }), }) - const BodySchema = z.object({ - sex: z.enum(['male', 'female']).openapi({}) - }).openapi('User') + const BodySchema = z + .object({ + sex: z.enum(['male', 'female']).openapi({}), + }) + .openapi('User') const UserSchema = z .object({ @@ -111,7 +119,7 @@ describe('Input types', () => { }), sex: z.enum(['male', 'female']).openapi({ example: 'male', - }) + }), }) .openapi('User') @@ -141,7 +149,6 @@ describe('Input types', () => { }, }) - it('Should return correct types', () => { const app = new OpenAPIHono() diff --git a/packages/zod-validator/src/index.ts b/packages/zod-validator/src/index.ts index 08fe64bf..32eab9b9 100644 --- a/packages/zod-validator/src/index.ts +++ b/packages/zod-validator/src/index.ts @@ -17,15 +17,11 @@ export const zValidator = < I = z.input, O = z.output, V extends { - in: HasUndefined extends true - ? { [K in Target]?: I } - : { [K in Target]: I }; - out: { [K in Target]: O }; + in: HasUndefined extends true ? { [K in Target]?: I } : { [K in Target]: I } + out: { [K in Target]: O } } = { - in: HasUndefined extends true - ? { [K in Target]?: I } - : { [K in Target]: I }; - out: { [K in Target]: O }; + in: HasUndefined extends true ? { [K in Target]?: I } : { [K in Target]: I } + out: { [K in Target]: O } } >( target: Target,