From f1f873e1b792e98fa45055da53781dadb5214823 Mon Sep 17 00:00:00 2001 From: Joel Mut Date: Thu, 24 Oct 2024 15:23:56 -0300 Subject: [PATCH] Fix ESLint with --fix --- .../src/assemblers/payloadAssembler.ts | 9 ++++++--- .../src/contentStream.ts | 18 +++++++++--------- .../src/disassemblers/cancelDisassembler.ts | 2 +- .../src/disassemblers/payloadDisassembler.ts | 5 ++++- .../src/disassemblers/requestDisassembler.ts | 6 +++++- .../src/httpContentStream.ts | 5 ++++- .../src/interfaces/IBrowserFileReader.ts | 2 -- .../src/interfaces/IBrowserWebSocket.ts | 3 +-- .../src/interfaces/IEventEmitter.ts | 3 +-- .../src/interfaces/INodeBuffer.ts | 6 ++---- .../src/interfaces/INodeIncomingMessage.ts | 4 ++-- .../src/interfaces/INodeSocket.ts | 2 +- .../src/interfaces/ISocket.ts | 6 +++--- .../src/namedPipe/namedPipeClient.ts | 5 ++--- .../src/namedPipe/namedPipeServer.ts | 6 +++++- .../src/namedPipe/namedPipeTransport.ts | 2 +- .../src/payloadTransport/payloadReceiver.ts | 6 +++--- .../transportDisconnectedEventHandler.ts | 1 - .../src/payloads/headerSerializer.ts | 2 +- .../src/payloads/payloadAssemblerManager.ts | 2 +- .../src/payloads/requestManager.ts | 2 +- .../src/payloads/sendOperations.ts | 16 ++++++---------- .../src/protocolAdapter.ts | 6 +++--- .../src/streamingRequest.ts | 6 +++--- .../src/streamingResponse.ts | 6 +++--- .../src/subscribableStream.ts | 6 +++--- .../src/utilities/createNodeServer.ts | 6 +----- .../src/webSocket/browserWebSocket.ts | 10 +++++----- .../src/webSocket/browserWebSocketClient.ts | 7 +++---- .../src/webSocket/nodeWebSocket.ts | 8 ++++---- .../src/webSocket/nodeWebSocketClient.ts | 7 +++---- .../src/webSocket/webSocketServer.ts | 2 +- .../src/webSocket/webSocketTransport.ts | 2 +- .../tests/Assembler.test.js | 4 ++-- .../tests/ContentStream.test.js | 4 ++-- .../tests/NamedPipe.test.js | 6 +++--- .../tests/NodeWebSocket.test.js | 4 ++-- .../tests/PayloadSender.test.js | 4 ++-- .../tests/ProtocolAdapter.test.js | 12 ++++++------ .../tests/RequestManager.test.js | 2 +- .../tests/helpers/fauxSocket.js | 4 ---- 41 files changed, 107 insertions(+), 112 deletions(-) diff --git a/libraries/botframework-streaming/src/assemblers/payloadAssembler.ts b/libraries/botframework-streaming/src/assemblers/payloadAssembler.ts index 2883426017..9eeb94a46e 100644 --- a/libraries/botframework-streaming/src/assemblers/payloadAssembler.ts +++ b/libraries/botframework-streaming/src/assemblers/payloadAssembler.ts @@ -39,7 +39,10 @@ export class PayloadAssembler { * @param streamManager The [StreamManager](xref:botframework-streaming.StreamManager) managing the stream being assembled. * @param params Parameters for a streaming assembler. */ - constructor(private readonly streamManager: StreamManager, params: IAssemblerParams) { + constructor( + private readonly streamManager: StreamManager, + params: IAssemblerParams, + ) { if (params.header) { this.id = params.header.id; this.payloadType = params.header.payloadType; @@ -141,7 +144,7 @@ export class PayloadAssembler { private async processStreams( responsePayload: IResponsePayload | IRequestPayload, - receiveResponse: IReceiveResponse | IReceiveRequest + receiveResponse: IReceiveResponse | IReceiveRequest, ): Promise { responsePayload.streams?.forEach((responseStream) => { // There was a bug in how streams were handled. In .NET, the StreamDescription definiton mapped the @@ -151,7 +154,7 @@ export class PayloadAssembler { // .NET code: // https://github.com/microsoft/botbuilder-dotnet/blob/a79036ddf6625ec3fd68a6f7295886eb7831bc1c/libraries/Microsoft.Bot.Streaming/Payloads/Models/StreamDescription.cs#L28-L29 const contentType = - ((responseStream as unknown) as Record).type ?? responseStream.contentType; + (responseStream as unknown as Record).type ?? responseStream.contentType; const contentAssembler = this.streamManager.getPayloadAssembler(responseStream.id); diff --git a/libraries/botframework-streaming/src/contentStream.ts b/libraries/botframework-streaming/src/contentStream.ts index b554df3e28..b67059a694 100644 --- a/libraries/botframework-streaming/src/contentStream.ts +++ b/libraries/botframework-streaming/src/contentStream.ts @@ -91,7 +91,6 @@ export class ContentStream { return JSON.parse(stringToParse); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any private async readAll(): Promise> { // do a read-all const allData: INodeBuffer[] = []; @@ -107,14 +106,15 @@ export class ContentStream { if (count < this.length) { const readToEnd = new Promise((resolve): void => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const callback = (cs: ContentStream) => (chunk: any): void => { - allData.push(chunk); - count += (chunk as INodeBuffer).length; - if (count === cs.length) { - resolve(true); - } - }; + const callback = + (cs: ContentStream) => + (chunk: any): void => { + allData.push(chunk); + count += (chunk as INodeBuffer).length; + if (count === cs.length) { + resolve(true); + } + }; stream.subscribe(callback(this)); }); diff --git a/libraries/botframework-streaming/src/disassemblers/cancelDisassembler.ts b/libraries/botframework-streaming/src/disassemblers/cancelDisassembler.ts index a4bf7ec5b9..1c08feb1b3 100644 --- a/libraries/botframework-streaming/src/disassemblers/cancelDisassembler.ts +++ b/libraries/botframework-streaming/src/disassemblers/cancelDisassembler.ts @@ -22,7 +22,7 @@ export class CancelDisassembler { constructor( private readonly sender: PayloadSender, private readonly id: string, - private readonly payloadType: PayloadTypes + private readonly payloadType: PayloadTypes, ) {} /** diff --git a/libraries/botframework-streaming/src/disassemblers/payloadDisassembler.ts b/libraries/botframework-streaming/src/disassemblers/payloadDisassembler.ts index ad4b70bf27..3d5a8c27da 100644 --- a/libraries/botframework-streaming/src/disassemblers/payloadDisassembler.ts +++ b/libraries/botframework-streaming/src/disassemblers/payloadDisassembler.ts @@ -24,7 +24,10 @@ export abstract class PayloadDisassembler { * @param sender The [PayloadSender](xref:botframework-streaming.PayloadSender) used to send the disassembled payload chunks. * @param id The ID of this disassembler. */ - constructor(private readonly sender: PayloadSender, private readonly id: string) {} + constructor( + private readonly sender: PayloadSender, + private readonly id: string, + ) {} /** * Serializes the item into the [IStreamWrapper](xref:botframework-streaming.IStreamWrapper) that exposes the stream and length of the result. diff --git a/libraries/botframework-streaming/src/disassemblers/requestDisassembler.ts b/libraries/botframework-streaming/src/disassemblers/requestDisassembler.ts index 8042e2e7e4..7fa5eabf4a 100644 --- a/libraries/botframework-streaming/src/disassemblers/requestDisassembler.ts +++ b/libraries/botframework-streaming/src/disassemblers/requestDisassembler.ts @@ -25,7 +25,11 @@ export class RequestDisassembler extends PayloadDisassembler { * @param id The ID of this disassembler. * @param request The request to be disassembled. */ - constructor(sender: PayloadSender, id: string, public request?: StreamingRequest) { + constructor( + sender: PayloadSender, + id: string, + public request?: StreamingRequest, + ) { super(sender, id); } diff --git a/libraries/botframework-streaming/src/httpContentStream.ts b/libraries/botframework-streaming/src/httpContentStream.ts index 0f32a1e885..7599d661ed 100644 --- a/libraries/botframework-streaming/src/httpContentStream.ts +++ b/libraries/botframework-streaming/src/httpContentStream.ts @@ -41,7 +41,10 @@ export class HttpContent { * @param headers The Streaming Http content header definition. * @param stream The stream of buffered data. */ - constructor(public headers: IHttpContentHeaders, private readonly stream: SubscribableStream) {} + constructor( + public headers: IHttpContentHeaders, + private readonly stream: SubscribableStream, + ) {} /** * Gets the data contained within this [HttpContent](xref:botframework-streaming.HttpContent). diff --git a/libraries/botframework-streaming/src/interfaces/IBrowserFileReader.ts b/libraries/botframework-streaming/src/interfaces/IBrowserFileReader.ts index 0e0f3ef23e..ccf351e441 100644 --- a/libraries/botframework-streaming/src/interfaces/IBrowserFileReader.ts +++ b/libraries/botframework-streaming/src/interfaces/IBrowserFileReader.ts @@ -13,9 +13,7 @@ * This interface supports the framework and is not intended to be called directly for your code. */ export interface IBrowserFileReader { - /* eslint-disable @typescript-eslint/no-explicit-any */ result: any; onload: (event: any) => void; readAsArrayBuffer: (blobOrFile: any) => void; - /* eslint-enable @typescript-eslint/no-explicit-any */ } diff --git a/libraries/botframework-streaming/src/interfaces/IBrowserWebSocket.ts b/libraries/botframework-streaming/src/interfaces/IBrowserWebSocket.ts index 0a03f808b6..1370fb60f6 100644 --- a/libraries/botframework-streaming/src/interfaces/IBrowserWebSocket.ts +++ b/libraries/botframework-streaming/src/interfaces/IBrowserWebSocket.ts @@ -13,13 +13,12 @@ * This interface supports the framework and is not intended to be called directly for your code. */ export interface IBrowserWebSocket { - /* eslint-disable @typescript-eslint/no-explicit-any */ onclose: (event: any) => void; onerror: (event: any) => void; onmessage: (event: any) => void; onopen: (event: any) => void; send(buffer: any): void; - /* eslint-enable @typescript-eslint/no-explicit-any */ + readyState: number; close(): void; } diff --git a/libraries/botframework-streaming/src/interfaces/IEventEmitter.ts b/libraries/botframework-streaming/src/interfaces/IEventEmitter.ts index 8da005acb1..1dcc15d063 100644 --- a/libraries/botframework-streaming/src/interfaces/IEventEmitter.ts +++ b/libraries/botframework-streaming/src/interfaces/IEventEmitter.ts @@ -12,7 +12,6 @@ * This interface supports the framework and is not intended to be called directly for your code. */ export interface IEventEmitter { - /* eslint-disable @typescript-eslint/no-explicit-any */ addListener(event: string | symbol, listener: (...args: any[]) => void): this; emit(event: string | symbol, ...args: any[]): boolean; off(event: string | symbol, listener: (...args: any[]) => void): this; @@ -21,7 +20,7 @@ export interface IEventEmitter { removeListener(event: string | symbol, listener: (...args: any[]) => void): this; prependListener(event: string | symbol, listener: (...args: any[]) => void): this; prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; - /* eslint-enable @typescript-eslint/no-explicit-any */ + removeAllListeners(event?: string | symbol): this; setMaxListeners(n: number): this; getMaxListeners(): number; diff --git a/libraries/botframework-streaming/src/interfaces/INodeBuffer.ts b/libraries/botframework-streaming/src/interfaces/INodeBuffer.ts index 78a3bf09eb..e98d4ba440 100644 --- a/libraries/botframework-streaming/src/interfaces/INodeBuffer.ts +++ b/libraries/botframework-streaming/src/interfaces/INodeBuffer.ts @@ -26,11 +26,10 @@ export type BufferEncoding = * This interface supports the framework and is not intended to be called directly for your code. */ export interface INodeBuffer extends Uint8Array { - // eslint-disable-next-line @typescript-eslint/no-explicit-any constructor: any; write(string: string, offset?: number, length?: number, encoding?: string): number; toString(encoding?: string, start?: number, end?: number): string; - // eslint-disable-next-line @typescript-eslint/no-explicit-any + toJSON(): { type: 'Buffer'; data: any[] }; equals(otherBuffer: Uint8Array): boolean; compare( @@ -38,7 +37,7 @@ export interface INodeBuffer extends Uint8Array { targetStart?: number, targetEnd?: number, sourceStart?: number, - sourceEnd?: number + sourceEnd?: number, ): number; copy(targetBuffer: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; slice(start?: number, end?: number): this; @@ -92,7 +91,6 @@ export interface INodeBuffer extends Uint8Array { writeDoubleLE(value: number, offset: number, noAssert?: boolean): number; writeDoubleBE(value: number, offset: number, noAssert?: boolean): number; - // eslint-disable-next-line @typescript-eslint/no-explicit-any fill(value: any, offset?: number, end?: number): this; indexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: string): number; lastIndexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: string): number; diff --git a/libraries/botframework-streaming/src/interfaces/INodeIncomingMessage.ts b/libraries/botframework-streaming/src/interfaces/INodeIncomingMessage.ts index efa181a64a..103957b569 100644 --- a/libraries/botframework-streaming/src/interfaces/INodeIncomingMessage.ts +++ b/libraries/botframework-streaming/src/interfaces/INodeIncomingMessage.ts @@ -15,12 +15,12 @@ export interface INodeIncomingMessage { /** * Optional. The request headers. */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any + headers?: any; /** * Optional. The request method. */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any + method?: any; } diff --git a/libraries/botframework-streaming/src/interfaces/INodeSocket.ts b/libraries/botframework-streaming/src/interfaces/INodeSocket.ts index 1d117440c0..10883e3756 100644 --- a/libraries/botframework-streaming/src/interfaces/INodeSocket.ts +++ b/libraries/botframework-streaming/src/interfaces/INodeSocket.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types */ +/* eslint-disable @typescript-eslint/ban-types */ /** * @module botframework-streaming */ diff --git a/libraries/botframework-streaming/src/interfaces/ISocket.ts b/libraries/botframework-streaming/src/interfaces/ISocket.ts index 84844176f8..229a879003 100644 --- a/libraries/botframework-streaming/src/interfaces/ISocket.ts +++ b/libraries/botframework-streaming/src/interfaces/ISocket.ts @@ -18,10 +18,10 @@ export interface ISocket { write(buffer: INodeBuffer); connect(serverAddress: string): Promise; close(); - // eslint-disable-next-line @typescript-eslint/no-explicit-any + setOnMessageHandler(handler: (x: any) => void); - // eslint-disable-next-line @typescript-eslint/no-explicit-any + setOnErrorHandler(handler: (x: any) => void); - // eslint-disable-next-line @typescript-eslint/no-explicit-any + setOnCloseHandler(handler: (x: any) => void); } diff --git a/libraries/botframework-streaming/src/namedPipe/namedPipeClient.ts b/libraries/botframework-streaming/src/namedPipe/namedPipeClient.ts index 71d997b75f..989b51a2b7 100644 --- a/libraries/botframework-streaming/src/namedPipe/namedPipeClient.ts +++ b/libraries/botframework-streaming/src/namedPipe/namedPipeClient.ts @@ -47,7 +47,7 @@ export class NamedPipeClient implements IStreamingTransportClient { this._requestHandler, this._requestManager, this._sender, - this._receiver + this._receiver, ); } @@ -84,7 +84,6 @@ export class NamedPipeClient implements IStreamingTransportClient { return this._protocolAdapter.sendRequest(request); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any private onConnectionDisconnected(sender: Record, args: any): void { if (!this._isDisconnecting) { this._isDisconnecting = true; @@ -102,7 +101,7 @@ export class NamedPipeClient implements IStreamingTransportClient { .then((): void => {}) .catch((error): void => { throw new Error( - `Failed to reconnect. Reason: ${error.message} Sender: ${sender} Args: ${args}. ` + `Failed to reconnect. Reason: ${error.message} Sender: ${sender} Args: ${args}. `, ); }); } diff --git a/libraries/botframework-streaming/src/namedPipe/namedPipeServer.ts b/libraries/botframework-streaming/src/namedPipe/namedPipeServer.ts index 0ebe42752e..635b69f908 100644 --- a/libraries/botframework-streaming/src/namedPipe/namedPipeServer.ts +++ b/libraries/botframework-streaming/src/namedPipe/namedPipeServer.ts @@ -32,7 +32,11 @@ export class NamedPipeServer implements IStreamingTransportServer { * @param requestHandler Optional [RequestHandler](xref:botframework-streaming.RequestHandler) to process incoming messages received by this client. * @param autoReconnect Deprecated: Automatic reconnection is the default behavior. */ - constructor(private readonly baseName: string, requestHandler?: RequestHandler, autoReconnect?: boolean) { + constructor( + private readonly baseName: string, + requestHandler?: RequestHandler, + autoReconnect?: boolean, + ) { if (!baseName) { throw new TypeError('NamedPipeServer: Missing baseName parameter'); } diff --git a/libraries/botframework-streaming/src/namedPipe/namedPipeTransport.ts b/libraries/botframework-streaming/src/namedPipe/namedPipeTransport.ts index 2daebe1306..0999ea9d9b 100644 --- a/libraries/botframework-streaming/src/namedPipe/namedPipeTransport.ts +++ b/libraries/botframework-streaming/src/namedPipe/namedPipeTransport.ts @@ -20,7 +20,7 @@ export class NamedPipeTransport implements ITransportSender, ITransportReceiver private _activeOffset = 0; private _activeReceiveCount = 0; private _activeReceiveResolve: (resolve: INodeBuffer) => void; - // eslint-disable-next-line @typescript-eslint/no-explicit-any + private _activeReceiveReject: (reason?: any) => void; /** diff --git a/libraries/botframework-streaming/src/payloadTransport/payloadReceiver.ts b/libraries/botframework-streaming/src/payloadTransport/payloadReceiver.ts index 870b5d32d6..3ad941fc86 100644 --- a/libraries/botframework-streaming/src/payloadTransport/payloadReceiver.ts +++ b/libraries/botframework-streaming/src/payloadTransport/payloadReceiver.ts @@ -54,7 +54,7 @@ export class PayloadReceiver { */ subscribe( getStream: (header: IHeader) => SubscribableStream, - receiveAction: (header: IHeader, stream: SubscribableStream, count: number) => void + receiveAction: (header: IHeader, stream: SubscribableStream, count: number) => void, ): void { this._getStream = getStream; this._receiveAction = receiveAction; @@ -86,7 +86,7 @@ export class PayloadReceiver { let readSoFar = 0; while (readSoFar < PayloadConstants.MaxHeaderLength) { this._receiveHeaderBuffer = await this._receiver.receive( - PayloadConstants.MaxHeaderLength - readSoFar + PayloadConstants.MaxHeaderLength - readSoFar, ); if (this._receiveHeaderBuffer) { @@ -108,7 +108,7 @@ export class PayloadReceiver { ) { const count = Math.min( header.payloadLength - bytesActuallyRead, - PayloadConstants.MaxPayloadLength + PayloadConstants.MaxPayloadLength, ); this._receivePayloadBuffer = await this._receiver.receive(count); bytesActuallyRead += this._receivePayloadBuffer.byteLength; diff --git a/libraries/botframework-streaming/src/payloadTransport/transportDisconnectedEventHandler.ts b/libraries/botframework-streaming/src/payloadTransport/transportDisconnectedEventHandler.ts index dcc00f39c4..5012fbfad3 100644 --- a/libraries/botframework-streaming/src/payloadTransport/transportDisconnectedEventHandler.ts +++ b/libraries/botframework-streaming/src/payloadTransport/transportDisconnectedEventHandler.ts @@ -8,5 +8,4 @@ import { TransportDisconnectedEvent } from './transportDisconnectedEvent'; -// eslint-disable-next-line @typescript-eslint/no-explicit-any export type TransportDisconnectedEventHandler = (sender: any, e: TransportDisconnectedEvent) => void; diff --git a/libraries/botframework-streaming/src/payloads/headerSerializer.ts b/libraries/botframework-streaming/src/payloads/headerSerializer.ts index 67eeef8972..cb54b56e3e 100644 --- a/libraries/botframework-streaming/src/payloads/headerSerializer.ts +++ b/libraries/botframework-streaming/src/payloads/headerSerializer.ts @@ -41,7 +41,7 @@ export class HeaderSerializer { this.headerLengthPadder(header.payloadLength, this.LengthLength, '0'), this.LengthOffset, this.LengthLength, - this.Encoding + this.Encoding, ); buffer.write(this.Delimiter, this.LengthDelimeterOffset, 1, this.Encoding); buffer.write(header.id, this.IdOffset); diff --git a/libraries/botframework-streaming/src/payloads/payloadAssemblerManager.ts b/libraries/botframework-streaming/src/payloads/payloadAssemblerManager.ts index 6e03145a3e..417723194d 100644 --- a/libraries/botframework-streaming/src/payloads/payloadAssemblerManager.ts +++ b/libraries/botframework-streaming/src/payloads/payloadAssemblerManager.ts @@ -27,7 +27,7 @@ export class PayloadAssemblerManager { constructor( private readonly streamManager: StreamManager, private readonly onReceiveResponse: (id: string, receiveResponse: IReceiveResponse) => Promise, - private readonly onReceiveRequest: (id: string, receiveRequest: IReceiveRequest) => Promise + private readonly onReceiveRequest: (id: string, receiveRequest: IReceiveRequest) => Promise, ) {} /** diff --git a/libraries/botframework-streaming/src/payloads/requestManager.ts b/libraries/botframework-streaming/src/payloads/requestManager.ts index 2b7d9d46b7..795687a732 100644 --- a/libraries/botframework-streaming/src/payloads/requestManager.ts +++ b/libraries/botframework-streaming/src/payloads/requestManager.ts @@ -13,7 +13,7 @@ import { IReceiveResponse } from '../interfaces'; class PendingRequest { requestId: string; resolve: (response: IReceiveResponse) => void; - // eslint-disable-next-line @typescript-eslint/no-explicit-any + reject: (reason?: any) => void; } diff --git a/libraries/botframework-streaming/src/payloads/sendOperations.ts b/libraries/botframework-streaming/src/payloads/sendOperations.ts index 13da105a9c..c24c8b2a54 100644 --- a/libraries/botframework-streaming/src/payloads/sendOperations.ts +++ b/libraries/botframework-streaming/src/payloads/sendOperations.ts @@ -41,11 +41,9 @@ export class SendOperations { await disassembler.disassemble(); if (request.streams) { - request.streams.forEach( - async (contentStream): Promise => { - await new HttpContentStreamDisassembler(this.payloadSender, contentStream).disassemble(); - } - ); + request.streams.forEach(async (contentStream): Promise => { + await new HttpContentStreamDisassembler(this.payloadSender, contentStream).disassemble(); + }); } } @@ -61,11 +59,9 @@ export class SendOperations { await disassembler.disassemble(); if (response.streams) { - response.streams.forEach( - async (contentStream): Promise => { - await new HttpContentStreamDisassembler(this.payloadSender, contentStream).disassemble(); - } - ); + response.streams.forEach(async (contentStream): Promise => { + await new HttpContentStreamDisassembler(this.payloadSender, contentStream).disassemble(); + }); } } diff --git a/libraries/botframework-streaming/src/protocolAdapter.ts b/libraries/botframework-streaming/src/protocolAdapter.ts index 9690e739f8..104373670e 100644 --- a/libraries/botframework-streaming/src/protocolAdapter.ts +++ b/libraries/botframework-streaming/src/protocolAdapter.ts @@ -43,7 +43,7 @@ export class ProtocolAdapter { requestHandler: RequestHandler, requestManager: RequestManager, sender: PayloadSender, - receiver: PayloadReceiver + receiver: PayloadReceiver, ) { this.requestHandler = requestHandler; this.requestManager = requestManager; @@ -54,12 +54,12 @@ export class ProtocolAdapter { this.assemblerManager = new PayloadAssemblerManager( this.streamManager, (id: string, response: IReceiveResponse): Promise => this.onReceiveResponse(id, response), - (id: string, request: IReceiveRequest): Promise => this.onReceiveRequest(id, request) + (id: string, request: IReceiveRequest): Promise => this.onReceiveRequest(id, request), ); this.payloadReceiver.subscribe( (header: IHeader): SubscribableStream => this.assemblerManager.getPayloadStream(header), (header: IHeader, contentStream: SubscribableStream, contentLength: number): void => - this.assemblerManager.onReceive(header, contentStream, contentLength) + this.assemblerManager.onReceive(header, contentStream, contentLength), ); } diff --git a/libraries/botframework-streaming/src/streamingRequest.ts b/libraries/botframework-streaming/src/streamingRequest.ts index 84870da62f..930490811f 100644 --- a/libraries/botframework-streaming/src/streamingRequest.ts +++ b/libraries/botframework-streaming/src/streamingRequest.ts @@ -64,7 +64,7 @@ export class StreamingRequest { * * @param body The JSON text to write to the body of the streamingRequest. */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any + setBody(body: any): void { if (typeof body === 'string') { const stream = new SubscribableStream(); @@ -75,8 +75,8 @@ export class StreamingRequest { type: 'application/json; charset=utf-8', contentLength: stream.length, }, - stream - ) + stream, + ), ); } else if (typeof body === 'object') { this.addStream(body); diff --git a/libraries/botframework-streaming/src/streamingResponse.ts b/libraries/botframework-streaming/src/streamingResponse.ts index 55109d8485..06ecd8f601 100644 --- a/libraries/botframework-streaming/src/streamingResponse.ts +++ b/libraries/botframework-streaming/src/streamingResponse.ts @@ -46,7 +46,7 @@ export class StreamingResponse { * * @param body The JSON text to write to the body of the streaming response. */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any + setBody(body: any): void { const stream = new SubscribableStream(); stream.write(JSON.stringify(body), 'utf8'); @@ -56,8 +56,8 @@ export class StreamingResponse { type: 'application/json; charset=utf-8', contentLength: stream.length, }, - stream - ) + stream, + ), ); } } diff --git a/libraries/botframework-streaming/src/subscribableStream.ts b/libraries/botframework-streaming/src/subscribableStream.ts index f99959e81c..b2ee059511 100644 --- a/libraries/botframework-streaming/src/subscribableStream.ts +++ b/libraries/botframework-streaming/src/subscribableStream.ts @@ -14,7 +14,7 @@ export class SubscribableStream extends Duplex { length = 0; private readonly bufferList: Buffer[] = []; - // eslint-disable-next-line @typescript-eslint/no-explicit-any + private _onData: (chunk: any) => void; /** @@ -34,7 +34,7 @@ export class SubscribableStream extends Duplex { * @param _encoding The encoding. Unused in the implementation of Duplex. * @param callback Callback for when this chunk of data is flushed. */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any + _write(chunk: any, _encoding: string, callback: (error?: Error | null) => void): void { const buffer = Buffer.from(chunk); this.bufferList.push(buffer); @@ -72,7 +72,7 @@ export class SubscribableStream extends Duplex { * * @param onData Callback to be called when onData is executed. */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any + subscribe(onData: (chunk: any) => void): void { this._onData = onData; } diff --git a/libraries/botframework-streaming/src/utilities/createNodeServer.ts b/libraries/botframework-streaming/src/utilities/createNodeServer.ts index 47d2edcd60..95f9218d26 100644 --- a/libraries/botframework-streaming/src/utilities/createNodeServer.ts +++ b/libraries/botframework-streaming/src/utilities/createNodeServer.ts @@ -36,26 +36,22 @@ export function createNodeServer(callback?: ConnectionListener): INodeServer { */ export function getServerFactory(): (callback?: ConnectionListener) => INodeServer { if (typeof require !== undefined) { - // eslint-disable-next-line @typescript-eslint/no-var-requires return require('net').Server; } throw TypeError( - "require is undefined. Must be in a Node module to require 'net' dynamically in order to fetch Server factory." + "require is undefined. Must be in a Node module to require 'net' dynamically in order to fetch Server factory.", ); } -// eslint-disable-next-line @typescript-eslint/no-explicit-any function isNetServer(o: any): o is INodeServer { return hasCloseMethod(o) && hasListenMethod(o); } -// eslint-disable-next-line @typescript-eslint/no-explicit-any function hasCloseMethod(o: any): o is INodeServer { return o.close && typeof o.close === 'function'; } -// eslint-disable-next-line @typescript-eslint/no-explicit-any function hasListenMethod(o: any): o is INodeServer { return o.listen && typeof o.listen === 'function'; } diff --git a/libraries/botframework-streaming/src/webSocket/browserWebSocket.ts b/libraries/botframework-streaming/src/webSocket/browserWebSocket.ts index bbec707294..bcae1a6181 100644 --- a/libraries/botframework-streaming/src/webSocket/browserWebSocket.ts +++ b/libraries/botframework-streaming/src/webSocket/browserWebSocket.ts @@ -32,7 +32,7 @@ export class BrowserWebSocket implements ISocket { */ async connect(serverAddress: string): Promise { let resolver: (value: void | PromiseLike) => void; - // eslint-disable-next-line @typescript-eslint/no-explicit-any + let rejector: (reason?: any) => void; if (!this.webSocket) { @@ -83,7 +83,7 @@ export class BrowserWebSocket implements ISocket { * * @param handler The callback to handle the "message" event. */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any + setOnMessageHandler(handler: (x: any) => void): void { const bufferKey = 'buffer'; const packets = []; @@ -92,7 +92,7 @@ export class BrowserWebSocket implements ISocket { const queueEntry = { buffer: null }; packets.push(queueEntry); fileReader.onload = (e): void => { - const t = (e.target as unknown) as IBrowserFileReader; + const t = e.target as unknown as IBrowserFileReader; queueEntry[bufferKey] = t.result; if (packets[0] === queueEntry) { while (0 < packets.length && packets[0][bufferKey]) { @@ -110,7 +110,7 @@ export class BrowserWebSocket implements ISocket { * * @param handler The callback to handle the "error" event. */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any + setOnErrorHandler(handler: (x: any) => void): void { this.webSocket.onerror = (error): void => { if (error) { @@ -124,7 +124,7 @@ export class BrowserWebSocket implements ISocket { * * @param handler The callback to handle the "close" event. */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any + setOnCloseHandler(handler: (x: any) => void): void { this.webSocket.onclose = handler; } diff --git a/libraries/botframework-streaming/src/webSocket/browserWebSocketClient.ts b/libraries/botframework-streaming/src/webSocket/browserWebSocketClient.ts index 7d7902cfd1..fa7a5fe5d2 100644 --- a/libraries/botframework-streaming/src/webSocket/browserWebSocketClient.ts +++ b/libraries/botframework-streaming/src/webSocket/browserWebSocketClient.ts @@ -59,7 +59,7 @@ export class WebSocketClient implements IStreamingTransportClient { this._requestHandler, this._requestManager, this._sender, - this._receiver + this._receiver, ); } @@ -94,7 +94,6 @@ export class WebSocketClient implements IStreamingTransportClient { return this._protocolAdapter.sendRequest(request); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any private onConnectionDisconnected(sender: Record, args: any): void { // Rejects all pending requests on disconnect. this._requestManager.rejectAllResponses(new Error('Disconnect was called.')); @@ -106,8 +105,8 @@ export class WebSocketClient implements IStreamingTransportClient { throw new Error( `Unable to re-connect client to transport for url ${this._url}. Sender: '${JSON.stringify( - sender - )}'. Args:' ${JSON.stringify(args)}` + sender, + )}'. Args:' ${JSON.stringify(args)}`, ); } } diff --git a/libraries/botframework-streaming/src/webSocket/nodeWebSocket.ts b/libraries/botframework-streaming/src/webSocket/nodeWebSocket.ts index f6cdd740a3..d6d8d1ffbf 100644 --- a/libraries/botframework-streaming/src/webSocket/nodeWebSocket.ts +++ b/libraries/botframework-streaming/src/webSocket/nodeWebSocket.ts @@ -121,7 +121,7 @@ export class NodeWebSocket implements ISocket { req.on('upgrade', (res, socket, head): void => { // @types/ws does not contain the signature for completeUpgrade // https://github.com/websockets/ws/blob/0a612364e69fc07624b8010c6873f7766743a8e3/lib/websocket-server.js#L269 - // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this.wsServer as any).completeUpgrade(wskey, undefined, res, socket, head, (websocket): void => { this.wsSocket = websocket; }); @@ -138,7 +138,7 @@ export class NodeWebSocket implements ISocket { * * @param handler The callback to handle the "message" event. */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any + setOnMessageHandler(handler: (x: any) => void): void { this.wsSocket.on('message', handler); } @@ -160,7 +160,7 @@ export class NodeWebSocket implements ISocket { * * @param handler The callback to handle the "close" event. */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any + setOnCloseHandler(handler: (x: any) => void): void { this.wsSocket.on('close', handler); } @@ -170,7 +170,7 @@ export class NodeWebSocket implements ISocket { * * @param handler The callback to handle the "error" event. */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any + setOnErrorHandler(handler: (x: any) => void): void { this.wsSocket.on('error', (error): void => { if (error) { diff --git a/libraries/botframework-streaming/src/webSocket/nodeWebSocketClient.ts b/libraries/botframework-streaming/src/webSocket/nodeWebSocketClient.ts index 3f32628529..8df9a81718 100644 --- a/libraries/botframework-streaming/src/webSocket/nodeWebSocketClient.ts +++ b/libraries/botframework-streaming/src/webSocket/nodeWebSocketClient.ts @@ -59,7 +59,7 @@ export class WebSocketClient implements IStreamingTransportClient { this._requestHandler, this._requestManager, this._sender, - this._receiver + this._receiver, ); } @@ -98,7 +98,6 @@ export class WebSocketClient implements IStreamingTransportClient { return this._protocolAdapter.sendRequest(request); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any private onConnectionDisconnected(sender: Record, args: any): void { // Rejects all pending requests on disconnect. this._requestManager.rejectAllResponses(new Error('Disconnect was called.')); @@ -110,8 +109,8 @@ export class WebSocketClient implements IStreamingTransportClient { throw new Error( `Unable to re-connect client to Node transport for url ${this._url}. Sender: '${JSON.stringify( - sender - )}'. Args:' ${JSON.stringify(args)}` + sender, + )}'. Args:' ${JSON.stringify(args)}`, ); } } diff --git a/libraries/botframework-streaming/src/webSocket/webSocketServer.ts b/libraries/botframework-streaming/src/webSocket/webSocketServer.ts index 89b4c64b25..d082a1467f 100644 --- a/libraries/botframework-streaming/src/webSocket/webSocketServer.ts +++ b/libraries/botframework-streaming/src/webSocket/webSocketServer.ts @@ -53,7 +53,7 @@ export class WebSocketServer implements IStreamingTransportServer { this._requestHandler, this._requestManager, this._sender, - this._receiver + this._receiver, ); this._closedSignal = (x: string): string => { diff --git a/libraries/botframework-streaming/src/webSocket/webSocketTransport.ts b/libraries/botframework-streaming/src/webSocket/webSocketTransport.ts index 215d286026..c99382942a 100644 --- a/libraries/botframework-streaming/src/webSocket/webSocketTransport.ts +++ b/libraries/botframework-streaming/src/webSocket/webSocketTransport.ts @@ -16,7 +16,7 @@ export class WebSocketTransport implements ITransportSender, ITransportReceiver private _active: INodeBuffer; private _activeOffset = 0; private _activeReceiveResolve: (resolve: INodeBuffer) => void; - // eslint-disable-next-line @typescript-eslint/no-explicit-any + private _activeReceiveReject: (reason?: any) => void; private _activeReceiveCount = 0; diff --git a/libraries/botframework-streaming/tests/Assembler.test.js b/libraries/botframework-streaming/tests/Assembler.test.js index ebd7f28df4..66b57e40fd 100644 --- a/libraries/botframework-streaming/tests/Assembler.test.js +++ b/libraries/botframework-streaming/tests/Assembler.test.js @@ -213,7 +213,7 @@ describe('PayloadAssemblerManager', function () { end: true, }; expect(() => new PayloadAssembler(streamManager, { header })).to.throw( - 'An ID must be supplied when creating an assembler.' + 'An ID must be supplied when creating an assembler.', ); }); @@ -221,7 +221,7 @@ describe('PayloadAssemblerManager', function () { const header = { payloadType: PayloadTypes.response, payloadLength: '5', id: '96', end: true }; const s = new SubscribableStream(); s.write( - '{"statusCode": "12345","streams": [{"id": "1","contentType": "text","length": "2"},{"id": "2","contentType": "text","length": "2"},{"id": "3","contentType": "text","length": "2"}]}' + '{"statusCode": "12345","streams": [{"id": "1","contentType": "text","length": "2"},{"id": "2","contentType": "text","length": "2"},{"id": "3","contentType": "text","length": "2"}]}', ); const rp = { verb: 'POST', path: '/some/path' }; rp.streams = []; diff --git a/libraries/botframework-streaming/tests/ContentStream.test.js b/libraries/botframework-streaming/tests/ContentStream.test.js index 5350ce39b3..b3ebe85fb9 100644 --- a/libraries/botframework-streaming/tests/ContentStream.test.js +++ b/libraries/botframework-streaming/tests/ContentStream.test.js @@ -76,7 +76,7 @@ describe('Streaming Extensions ContentStream Tests ', function () { new PayloadAssembler(streamManager, { id: 'csa1', header: { ...header, payloadLength: 0 }, - }) + }), ); return cs.readAsString().then((data) => { @@ -93,7 +93,7 @@ describe('Streaming Extensions ContentStream Tests ', function () { new PayloadAssembler(streamManager, { id: 'csa1', header: assemblerHeader, - }) + }), ); return cs diff --git a/libraries/botframework-streaming/tests/NamedPipe.test.js b/libraries/botframework-streaming/tests/NamedPipe.test.js index 5892db99b2..3883a7e2a3 100644 --- a/libraries/botframework-streaming/tests/NamedPipe.test.js +++ b/libraries/botframework-streaming/tests/NamedPipe.test.js @@ -354,7 +354,7 @@ describe.windowsOnly('Streaming Extensions NamedPipe Library Tests', function () err.server = server; throw err; } - }) + }), ), (err) => { // Verify we did get an addr in use error @@ -363,12 +363,12 @@ describe.windowsOnly('Streaming Extensions NamedPipe Library Tests', function () assert(err.server, 'server attached to error'); assert( err.server._incomingServer && !err.server._incomingServer.listening, - 'incoming server attached but not listening' + 'incoming server attached but not listening', ); assert(!err.server._outgoingServer, 'no outgoing server attached'); return true; - } + }, ); } finally { servers.forEach((server) => server.disconnect()); diff --git a/libraries/botframework-streaming/tests/NodeWebSocket.test.js b/libraries/botframework-streaming/tests/NodeWebSocket.test.js index 895c027fb0..14f982e1d6 100644 --- a/libraries/botframework-streaming/tests/NodeWebSocket.test.js +++ b/libraries/botframework-streaming/tests/NodeWebSocket.test.js @@ -30,9 +30,9 @@ describe('NodeWebSocket', function () { socket.connect().catch((error) => { expect( error.message === 'connect ECONNREFUSED 127.0.0.1:8082' || - error.message === 'connect ECONNREFUSED ::1:8082' + error.message === 'connect ECONNREFUSED ::1:8082', ).to.be.true; - }) + }), ); }); diff --git a/libraries/botframework-streaming/tests/PayloadSender.test.js b/libraries/botframework-streaming/tests/PayloadSender.test.js index 0b4fac80be..600fae10ce 100644 --- a/libraries/botframework-streaming/tests/PayloadSender.test.js +++ b/libraries/botframework-streaming/tests/PayloadSender.test.js @@ -95,7 +95,7 @@ describe('PayloadTransport', function () { } catch (e) { done(e); } - }) + }), ); }); @@ -182,7 +182,7 @@ describe('PayloadTransport', function () { pr.subscribe( (header) => assemblerManager.getPayloadStream(header), (header, contentStream, contentLength) => - assemblerManager.onReceive(header, contentStream, contentLength) + assemblerManager.onReceive(header, contentStream, contentLength), ); expect(() => pr.connect(sock)).to.not.throw(); diff --git a/libraries/botframework-streaming/tests/ProtocolAdapter.test.js b/libraries/botframework-streaming/tests/ProtocolAdapter.test.js index 85fda449b9..06c797be98 100644 --- a/libraries/botframework-streaming/tests/ProtocolAdapter.test.js +++ b/libraries/botframework-streaming/tests/ProtocolAdapter.test.js @@ -50,7 +50,7 @@ describe('Streaming Extensions ProtocolAdapter', function () { requestHandler, requestManager, payloadSender, - payloadReceiver + payloadReceiver, ); expect(protocolAdapter.assemblerManager).to.not.be.undefined; @@ -79,7 +79,7 @@ describe('Streaming Extensions ProtocolAdapter', function () { requestHandler, requestManager, payloadSender, - payloadReceiver + payloadReceiver, ); const requestHandlerSpy = sinon.spy(requestHandler, 'processRequest'); @@ -99,7 +99,7 @@ describe('Streaming Extensions ProtocolAdapter', function () { requestHandler, requestManager, payloadSender, - payloadReceiver + payloadReceiver, ); const requestManagerSpy = sinon.spy(requestManager, 'signalResponse'); @@ -119,7 +119,7 @@ describe('Streaming Extensions ProtocolAdapter', function () { requestHandler, requestManager, payloadSender, - payloadReceiver + payloadReceiver, ); const header = { payloadType: 'A', payloadLength: '5', id: '100', end: true }; const assembler = new PayloadAssembler.PayloadAssembler(new StreamManager.StreamManager(), { @@ -139,7 +139,7 @@ describe('Streaming Extensions ProtocolAdapter', function () { requestHandler, requestManager, payloadSender, - payloadReceiver + payloadReceiver, ); expect(() => protocolAdapter.sendRequest(new Request.StreamingRequest())).to.not.throw(); @@ -159,7 +159,7 @@ describe('Streaming Extensions ProtocolAdapter', function () { }; const s = new SubscribableStream.SubscribableStream(); s.write( - '{"statusCode": "12345","streams": [{"id": "1","contentType": "text","length": "2"},{"id": "2","contentType": "text","length": "2"},{"id": "3","contentType": "text","length": "2"}]}' + '{"statusCode": "12345","streams": [{"id": "1","contentType": "text","length": "2"},{"id": "2","contentType": "text","length": "2"},{"id": "3","contentType": "text","length": "2"}]}', ); const rp = { verb: 'POST', path: '/some/path' }; rp.streams = []; diff --git a/libraries/botframework-streaming/tests/RequestManager.test.js b/libraries/botframework-streaming/tests/RequestManager.test.js index 450c60fd9c..e79bd5518e 100644 --- a/libraries/botframework-streaming/tests/RequestManager.test.js +++ b/libraries/botframework-streaming/tests/RequestManager.test.js @@ -17,7 +17,7 @@ describe('RequestManager', function () { rm.getResponse(REQUEST_ID); rm.getResponse(REQUEST_ID).catch((reason) => - expect(reason).to.equal(`requestId '${REQUEST_ID}' already exists in RequestManager`) + expect(reason).to.equal(`requestId '${REQUEST_ID}' already exists in RequestManager`), ); }); diff --git a/libraries/botframework-streaming/tests/helpers/fauxSocket.js b/libraries/botframework-streaming/tests/helpers/fauxSocket.js index 562a1e51af..c7b5eef64e 100644 --- a/libraries/botframework-streaming/tests/helpers/fauxSocket.js +++ b/libraries/botframework-streaming/tests/helpers/fauxSocket.js @@ -1,15 +1,11 @@ const { Duplex } = require('stream'); module.exports.FauxSocket = class FauxSocket extends Duplex { - // eslint-disable-next-line no-empty _read() {} - // eslint-disable-next-line no-empty _write() {} - // eslint-disable-next-line no-empty setNoDelay() {} - // eslint-disable-next-line no-empty setTimeout() {} };