enable and fix no-unused-vars and no-async-promise-executor (#17070)

* dev: set --no-bail for lint task

* lint: enable no-async-promise-executor lint and fix them

* lint: enable no-unused-vars with allowing _ prefix

* lint: fix semi
This commit is contained in:
anatawa12
2026-01-08 11:49:12 +09:00
committed by GitHub
parent cf89c4e363
commit 666f78e676
144 changed files with 324 additions and 354 deletions

View File

@@ -75,7 +75,7 @@ export class AccountMoveService {
*/
@bindThis
public async moveFromLocal(src: MiLocalUser, dst: MiLocalUser | MiRemoteUser): Promise<unknown> {
const srcUri = this.userEntityService.getUserUri(src);
const _srcUri = this.userEntityService.getUserUri(src);
const dstUri = this.userEntityService.getUserUri(dst);
// add movedToUri to indicate that the user has moved

View File

@@ -205,7 +205,7 @@ export class AnnouncementService {
announcementId: announcementId,
userId: user.id,
});
} catch (e) {
} catch (_) {
return;
}

View File

@@ -39,7 +39,7 @@ export class AvatarDecorationService implements OnApplicationShutdown {
const obj = JSON.parse(data);
if (obj.channel === 'internal') {
const { type, body } = obj.message as GlobalEvents['internal']['payload'];
const { type, body: _ } = obj.message as GlobalEvents['internal']['payload'];
switch (type) {
case 'avatarDecorationCreated':
case 'avatarDecorationUpdated':

View File

@@ -366,7 +366,7 @@ export class EmailService {
valid: true,
reason: null,
};
} catch (error) {
} catch (_) {
return {
valid: false,
reason: 'network',

View File

@@ -484,25 +484,13 @@ export class FileInfoService {
* Calculate blurhash string of image
*/
@bindThis
private getBlurhash(path: string, type: string): Promise<string> {
return new Promise(async (resolve, reject) => {
(await sharpBmp(path, type))
.raw()
.ensureAlpha()
.resize(64, 64, { fit: 'inside' })
.toBuffer((err, buffer, info) => {
if (err) return reject(err);
let hash;
try {
hash = blurhash.encode(new Uint8ClampedArray(buffer), info.width, info.height, 5, 5);
} catch (e) {
return reject(e);
}
resolve(hash);
});
});
private async getBlurhash(path: string, type: string): Promise<string> {
const sharp = await sharpBmp(path, type);
const { data: buffer, info } = await sharp
.raw()
.ensureAlpha()
.resize(64, 64, { fit: 'inside' })
.toBuffer({ resolveWithObject: true });
return blurhash.encode(new Uint8ClampedArray(buffer), info.width, info.height, 5, 5);
}
}

View File

@@ -308,7 +308,7 @@ export class MfmService {
try {
const date = new Date(parseInt(text, 10) * 1000);
return `<time datetime="${escapeHtml(date.toISOString())}">${escapeHtml(date.toISOString())}</time>`;
} catch (err) {
} catch (_) {
return fnDefault(node);
}
}
@@ -376,7 +376,7 @@ export class MfmService {
try {
const url = new URL(node.props.url);
return `<a href="${escapeHtml(url.href)}">${toHtml(node.children)}</a>`;
} catch (err) {
} catch (_) {
return `[${toHtml(node.children)}](${escapeHtml(node.props.url)})`;
}
},
@@ -390,7 +390,7 @@ export class MfmService {
try {
const url = new URL(href);
return `<a href="${escapeHtml(url.href)}" class="u-url mention">${escapeHtml(acct)}</a>`;
} catch (err) {
} catch (_) {
return escapeHtml(acct);
}
},
@@ -419,7 +419,7 @@ export class MfmService {
try {
const url = new URL(node.props.url);
return `<a href="${escapeHtml(url.href)}">${escapeHtml(node.props.url)}</a>`;
} catch (err) {
} catch (_) {
return escapeHtml(node.props.url);
}
},

View File

@@ -187,9 +187,9 @@ export class NoteDraftService {
}
//#region visibleUsers
let visibleUsers: MiUser[] = [];
let _visibleUsers: MiUser[] = [];
if (data.visibleUserIds != null && data.visibleUserIds.length > 0) {
visibleUsers = await this.usersRepository.findBy({
_visibleUsers = await this.usersRepository.findBy({
id: In(data.visibleUserIds),
});
}

View File

@@ -314,7 +314,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
default:
return false;
}
} catch (err) {
} catch (_) {
// TODO: log error
return false;
}

View File

@@ -190,8 +190,7 @@ export class SearchService {
return this.searchNoteByMeiliSearch(q, me, opts, pagination);
}
default: {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const typeCheck: never = this.provider;
const _: never = this.provider;
return [];
}
}

View File

@@ -49,8 +49,8 @@ export class UserSuspendService {
});
(async () => {
await this.postSuspend(user).catch(e => {});
await this.unFollowAll(user).catch(e => {});
await this.postSuspend(user).catch(_ => {});
await this.unFollowAll(user).catch(_ => {});
})();
}
@@ -67,7 +67,7 @@ export class UserSuspendService {
});
(async () => {
await this.postUnsuspend(user).catch(e => {});
await this.postUnsuspend(user).catch(_ => {});
})();
}

View File

@@ -98,7 +98,7 @@ export class UtilityService {
try {
// TODO: RE2インスタンスをキャッシュ
return new RE2(regexp[1], regexp[2]).test(text);
} catch (err) {
} catch (_) {
// This should never happen due to input sanitisation.
return false;
}

View File

@@ -515,7 +515,7 @@ export class ApRendererService {
const restPart = maybeUrl.slice(match[0].length);
return `<a href="${urlPartParsed.href}" rel="me nofollow noopener" target="_blank">${urlPart}</a>${restPart}`;
} catch (e) {
} catch (_) {
return maybeUrl;
}
};

View File

@@ -226,7 +226,7 @@ export class ApRequestService {
return await this.signedGet(href, user, allowSoftfail, false);
}
}
} catch (e) {
} catch (_) {
// something went wrong parsing the HTML, ignore the whole thing
}
}

View File

@@ -138,7 +138,7 @@ export class ChatEntityService {
const reactions: { reaction: string; }[] = [];
for (const record of message.reactions) {
const [userId, reaction] = record.split('/');
const [, reaction] = record.split('/');
reactions.push({
reaction,
});

View File

@@ -55,13 +55,13 @@ export class MetaEntityService {
if (instance.defaultLightTheme) {
try {
defaultLightTheme = JSON.stringify(JSON5.parse(instance.defaultLightTheme));
} catch (e) {
} catch (_) {
}
}
if (instance.defaultDarkTheme) {
try {
defaultDarkTheme = JSON.stringify(JSON5.parse(instance.defaultDarkTheme));
} catch (e) {
} catch (_) {
}
}

View File

@@ -54,7 +54,7 @@ export class NoteReactionEntityService implements OnModuleInit {
packedUser?: Packed<'UserLite'>
},
): Promise<Packed<'NoteReaction'>> {
const opts = Object.assign({
const _opts = Object.assign({
}, options);
const reaction = typeof src === 'object' ? src : await this.noteReactionsRepository.findOneByOrFail({ id: src });
@@ -90,7 +90,7 @@ export class NoteReactionEntityService implements OnModuleInit {
packedUser?: Packed<'UserLite'>
},
): Promise<Packed<'NoteReactionWithNote'>> {
const opts = Object.assign({
const _opts = Object.assign({
}, options);
const reaction = typeof src === 'object' ? src : await this.noteReactionsRepository.findOneByOrFail({ id: src });