lint: array-type (#1165)

* lint: array-type

* format

---------

Co-authored-by: Yusuke Wada <yusuke@kamawada.com>
pull/1176/head
Jonathan Haines 2025-05-19 17:00:53 +10:00 committed by GitHub
parent 52a1d46cd2
commit deeeac9e1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 6 additions and 9 deletions

2
.gitignore vendored
View File

@ -3,7 +3,7 @@ dist
node_modules node_modules
*.tgz *.tgz
coverage coverage
.eslintcache
.yarn/* .yarn/*
!.yarn/cache !.yarn/cache
!.yarn/patches !.yarn/patches

View File

@ -17,7 +17,6 @@ export default defineConfig(globalIgnores(['.yarn', '**/coverage', '**/dist']),
}, },
rules: { rules: {
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/await-thenable': 'off', '@typescript-eslint/await-thenable': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off', '@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/consistent-type-definitions': 'off', '@typescript-eslint/consistent-type-definitions': 'off',

View File

@ -145,7 +145,7 @@ export const createEmitter = <EPMap extends EventPayloadMap>(
if (!handlers.has(key as EventKey)) { if (!handlers.has(key as EventKey)) {
handlers.set(key as EventKey, []) handlers.set(key as EventKey, [])
} }
const handlerArray = handlers.get(key as EventKey) as Array<EventHandler<EPMap[Key]>> const handlerArray = handlers.get(key as EventKey) as EventHandler<EPMap[Key]>[]
const limit = options?.maxHandlers ?? 10 const limit = options?.maxHandlers ?? 10
if (handlerArray.length >= limit) { if (handlerArray.length >= limit) {
throw new RangeError( throw new RangeError(

View File

@ -32,7 +32,7 @@ type Options<E extends Env = any, P extends string = any, I extends Input = {}>
schema: GraphQLSchema schema: GraphQLSchema
rootResolver?: RootResolver<E, P, I> rootResolver?: RootResolver<E, P, I>
pretty?: boolean pretty?: boolean
validationRules?: ReadonlyArray<ValidationRule> validationRules?: readonly ValidationRule[]
graphiql?: boolean graphiql?: boolean
} }

View File

@ -183,9 +183,7 @@ describe('Standard Schema Validation', () => {
'/post', '/post',
sValidator('json', schema, (result, c) => { sValidator('json', schema, (result, c) => {
if (!result.success) { if (!result.success) {
type verify = Expect< type verify = Expect<Equal<readonly StandardSchemaV1.Issue[], typeof result.error>>
Equal<ReadonlyArray<StandardSchemaV1.Issue>, typeof result.error>
>
return c.text(`${result.data.id} is invalid!`, 400) return c.text(`${result.data.id} is invalid!`, 400)
} }
}), }),

View File

@ -14,7 +14,7 @@ type Hook<
> = ( > = (
result: ( result: (
| { success: true; data: T } | { success: true; data: T }
| { success: false; error: ReadonlyArray<StandardSchemaV1.Issue>; data: T } | { success: false; error: readonly StandardSchemaV1.Issue[]; data: T }
) & { ) & {
target: Target target: Target
}, },

View File

@ -313,7 +313,7 @@ describe('Remove non schema items', () => {
}) })
const res = await app.request(req) const res = await app.request(req)
const { message, success } = (await res.json()) as { success: boolean; message: Array<any> } const { message, success } = (await res.json()) as { success: boolean; message: any[] }
expect(res.status).toBe(200) expect(res.status).toBe(200)
expect(success).toBe(true) expect(success).toBe(true)
expect(message).toEqual([ expect(message).toEqual([