From 3470070845da091fee3e578a5aab67f380cd1e6a Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Wed, 5 Feb 2025 11:54:29 +0800 Subject: [PATCH] style: fix lint error --- src/server/database/database.service.ts | 10 +++++----- src/server/octokit/octokit.service.ts | 10 ++++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/server/database/database.service.ts b/src/server/database/database.service.ts index f7c98b60..11efe0b1 100644 --- a/src/server/database/database.service.ts +++ b/src/server/database/database.service.ts @@ -113,14 +113,14 @@ export class DatabaseService extends InjectableBase implements OnModuleInit { let updatedFiles: string[]; if (oldInfo.head.sha.length !== 40) { updatedFiles = await Promise.all( - ['version', ...NamespaceName.map((ns) => `database/${ns}.md`)].map((f) => pullFile(f)), + ['version', ...NamespaceName.map((ns) => `database/${ns}.md`)].map(async (f) => pullFile(f)), ); this.logger.verbose(`Reconstruction of database. Updated files: ${updatedFiles.join(', ')}`); } else { const comparison = await this.octokit.compare(this.info.head.sha, headCommit.sha); if (comparison.files && comparison.files.length > 0) { updatedFiles = await Promise.all( - comparison.files.map((f) => pullFile(f.filename, f.status === 'removed')), + comparison.files.map(async (f) => pullFile(f.filename, f.status === 'removed')), ); } else { updatedFiles = []; @@ -143,8 +143,8 @@ export class DatabaseService extends InjectableBase implements OnModuleInit { ): Promise { const content = await this.data.data[ns].save(); let msg: string; - const oldContext = new Context((message.ov ?? message.nv) as TagRecord, message.ok); - const newContext = new Context((message.nv ?? message.ov) as TagRecord, message.nk); + const oldContext = new Context((message.ov ?? message.nv)!, message.ok); + const newContext = new Context((message.nv ?? message.ov)!, message.nk); if (message.ov && message.nv) { msg = `修改 ${ns}:${message.nk ?? message.ok ?? '(注释)'} - ${message.nv.name.render('text', newContext)} | | 原始标签 | 名称 | 描述 | 外部链接 | @@ -181,5 +181,5 @@ ${message.nv.stringify(newContext)} readonly path: string; readonly repo: string; - public data!: Database; + data!: Database; } diff --git a/src/server/octokit/octokit.service.ts b/src/server/octokit/octokit.service.ts index 913a86b0..a6931acc 100644 --- a/src/server/octokit/octokit.service.ts +++ b/src/server/octokit/octokit.service.ts @@ -53,7 +53,9 @@ export class OctokitService extends InjectableBase implements OnModuleInit { else throw new Error(`Failed to get app info`); }); this._botUserInfo = this._appInfo - .then((appInfo) => this.forApp.users.getByUsername({ username: `${appInfo.slug ?? appInfo.name}[bot]` })) + .then(async (appInfo) => + this.forApp.users.getByUsername({ username: `${appInfo.slug ?? appInfo.name}[bot]` }), + ) .then((userInfoReq) => Object.freeze(userInfoReq.data)); } @@ -157,7 +159,7 @@ export class OctokitService extends InjectableBase implements OnModuleInit { repo: this.repo, path, }); - const data = res.data; + const { data } = res; if (Array.isArray(data) || data.type !== 'file' || !('encoding' in data)) { throw new Error(`${path} is not a file.`); } @@ -187,7 +189,7 @@ export class OctokitService extends InjectableBase implements OnModuleInit { sha: oldSha, author, }); - const data = res.data; + const { data } = res; return { file: { path: data.content?.path ?? path, @@ -211,7 +213,7 @@ export class OctokitService extends InjectableBase implements OnModuleInit { repo: this.repo, branch: 'master', }); - const commit = res.data.commit; + const { commit } = res.data; return { sha: commit.sha as Sha1Value, message: commit.commit.message,