Просмотр исходного кода

fix non-autofixable biome lint errors

Futa Arai 9 месяцев назад
Родитель
Сommit
f84ce09dc2

+ 1 - 1
apps/slackbot-proxy/src/Server.ts

@@ -116,7 +116,7 @@ export class Server {
   @Inject()
   @Inject()
   injector: InjectorService;
   injector: InjectorService;
 
 
-  $beforeInit(): Promise<any> | void {
+  $beforeInit(): void {
     const serverUri = process.env.SERVER_URI;
     const serverUri = process.env.SERVER_URI;
 
 
     if (serverUri === undefined) {
     if (serverUri === undefined) {

+ 5 - 5
apps/slackbot-proxy/src/controllers/growi-to-slack.ts

@@ -95,7 +95,7 @@ export class GrowiToSlackCtrl {
   async getConnectionStatuses(
   async getConnectionStatuses(
     @Req() req: GrowiReq,
     @Req() req: GrowiReq,
     @Res() res: Res,
     @Res() res: Res,
-  ): Promise<void | string | Res | WebAPICallResult> {
+  ): Promise<undefined | string | Res | WebAPICallResult> {
     // asserted (tokenGtoPs.length > 0) by verifyGrowiToSlackRequest
     // asserted (tokenGtoPs.length > 0) by verifyGrowiToSlackRequest
     const { tokenGtoPs } = req;
     const { tokenGtoPs } = req;
 
 
@@ -111,12 +111,12 @@ export class GrowiToSlackCtrl {
     // key: tokenGtoP, value: botToken
     // key: tokenGtoP, value: botToken
     const botTokenResolverMapping: { [tokenGtoP: string]: string } = {};
     const botTokenResolverMapping: { [tokenGtoP: string]: string } = {};
 
 
-    relations.forEach((relation) => {
+    for (const relation of relations) {
       const botToken = relation.installation?.data?.bot?.token;
       const botToken = relation.installation?.data?.bot?.token;
       if (botToken != null) {
       if (botToken != null) {
         botTokenResolverMapping[relation.tokenGtoP] = botToken;
         botTokenResolverMapping[relation.tokenGtoP] = botToken;
       }
       }
-    });
+    }
 
 
     const connectionStatuses = await getConnectionStatuses(
     const connectionStatuses = await getConnectionStatuses(
       Object.keys(botTokenResolverMapping),
       Object.keys(botTokenResolverMapping),
@@ -130,7 +130,7 @@ export class GrowiToSlackCtrl {
   async putSupportedCommands(
   async putSupportedCommands(
     @Req() req: GrowiReq,
     @Req() req: GrowiReq,
     @Res() res: Res,
     @Res() res: Res,
-  ): Promise<void | string | Res | WebAPICallResult> {
+  ): Promise<undefined | string | Res | WebAPICallResult> {
     // asserted (tokenGtoPs.length > 0) by verifyGrowiToSlackRequest
     // asserted (tokenGtoPs.length > 0) by verifyGrowiToSlackRequest
     const { tokenGtoPs } = req;
     const { tokenGtoPs } = req;
 
 
@@ -158,7 +158,7 @@ export class GrowiToSlackCtrl {
   async postRelation(
   async postRelation(
     @Req() req: GrowiReq,
     @Req() req: GrowiReq,
     @Res() res: Res,
     @Res() res: Res,
-  ): Promise<void | string | Res | WebAPICallResult> {
+  ): Promise<undefined | string | Res | WebAPICallResult> {
     const { tokenGtoPs } = req;
     const { tokenGtoPs } = req;
 
 
     if (tokenGtoPs.length !== 1) {
     if (tokenGtoPs.length !== 1) {

+ 1 - 1
apps/slackbot-proxy/src/controllers/privacy.ts

@@ -11,7 +11,7 @@ export class PrivacyCtrl {
     }
     }
   }
   }
 
 
-  getPrivacy(req: Request, res: Response): string | void {
+  getPrivacy(req: Request, res: Response): void {
     res.render('privacy.ejs');
     res.render('privacy.ejs');
   }
   }
 }
 }

+ 10 - 11
apps/slackbot-proxy/src/controllers/slack.ts

@@ -1,4 +1,4 @@
-import { ServerResponse } from 'http';
+import { ServerResponse } from 'node:http';
 
 
 import {
 import {
   type GrowiCommand,
   type GrowiCommand,
@@ -64,9 +64,7 @@ const postNotAllowedMessage = async (
   commandName: string,
   commandName: string,
 ): Promise<void> => {
 ): Promise<void> => {
   const linkUrlList = Array.from(disallowedGrowiUrls).map((growiUrl) => {
   const linkUrlList = Array.from(disallowedGrowiUrls).map((growiUrl) => {
-    return (
-      '\n' + `• ${new URL('/admin/slack-integration', growiUrl).toString()}`
-    );
+    return `\n• ${new URL('/admin/slack-integration', growiUrl).toString()}`;
   });
   });
 
 
   const growiDocsLink =
   const growiDocsLink =
@@ -127,6 +125,7 @@ export class SlackCtrl {
   private async sendCommand(
   private async sendCommand(
     growiCommand: GrowiCommand,
     growiCommand: GrowiCommand,
     relations: Relation[],
     relations: Relation[],
+    // biome-ignore lint/suspicious/noExplicitAny: ignore
     body: any,
     body: any,
   ) {
   ) {
     if (relations.length === 0) {
     if (relations.length === 0) {
@@ -176,6 +175,7 @@ export class SlackCtrl {
   async handleCommand(
   async handleCommand(
     @Req() req: SlackOauthReq,
     @Req() req: SlackOauthReq,
     @Res() res: Res,
     @Res() res: Res,
+    // biome-ignore lint/suspicious/noConfusingVoidType: TODO: fix in https://redmine.weseek.co.jp/issues/168174
   ): Promise<void | string | Res | WebAPICallResult> {
   ): Promise<void | string | Res | WebAPICallResult> {
     const { body, authorizeResult } = req;
     const { body, authorizeResult } = req;
 
 
@@ -236,9 +236,9 @@ export class SlackCtrl {
     // get relations
     // get relations
     const installationId =
     const installationId =
       authorizeResult.enterpriseId || authorizeResult.teamId;
       authorizeResult.enterpriseId || authorizeResult.teamId;
-    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
     const installation =
     const installation =
       await this.installationRepository.findByTeamIdOrEnterpriseId(
       await this.installationRepository.findByTeamIdOrEnterpriseId(
+        // biome-ignore lint/style/noNonNullAssertion: ignore
         installationId!,
         installationId!,
       );
       );
     const relations = await this.relationRepository
     const relations = await this.relationRepository
@@ -329,9 +329,7 @@ export class SlackCtrl {
     // when all of GROWI disallowed
     // when all of GROWI disallowed
     if (relations.length === disallowedGrowiUrls.size) {
     if (relations.length === disallowedGrowiUrls.size) {
       const linkUrlList = Array.from(disallowedGrowiUrls).map((growiUrl) => {
       const linkUrlList = Array.from(disallowedGrowiUrls).map((growiUrl) => {
-        return (
-          '\n' + `• ${new URL('/admin/slack-integration', growiUrl).toString()}`
-        );
+        return `\n• ${new URL('/admin/slack-integration', growiUrl).toString()}`;
       });
       });
 
 
       const growiDocsLink =
       const growiDocsLink =
@@ -387,6 +385,7 @@ export class SlackCtrl {
   async handleInteraction(
   async handleInteraction(
     @Req() req: SlackOauthReq,
     @Req() req: SlackOauthReq,
     @Res() res: Res,
     @Res() res: Res,
+    // biome-ignore lint/suspicious/noConfusingVoidType: TODO: fix in https://redmine.weseek.co.jp/issues/168174
   ): Promise<void | string | Res | WebAPICallResult> {
   ): Promise<void | string | Res | WebAPICallResult> {
     logger.info('receive interaction', req.authorizeResult);
     logger.info('receive interaction', req.authorizeResult);
     logger.debug('receive interaction', req.body);
     logger.debug('receive interaction', req.body);
@@ -443,9 +442,9 @@ export class SlackCtrl {
     // check permission
     // check permission
     const installationId =
     const installationId =
       authorizeResult.enterpriseId || authorizeResult.teamId;
       authorizeResult.enterpriseId || authorizeResult.teamId;
-    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
     const installation =
     const installation =
       await this.installationRepository.findByTeamIdOrEnterpriseId(
       await this.installationRepository.findByTeamIdOrEnterpriseId(
+        // biome-ignore lint/style/noNonNullAssertion: ignore
         installationId!,
         installationId!,
       );
       );
     const relations = await this.relationRepository
     const relations = await this.relationRepository
@@ -568,7 +567,7 @@ export class SlackCtrl {
     @Req() req: Req,
     @Req() req: Req,
     @Res() serverRes: ServerResponse,
     @Res() serverRes: ServerResponse,
     @Res() platformRes: PlatformResponse,
     @Res() platformRes: PlatformResponse,
-  ): Promise<void | string> {
+  ): Promise<string> {
     // create 'Add to Slack' url
     // create 'Add to Slack' url
     const addToSlackUrl =
     const addToSlackUrl =
       await this.installerService.installer.generateInstallUrl({
       await this.installerService.installer.generateInstallUrl({
@@ -596,7 +595,7 @@ export class SlackCtrl {
     });
     });
 
 
     let httpStatus = 200;
     let httpStatus = 200;
-    let httpBody;
+    let httpBody: string | undefined;
     try {
     try {
       const installation = await installPromise;
       const installation = await installPromise;
 
 

+ 1 - 1
apps/slackbot-proxy/src/controllers/term.ts

@@ -13,7 +13,7 @@ export class TermCtrl {
     }
     }
   }
   }
 
 
-  getTerm(req: Request, res: Response): string | void {
+  getTerm(req: Request, res: Response): void {
     res.render('term.ejs');
     res.render('term.ejs');
   }
   }
 }
 }

+ 1 - 0
apps/slackbot-proxy/src/controllers/top.ts

@@ -15,6 +15,7 @@ export class TopCtrl {
 
 
   @Get('/')
   @Get('/')
   @View('top.ejs')
   @View('top.ejs')
+  // biome-ignore lint/suspicious/noExplicitAny: ignore
   async getTopPage(): Promise<any> {
   async getTopPage(): Promise<any> {
     const url = await this.installerService.installer.generateInstallUrl({
     const url = await this.installerService.installer.generateInstallUrl({
       // Add the scopes your app needs
       // Add the scopes your app needs

+ 1 - 0
apps/slackbot-proxy/src/filters/CustomHttpErrorFilter.ts

@@ -12,6 +12,7 @@ export class CustomHttpErrorFilter implements ExceptionFilterMethods {
   async catch(
   async catch(
     exception: CustomHttpError,
     exception: CustomHttpError,
     ctx: PlatformContext,
     ctx: PlatformContext,
+    // biome-ignore lint/suspicious/noExplicitAny: ignore
   ): Promise<PlatformResponse<any>> {
   ): Promise<PlatformResponse<any>> {
     const { httpError } = exception;
     const { httpError } = exception;
     const { response } = ctx;
     const { response } = ctx;

+ 1 - 0
apps/slackbot-proxy/src/filters/ResourceNotFoundFilter.ts

@@ -11,6 +11,7 @@ export class ResourceNotFoundFilter implements ExceptionFilterMethods {
   async catch(
   async catch(
     exception: ResourceNotFound,
     exception: ResourceNotFound,
     ctx: PlatformContext,
     ctx: PlatformContext,
+    // biome-ignore lint/suspicious/noExplicitAny: ignore
   ): Promise<PlatformResponse<any>> {
   ): Promise<PlatformResponse<any>> {
     const { response } = ctx;
     const { response } = ctx;
 
 

+ 3 - 1
apps/slackbot-proxy/src/interfaces/growi-uri-injector.ts

@@ -12,17 +12,19 @@ export type TypedBlock = {
  * @param data
  * @param data
  * @returns
  * @returns
  */
  */
-// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
 export const isGrowiUriWithOriginalData = (
 export const isGrowiUriWithOriginalData = (
+  // biome-ignore lint/suspicious/noExplicitAny: ignore
   data: any,
   data: any,
 ): data is GrowiUriWithOriginalData => {
 ): data is GrowiUriWithOriginalData => {
   return data.growiUri != null && data.originalData != null;
   return data.growiUri != null && data.originalData != null;
 };
 };
 
 
 export interface GrowiUriInjector<ISDATA, IDATA, ESDATA, EDATA> {
 export interface GrowiUriInjector<ISDATA, IDATA, ESDATA, EDATA> {
+  // biome-ignore lint/suspicious/noExplicitAny: ignore
   shouldHandleToInject(data: ISDATA & any): data is IDATA;
   shouldHandleToInject(data: ISDATA & any): data is IDATA;
   inject(data: IDATA, growiUri: string): void;
   inject(data: IDATA, growiUri: string): void;
 
 
+  // biome-ignore lint/suspicious/noExplicitAny: ignore
   shouldHandleToExtract(data: ESDATA & any): data is EDATA;
   shouldHandleToExtract(data: ESDATA & any): data is EDATA;
   extract(data: EDATA): GrowiUriWithOriginalData;
   extract(data: EDATA): GrowiUriWithOriginalData;
 }
 }

+ 1 - 1
apps/slackbot-proxy/src/middlewares/GlobalHttpErrorHandlingMiddleware.ts

@@ -16,7 +16,7 @@ export class GlobalHttpErrorHandlingMiddleware {
     @Err() err: unknown,
     @Err() err: unknown,
     @Next() next: Next,
     @Next() next: Next,
     ctx: PlatformContext,
     ctx: PlatformContext,
-  ): PlatformResponse | void {
+  ): PlatformResponse | undefined {
     // handle if the err is a HttpError instance
     // handle if the err is a HttpError instance
     if (isHttpError(err)) {
     if (isHttpError(err)) {
       const httpError = err as HttpError;
       const httpError = err as HttpError;

+ 8 - 10
apps/slackbot-proxy/src/middlewares/slack-to-growi/authorizer.ts

@@ -15,13 +15,10 @@ const getCommonMiddleware = (
   installerService: InstallerService,
   installerService: InstallerService,
   logger: Logger,
   logger: Logger,
 ) => {
 ) => {
-  return async (
-    req: SlackOauthReq,
-    res: Res,
-    next: Next,
-  ): Promise<void | Res> => {
+  return async (req: SlackOauthReq, res: Res, next: Next): Promise<void> => {
     if (query.teamId == null && query.enterpriseId == null) {
     if (query.teamId == null && query.enterpriseId == null) {
-      return next(createError(400, 'No installation found'));
+      next(createError(400, 'No installation found'));
+      return;
     }
     }
 
 
     let result: AuthorizeResult;
     let result: AuthorizeResult;
@@ -64,7 +61,7 @@ export class AuthorizeCommandMiddleware implements IMiddleware {
     @Req() req: SlackOauthReq,
     @Req() req: SlackOauthReq,
     @Res() res: Res,
     @Res() res: Res,
     @Next() next: Next,
     @Next() next: Next,
-  ): Promise<void | Res> {
+  ): Promise<void> {
     const { body } = req;
     const { body } = req;
     const teamId = body.team_id;
     const teamId = body.team_id;
     const enterpriseId = body.enterprise_id;
     const enterpriseId = body.enterprise_id;
@@ -101,9 +98,10 @@ export class AuthorizeInteractionMiddleware implements IMiddleware {
     @Req() req: SlackOauthReq,
     @Req() req: SlackOauthReq,
     @Res() res: Res,
     @Res() res: Res,
     @Next() next: Next,
     @Next() next: Next,
-  ): Promise<void | Res> {
+  ): Promise<void> {
     if (req.interactionPayload == null) {
     if (req.interactionPayload == null) {
-      return next(createError(400, 'The request has no payload.'));
+      next(createError(400, 'The request has no payload.'));
+      return;
     }
     }
 
 
     const payload = req.interactionPayload;
     const payload = req.interactionPayload;
@@ -144,7 +142,7 @@ export class AuthorizeEventsMiddleware implements IMiddleware {
     @Req() req: SlackOauthReq,
     @Req() req: SlackOauthReq,
     @Res() res: Res,
     @Res() res: Res,
     @Next() next: Next,
     @Next() next: Next,
-  ): Promise<void | Res> {
+  ): Promise<void> {
     const { body } = req;
     const { body } = req;
     const teamId = body.team_id;
     const teamId = body.team_id;
     const enterpriseId = body.enterprise_id;
     const enterpriseId = body.enterprise_id;

+ 3 - 2
apps/slackbot-proxy/src/middlewares/slack-to-growi/extract-growi-uri-from-req.ts

@@ -15,7 +15,8 @@ export class ExtractGrowiUriFromReq implements IMiddleware {
   use(@Req() req: SlackOauthReq, @Res() res: Res, @Next() next: Next): void {
   use(@Req() req: SlackOauthReq, @Res() res: Res, @Next() next: Next): void {
     // There is no payload in the request from slack
     // There is no payload in the request from slack
     if (req.interactionPayload == null) {
     if (req.interactionPayload == null) {
-      return next();
+      next();
+      return;
     }
     }
 
 
     const payload = req.interactionPayload;
     const payload = req.interactionPayload;
@@ -30,6 +31,6 @@ export class ExtractGrowiUriFromReq implements IMiddleware {
       req.growiUri = data.growiUri;
       req.growiUri = data.growiUri;
     }
     }
 
 
-    return next();
+    next();
   }
   }
 }
 }

+ 1 - 1
apps/slackbot-proxy/src/middlewares/slack-to-growi/join-to-conversation.ts

@@ -17,7 +17,7 @@ export class JoinToConversationMiddleware implements IMiddleware {
   async use(@Req() req: SlackOauthReq): Promise<void> {
   async use(@Req() req: SlackOauthReq): Promise<void> {
     const { body, authorizeResult } = req;
     const { body, authorizeResult } = req;
 
 
-    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+    // biome-ignore lint/style/noNonNullAssertion: ignore
     const client = generateWebClient(authorizeResult.botToken!);
     const client = generateWebClient(authorizeResult.botToken!);
 
 
     try {
     try {

+ 3 - 2
apps/slackbot-proxy/src/middlewares/slack-to-growi/parse-interaction-req.ts

@@ -6,11 +6,12 @@ export class ParseInteractionPayloadMiddleare implements IMiddleware {
   use(@Req() req: RequestFromSlack, @Next() next: Next): void {
   use(@Req() req: RequestFromSlack, @Next() next: Next): void {
     // There is no payload in the request from slack
     // There is no payload in the request from slack
     if (req.body.payload == null) {
     if (req.body.payload == null) {
-      return next();
+      next();
+      return;
     }
     }
 
 
     req.interactionPayload = JSON.parse(req.body.payload);
     req.interactionPayload = JSON.parse(req.body.payload);
 
 
-    return next();
+    next();
   }
   }
 }
 }

+ 1 - 1
apps/slackbot-proxy/src/utils/welcome-message.ts

@@ -4,7 +4,7 @@ import { ChatPostMessageResponse, WebClient } from '@slack/web-api';
 export const postWelcomeMessageOnce = async (
 export const postWelcomeMessageOnce = async (
   client: WebClient,
   client: WebClient,
   channel: string,
   channel: string,
-): Promise<void | ChatPostMessageResponse> => {
+): Promise<undefined | ChatPostMessageResponse> => {
   const history = await client.conversations.history({
   const history = await client.conversations.history({
     channel,
     channel,
     limit: 1,
     limit: 1,