Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [#4684] ESLint issues in botbuilder-testing #4823

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions libraries/botbuilder-testing/eslint.config.cjs

This file was deleted.

5 changes: 2 additions & 3 deletions libraries/botbuilder-testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@
},
"dependencies": {
"botbuilder-core": "4.1.6",
"botbuilder-dialogs": "4.1.6",
"eslint-plugin-only-warn": "^1.1.0"
"botbuilder-dialogs": "4.1.6"
},
"scripts": {
"build": "tsc -b",
"build-docs": "typedoc --theme markdown --entryPoint botbuilder --excludePrivate --includeDeclarations --ignoreCompilerErrors --module amd --out ..\\..\\doc\\botbuilder .\\lib\\index.d.ts ..\\botbuilder-core\\lib\\index.d.ts ..\\botframework-schema\\lib\\index.d.ts --hideGenerator --name \"Bot Builder SDK\" --readme none",
"build:rollup": "yarn clean && yarn build && api-extractor run --verbose --local",
"clean": "rimraf _ts3.4 lib tsconfig.tsbuildinfo",
"depcheck": "depcheck --config ../../.depcheckrc",
"lint": "eslint .",
"lint": "eslint . --config ../../eslint.config.cjs",
"postbuild": "downlevel-dts lib _ts3.4/lib --checksum",
"test": "yarn build && nyc mocha tests/",
"test:compat": "api-extractor run --verbose"
Expand Down
13 changes: 5 additions & 8 deletions libraries/botbuilder-testing/src/dialogTestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* Licensed under the MIT License.
*/

/* eslint-disable @typescript-eslint/ban-types */

import {
Activity,
TestAdapter,
Expand Down Expand Up @@ -60,7 +58,7 @@ export class DialogTestClient {
targetDialog: Dialog,
initialDialogOptions?: unknown,
middlewares?: Middleware[],
conversationState?: ConversationState
conversationState?: ConversationState,
);
/**
* Creates a [DialogTestClient](xref:botbuilder-testing.DialogTestClient) to test a [Dialog](xref:botbuilder-dialogs.Dialog) without having to create a full-fledged adapter.
Expand All @@ -81,7 +79,7 @@ export class DialogTestClient {
targetDialog: Dialog,
initialDialogOptions?: unknown,
middlewares?: Middleware[],
conversationState?: ConversationState
conversationState?: ConversationState,
);
/**
* Creates a [DialogTestClient](xref:botbuilder-testing.DialogTestClient) to test a [Dialog](xref:botbuilder-dialogs.Dialog) without having to create a full-fledged adapter.
Expand All @@ -97,7 +95,7 @@ export class DialogTestClient {
targetDialog: Dialog,
initialDialogOptions?: object,
middlewares?: Middleware[],
conversationState?: ConversationState
conversationState?: ConversationState,
) {
this.conversationState = conversationState || new ConversationState(new MemoryStorage());

Expand All @@ -108,7 +106,7 @@ export class DialogTestClient {
if (typeof channelOrAdapter == 'string') {
const channelIdToUse: string = channelOrAdapter;
this._testAdapter = new TestAdapter(this._callback, { channelId: channelIdToUse }).use(
new AutoSaveStateMiddleware(this.conversationState)
new AutoSaveStateMiddleware(this.conversationState),
);
} else {
const testAdapterToUse: TestAdapter = channelOrAdapter;
Expand Down Expand Up @@ -140,7 +138,6 @@ export class DialogTestClient {
* @param activity an activity potentially with text
* @returns a TestFlow that can be used to assert replies etc
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async sendActivity(activity: Partial<Activity> | string): Promise<any> {
await this._testAdapter.receiveActivity(activity);
return this._testAdapter.activityBuffer.shift();
Expand All @@ -158,7 +155,7 @@ export class DialogTestClient {
private getDefaultCallback(
targetDialog: Dialog,
initialDialogOptions: object,
dialogState: StatePropertyAccessor<DialogState>
dialogState: StatePropertyAccessor<DialogState>,
): (turnContext: TurnContext) => Promise<void> {
return async (turnContext: TurnContext): Promise<void> => {
const dialogSet = new DialogSet(dialogState);
Expand Down
48 changes: 23 additions & 25 deletions libraries/botbuilder-testing/src/dialogTestLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,30 @@ export class DialogTestLogger implements Middleware {
const timestamp = `${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`;
this.logger.log(`-> ts: ${timestamp}`);

context.onSendActivities(
async (context, activities, next): Promise<ResourceResponse[]> => {
// log outgoing
activities.forEach((activity) => {
if (activity.type == ActivityTypes.Message) {
this.logger.log(`Bot: Text = ${activity.text}`);
this.logger.log(` Speak = ${activity.speak}`);
this.logger.log(` InputHint = ${activity.inputHint}`);
} else {
this.logger.log(`Bot: Activity = ${activity.type}`);
JSON.stringify(activity, null, 2)
.split(/\n/)
.forEach((line) => {
this.logger.log(line);
});
}
});
const now = new Date();
const stopwatch = context.turnState[this._stopwatchStateKey];
const mms = now.getTime() - stopwatch.getTime();
const timestamp = `${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`;
this.logger.log(`-> ts: ${timestamp} elapsed ${mms} ms`);
context.onSendActivities(async (context, activities, next): Promise<ResourceResponse[]> => {
// log outgoing
activities.forEach((activity) => {
if (activity.type == ActivityTypes.Message) {
this.logger.log(`Bot: Text = ${activity.text}`);
this.logger.log(` Speak = ${activity.speak}`);
this.logger.log(` InputHint = ${activity.inputHint}`);
} else {
this.logger.log(`Bot: Activity = ${activity.type}`);
JSON.stringify(activity, null, 2)
.split(/\n/)
.forEach((line) => {
this.logger.log(line);
});
}
});
const now = new Date();
const stopwatch = context.turnState[this._stopwatchStateKey];
const mms = now.getTime() - stopwatch.getTime();
const timestamp = `${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`;
this.logger.log(`-> ts: ${timestamp} elapsed ${mms} ms`);

return next();
}
);
return next();
});
await next();
}
}
Loading