Skip to content

Commit

Permalink
Fix ESLint with --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sw-joelmut committed Oct 24, 2024
1 parent c850da0 commit f1f873e
Show file tree
Hide file tree
Showing 41 changed files with 107 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -141,7 +144,7 @@ export class PayloadAssembler {

private async processStreams(
responsePayload: IResponsePayload | IRequestPayload,
receiveResponse: IReceiveResponse | IReceiveRequest
receiveResponse: IReceiveResponse | IReceiveRequest,
): Promise<void> {
responsePayload.streams?.forEach((responseStream) => {
// There was a bug in how streams were handled. In .NET, the StreamDescription definiton mapped the
Expand All @@ -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<string, string>).type ?? responseStream.contentType;
(responseStream as unknown as Record<string, string>).type ?? responseStream.contentType;

const contentAssembler = this.streamManager.getPayloadAssembler(responseStream.id);

Expand Down
18 changes: 9 additions & 9 deletions libraries/botframework-streaming/src/contentStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export class ContentStream {
return <T>JSON.parse(stringToParse);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
private async readAll(): Promise<Record<string, any>> {
// do a read-all
const allData: INodeBuffer[] = [];
Expand All @@ -107,14 +106,15 @@ export class ContentStream {

if (count < this.length) {
const readToEnd = new Promise<boolean>((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));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class CancelDisassembler {
constructor(
private readonly sender: PayloadSender,
private readonly id: string,
private readonly payloadType: PayloadTypes
private readonly payloadType: PayloadTypes,
) {}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
5 changes: 4 additions & 1 deletion libraries/botframework-streaming/src/httpContentStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,18 @@ 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(
otherBuffer: 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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types */
/* eslint-disable @typescript-eslint/ban-types */
/**
* @module botframework-streaming
*/
Expand Down
6 changes: 3 additions & 3 deletions libraries/botframework-streaming/src/interfaces/ISocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export interface ISocket {
write(buffer: INodeBuffer);
connect(serverAddress: string): Promise<void>;
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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class NamedPipeClient implements IStreamingTransportClient {
this._requestHandler,
this._requestManager,
this._sender,
this._receiver
this._receiver,
);
}

Expand Down Expand Up @@ -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<string, unknown>, args: any): void {
if (!this._isDisconnecting) {
this._isDisconnecting = true;
Expand All @@ -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}. `,
);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class PayloadAssemblerManager {
constructor(
private readonly streamManager: StreamManager,
private readonly onReceiveResponse: (id: string, receiveResponse: IReceiveResponse) => Promise<void>,
private readonly onReceiveRequest: (id: string, receiveRequest: IReceiveRequest) => Promise<void>
private readonly onReceiveRequest: (id: string, receiveRequest: IReceiveRequest) => Promise<void>,
) {}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
16 changes: 6 additions & 10 deletions libraries/botframework-streaming/src/payloads/sendOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ export class SendOperations {
await disassembler.disassemble();

if (request.streams) {
request.streams.forEach(
async (contentStream): Promise<void> => {
await new HttpContentStreamDisassembler(this.payloadSender, contentStream).disassemble();
}
);
request.streams.forEach(async (contentStream): Promise<void> => {
await new HttpContentStreamDisassembler(this.payloadSender, contentStream).disassemble();
});
}
}

Expand All @@ -61,11 +59,9 @@ export class SendOperations {
await disassembler.disassemble();

if (response.streams) {
response.streams.forEach(
async (contentStream): Promise<void> => {
await new HttpContentStreamDisassembler(this.payloadSender, contentStream).disassemble();
}
);
response.streams.forEach(async (contentStream): Promise<void> => {
await new HttpContentStreamDisassembler(this.payloadSender, contentStream).disassemble();
});
}
}

Expand Down
6 changes: 3 additions & 3 deletions libraries/botframework-streaming/src/protocolAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class ProtocolAdapter {
requestHandler: RequestHandler,
requestManager: RequestManager,
sender: PayloadSender,
receiver: PayloadReceiver
receiver: PayloadReceiver,
) {
this.requestHandler = requestHandler;
this.requestManager = requestManager;
Expand All @@ -54,12 +54,12 @@ export class ProtocolAdapter {
this.assemblerManager = new PayloadAssemblerManager(
this.streamManager,
(id: string, response: IReceiveResponse): Promise<void> => this.onReceiveResponse(id, response),
(id: string, request: IReceiveRequest): Promise<void> => this.onReceiveRequest(id, request)
(id: string, request: IReceiveRequest): Promise<void> => 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),
);
}

Expand Down
6 changes: 3 additions & 3 deletions libraries/botframework-streaming/src/streamingRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down
Loading

0 comments on commit f1f873e

Please sign in to comment.