chore: setup prettier (#301)

* changeset

* chore: setup prettier
pull/302/head
Yusuke Wada 2023-12-13 17:31:25 +09:00 committed by GitHub
parent 5403955ef6
commit a03e133d42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 34 deletions

View File

@ -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"
}
}

View File

@ -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

View File

@ -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', () => {

View File

@ -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()

View File

@ -17,15 +17,11 @@ export const zValidator = <
I = z.input<T>,
O = z.output<T>,
V extends {
in: HasUndefined<I> extends true
? { [K in Target]?: I }
: { [K in Target]: I };
out: { [K in Target]: O };
in: HasUndefined<I> extends true ? { [K in Target]?: I } : { [K in Target]: I }
out: { [K in Target]: O }
} = {
in: HasUndefined<I> extends true
? { [K in Target]?: I }
: { [K in Target]: I };
out: { [K in Target]: O };
in: HasUndefined<I> extends true ? { [K in Target]?: I } : { [K in Target]: I }
out: { [K in Target]: O }
}
>(
target: Target,