Skip to content

Commit

Permalink
Fix code under eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
adaex authored Sep 12, 2021
1 parent 2c0944d commit 3b0ee68
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/base/CoaSwagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class CoaSwagger {
return this.data
}

getHtml(dataUrl: string, group: string = '') {
getHtml(dataUrl: string, group = '') {
const groups = {} as any
_.forEach(this.router.layers, ({ group }) => {
if (group && !groups[group]) groups[group] = true
Expand Down Expand Up @@ -108,7 +108,7 @@ export class CoaSwagger {
summary: opt.name,
description: opt.desc,
tags: [tag],
parameters: [] as object[],
parameters: [] as Record<string, any>[],
requestBody: {
content: {
'application/json': {},
Expand Down Expand Up @@ -201,7 +201,7 @@ export class CoaSwagger {
}
}

const getHtml = (urls: object[], config: CoaSwaggerConfig) => `
const getHtml = (urls: Record<string, any>[], config: CoaSwaggerConfig) => `
<!DOCTYPE html>
<html lang="zh">
<head>
Expand Down
4 changes: 2 additions & 2 deletions lib/base/CoaSwaggerCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class CoaSwaggerCode {
const code = new Code()

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

private newline(content: string = '') {
private newline(content = '') {
this.contents.push(content.length ? this.indent + content : '')
}

Expand Down
4 changes: 2 additions & 2 deletions lib/service/CoaApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class CoaApplication<T extends CoaContext> {
})
}

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

Expand Down Expand Up @@ -56,7 +56,7 @@ export class CoaApplication<T extends CoaContext> {
} else if (type === 'string') {
ctx.html(body as string)
}
} catch (e) {
} catch (e: any) {
// 捕获错误
const isCoaError = e.name === 'CoaError'
const isCoaContextError = e.name === 'CoaContextError'
Expand Down
4 changes: 2 additions & 2 deletions lib/service/CoaRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface CoaRouterOptions {
legacy?: string
access?: string
}
export type CoaRouterHandler<T> = (ctx: T) => Promise<object | string | undefined>
export type CoaRouterHandler<T> = (ctx: T) => Promise<Record<string, any> | string | undefined>
export interface CoaRouterRoutes<T> {
[path: string]: { options: CoaRouterOptions; handler: CoaRouterHandler<T> }
}
Expand Down Expand Up @@ -92,7 +92,7 @@ export class CoaRouter<T> {
}

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

const urls = url.split('?')
Expand Down

0 comments on commit 3b0ee68

Please sign in to comment.