diff --git a/src/App.ts b/src/App.ts index 05352264a..ec3777486 100644 --- a/src/App.ts +++ b/src/App.ts @@ -695,6 +695,8 @@ export default class App { } catch (error) { this.logger.warn('Authorization of incoming event did not succeed. No listeners will be called.'); error.code = 'slack_bolt_authorization_error'; + // disabling due to https://github.com/typescript-eslint/typescript-eslint/issues/1277 + // eslint-disable-next-line consistent-return return this.handleError(error); } @@ -860,22 +862,23 @@ export default class App { // Don't process the last item in the listenerMiddleware array - it shouldn't get a next fn const listener = listenerMiddleware.pop(); - if (listener !== undefined) { - return processMiddleware( - listenerMiddleware, - listenerArgs as AnyMiddlewareArgs, + if (listener === undefined) { + return undefined; + } + return processMiddleware( + listenerMiddleware, + listenerArgs as AnyMiddlewareArgs, + context, + client, + this.logger, + // When the listener middleware chain is done processing, call the listener without a next fn + async () => listener({ + ...(listenerArgs as AnyMiddlewareArgs), context, client, - this.logger, - // When the listener middleware chain is done processing, call the listener without a next fn - async () => listener({ - ...(listenerArgs as AnyMiddlewareArgs), - context, - client, - logger: this.logger, - }), - ); - } + logger: this.logger, + }), + ); }); const settledListenerResults = await allSettled(listenerResults); @@ -890,6 +893,8 @@ export default class App { }, ); } catch (error) { + // disabling due to https://github.com/typescript-eslint/typescript-eslint/issues/1277 + // eslint-disable-next-line consistent-return return this.handleError(error); } } diff --git a/src/receivers/ExpressReceiver.ts b/src/receivers/ExpressReceiver.ts index 40aa9d2fa..07b955ec4 100644 --- a/src/receivers/ExpressReceiver.ts +++ b/src/receivers/ExpressReceiver.ts @@ -327,7 +327,7 @@ export default class ExpressReceiver implements Receiver { return reject(new ReceiverInconsistentStateError(missingServerErrorDescription)); } - resolve(this.server); + return resolve(this.server); }); }); } @@ -335,17 +335,17 @@ export default class ExpressReceiver implements Receiver { // TODO: the arguments should be defined as the arguments to close() (which happen to be none), but for sake of // generic types public stop(): Promise { + if (this.server === undefined) { + return Promise.reject(new ReceiverInconsistentStateError('The receiver cannot be stopped because it was not started.')); + } return new Promise((resolve, reject) => { - if (this.server === undefined) { - return reject(new ReceiverInconsistentStateError('The receiver cannot be stopped because it was not started.')); - } - this.server.close((error) => { + this.server?.close((error) => { if (error !== undefined) { return reject(error); } this.server = undefined; - resolve(); + return resolve(); }); }); } diff --git a/src/receivers/HTTPReceiver.ts b/src/receivers/HTTPReceiver.ts index d8e4805e8..bedae60a7 100644 --- a/src/receivers/HTTPReceiver.ts +++ b/src/receivers/HTTPReceiver.ts @@ -242,7 +242,7 @@ export default class HTTPReceiver implements Receiver { return reject(new ReceiverInconsistentStateError(missingServerErrorDescription)); } - resolve(this.server); + return resolve(this.server); }); }); } @@ -250,17 +250,17 @@ export default class HTTPReceiver implements Receiver { // TODO: the arguments should be defined as the arguments to close() (which happen to be none), but for sake of // generic types public stop(): Promise { + if (this.server === undefined) { + return Promise.reject(new ReceiverInconsistentStateError('The receiver cannot be stopped because it was not started.')); + } return new Promise((resolve, reject) => { - if (this.server === undefined) { - return reject(new ReceiverInconsistentStateError('The receiver cannot be stopped because it was not started.')); - } - this.server.close((error) => { + this.server?.close((error) => { if (error !== undefined) { return reject(error); } this.server = undefined; - resolve(); + return resolve(); }); }); }