Skip to content

Commit 3b0ee68

Browse files
authored
Fix code under eslint rules
1 parent 2c0944d commit 3b0ee68

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

lib/base/CoaSwagger.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class CoaSwagger {
7979
return this.data
8080
}
8181

82-
getHtml(dataUrl: string, group: string = '') {
82+
getHtml(dataUrl: string, group = '') {
8383
const groups = {} as any
8484
_.forEach(this.router.layers, ({ group }) => {
8585
if (group && !groups[group]) groups[group] = true
@@ -108,7 +108,7 @@ export class CoaSwagger {
108108
summary: opt.name,
109109
description: opt.desc,
110110
tags: [tag],
111-
parameters: [] as object[],
111+
parameters: [] as Record<string, any>[],
112112
requestBody: {
113113
content: {
114114
'application/json': {},
@@ -201,7 +201,7 @@ export class CoaSwagger {
201201
}
202202
}
203203

204-
const getHtml = (urls: object[], config: CoaSwaggerConfig) => `
204+
const getHtml = (urls: Record<string, any>[], config: CoaSwaggerConfig) => `
205205
<!DOCTYPE html>
206206
<html lang="zh">
207207
<head>

lib/base/CoaSwaggerCode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class CoaSwaggerCode {
1515
const code = new Code()
1616

1717
// 预处理
18-
_.forEach(this.router.layers, ({ group, tag, method, path, options: { name } }, key) => {
18+
_.forEach(this.router.layers, ({ group, tag, options: { name } }, key) => {
1919
if (!name) return
2020
if (group !== matchGroup) return
2121
if (!layerTagMaps[tag]) layerTagMaps[tag] = []
@@ -80,7 +80,7 @@ class Code {
8080
return this.contents.join('\n')
8181
}
8282

83-
private newline(content: string = '') {
83+
private newline(content = '') {
8484
this.contents.push(content.length ? this.indent + content : '')
8585
}
8686

lib/service/CoaApplication.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class CoaApplication<T extends CoaContext> {
2020
})
2121
}
2222

23-
async start(entry: string = '') {
23+
async start(entry = '') {
2424
// 设置端口
2525
const port = parseInt(process.env.HOST || '') || 8000
2626

@@ -56,7 +56,7 @@ export class CoaApplication<T extends CoaContext> {
5656
} else if (type === 'string') {
5757
ctx.html(body as string)
5858
}
59-
} catch (e) {
59+
} catch (e: any) {
6060
// 捕获错误
6161
const isCoaError = e.name === 'CoaError'
6262
const isCoaContextError = e.name === 'CoaContextError'

lib/service/CoaRouter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface CoaRouterOptions {
1414
legacy?: string
1515
access?: string
1616
}
17-
export type CoaRouterHandler<T> = (ctx: T) => Promise<object | string | undefined>
17+
export type CoaRouterHandler<T> = (ctx: T) => Promise<Record<string, any> | string | undefined>
1818
export interface CoaRouterRoutes<T> {
1919
[path: string]: { options: CoaRouterOptions; handler: CoaRouterHandler<T> }
2020
}
@@ -92,7 +92,7 @@ export class CoaRouter<T> {
9292
}
9393

9494
// 路由寻址
95-
lookup(method: string = '', url: string = '') {
95+
lookup(method = '', url = '') {
9696
const params: { query: { [key: string]: string }; path: string[] } = { query: {}, path: [] }
9797

9898
const urls = url.split('?')

0 commit comments

Comments
 (0)