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:oauth-providers": "yarn workspace @hono/oauth-providers build",
"build": "run-p 'build:*'", "build": "run-p 'build:*'",
"lint": "eslint 'packages/**/*.{ts,tsx}'", "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", "license": "MIT",
"private": true, "private": true,
@ -59,4 +61,4 @@
"typescript": "^5.2.2" "typescript": "^5.2.2"
}, },
"packageManager": "yarn@4.0.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. // 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 // 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. // 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 // Retrieve user data from github

View File

@ -6,7 +6,7 @@ describe('SwaggerUIOption Rendering', () => {
renderSwaggerUIOptions({ renderSwaggerUIOptions({
configUrl: 'https://petstore3.swagger.io/api/v3/openapi.json', 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', () => { it('renders correctly with presets', () => {
@ -59,7 +59,7 @@ describe('SwaggerUIOption Rendering', () => {
renderSwaggerUIOptions({ renderSwaggerUIOptions({
url: 'https://petstore3.swagger.io/api/v3/openapi.json', 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', () => { it('renders correctly with urls', () => {
@ -82,7 +82,7 @@ describe('SwaggerUIOption Rendering', () => {
renderSwaggerUIOptions({ renderSwaggerUIOptions({
layout: 'StandaloneLayout', layout: 'StandaloneLayout',
}) })
).toEqual('layout: \'StandaloneLayout\'') ).toEqual("layout: 'StandaloneLayout'")
}) })
it('renders correctly with docExpansion', () => { it('renders correctly with docExpansion', () => {
@ -90,7 +90,7 @@ describe('SwaggerUIOption Rendering', () => {
renderSwaggerUIOptions({ renderSwaggerUIOptions({
docExpansion: 'list', docExpansion: 'list',
}) })
).toEqual('docExpansion: \'list\'') ).toEqual("docExpansion: 'list'")
}) })
it('renders correctly with maxDisplayedTags', () => { it('renders correctly with maxDisplayedTags', () => {

View File

@ -75,28 +75,36 @@ describe('Types', () => {
describe('Input types', () => { describe('Input types', () => {
const ParamsSchema = z.object({ const ParamsSchema = z.object({
id: z.string().transform(Number).openapi({ id: z
param: { .string()
name: 'id', .transform(Number)
in: 'path', .openapi({
}, param: {
example: 123, name: 'id',
}), in: 'path',
},
example: 123,
}),
}) })
const QuerySchema = z.object({ const QuerySchema = z.object({
age: z.string().transform(Number).openapi({ age: z
param: { .string()
name: 'age', .transform(Number)
in: 'query', .openapi({
}, param: {
example: 42 name: 'age',
}), in: 'query',
},
example: 42,
}),
}) })
const BodySchema = z.object({ const BodySchema = z
sex: z.enum(['male', 'female']).openapi({}) .object({
}).openapi('User') sex: z.enum(['male', 'female']).openapi({}),
})
.openapi('User')
const UserSchema = z const UserSchema = z
.object({ .object({
@ -111,7 +119,7 @@ describe('Input types', () => {
}), }),
sex: z.enum(['male', 'female']).openapi({ sex: z.enum(['male', 'female']).openapi({
example: 'male', example: 'male',
}) }),
}) })
.openapi('User') .openapi('User')
@ -141,7 +149,6 @@ describe('Input types', () => {
}, },
}) })
it('Should return correct types', () => { it('Should return correct types', () => {
const app = new OpenAPIHono() const app = new OpenAPIHono()

View File

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