From 5e6c0cb493c1e6397ea47ee4e522cae90c3d22e7 Mon Sep 17 00:00:00 2001 From: JhontSouth Date: Thu, 14 Nov 2024 10:20:57 -0500 Subject: [PATCH 1/4] fix eslint issues in botbuilder-dialogs --- .../botbuilder-dialogs/eslint.config.cjs | 13 - libraries/botbuilder-dialogs/package.json | 2 +- .../scripts/gen-cldr-data.js | 8 +- .../src/choices/choiceFactory.ts | 8 +- .../src/choices/findChoices.ts | 4 +- .../src/choices/findValues.ts | 6 +- .../src/choices/recognizeChoices.ts | 6 +- .../botbuilder-dialogs/src/dialogContext.ts | 15 +- .../src/dialogContextError.ts | 5 +- .../botbuilder-dialogs/src/dialogHelper.ts | 13 +- libraries/botbuilder-dialogs/src/dialogSet.ts | 8 +- .../src/dialogsBotComponent.ts | 6 +- .../src/dialogsComponentRegistration.ts | 3 +- libraries/botbuilder-dialogs/src/i18n.ts | 2 +- .../src/memory/componentPathResolvers.ts | 2 +- .../src/memory/dialogStateManager.ts | 8 +- .../src/memory/scopes/settingsMemoryScope.ts | 2 +- .../src/prompts/activityPrompt.ts | 11 +- .../src/prompts/attachmentPrompt.ts | 4 +- .../src/prompts/choicePrompt.ts | 8 +- .../src/prompts/confirmPrompt.ts | 8 +- .../src/prompts/datetimePrompt.ts | 4 +- .../src/prompts/numberPrompt.ts | 10 +- .../src/prompts/oauthPrompt.ts | 22 +- .../botbuilder-dialogs/src/prompts/prompt.ts | 13 +- .../src/prompts/textPrompt.ts | 4 +- .../src/prompts/userTokenAccess.ts | 40 ++- .../botbuilder-dialogs/src/recognizer.ts | 10 +- .../botbuilder-dialogs/src/skillDialog.ts | 27 +- .../botbuilder-dialogs/src/waterfallDialog.ts | 12 +- .../tests/activityPrompt.test.js | 8 +- .../tests/attachmentPrompt.test.js | 6 +- .../tests/choicePrompt.test.js | 18 +- .../tests/choices_recognizers.test.js | 246 +++++++++--------- .../tests/choices_tokenizer.test.js | 2 +- .../tests/componentDialog.test.js | 22 +- .../tests/confirmPrompt.test.js | 12 +- .../tests/datetimePrompt.test.js | 8 +- .../tests/dialogContext.test.js | 44 ++-- .../tests/dialogHelper.test.js | 6 +- .../tests/dialogManager.test.js | 7 +- .../tests/dialogSet.test.js | 10 +- .../tests/memory/dialogStateManager.test.js | 10 +- .../tests/memory/memoryScopes.test.js | 10 +- .../tests/numberPrompt.test.js | 22 +- .../tests/oauthPrompt.test.js | 48 ++-- .../tests/skillDialog.test.js | 40 +-- .../tests/textPrompt.test.js | 4 +- .../tests/waterfallDialog.test.js | 68 ++--- 49 files changed, 434 insertions(+), 441 deletions(-) delete mode 100644 libraries/botbuilder-dialogs/eslint.config.cjs diff --git a/libraries/botbuilder-dialogs/eslint.config.cjs b/libraries/botbuilder-dialogs/eslint.config.cjs deleted file mode 100644 index 2a93ef4cf1..0000000000 --- a/libraries/botbuilder-dialogs/eslint.config.cjs +++ /dev/null @@ -1,13 +0,0 @@ -const onlyWarn = require("eslint-plugin-only-warn"); -const sharedConfig = require("../../eslint.config.cjs") - -module.exports = [ - ...sharedConfig, - { - ignores: ["**/vendor/"], - }, - { - plugins: { - "only-warn": onlyWarn, - }, - }]; diff --git a/libraries/botbuilder-dialogs/package.json b/libraries/botbuilder-dialogs/package.json index 7e996fa365..23ded5b613 100644 --- a/libraries/botbuilder-dialogs/package.json +++ b/libraries/botbuilder-dialogs/package.json @@ -50,7 +50,7 @@ "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": "npm-run-all build test:mocha", "test:mocha": "nyc mocha --recursive --require source-map-support/register tests", diff --git a/libraries/botbuilder-dialogs/scripts/gen-cldr-data.js b/libraries/botbuilder-dialogs/scripts/gen-cldr-data.js index 91b65e5a37..007515dcd4 100644 --- a/libraries/botbuilder-dialogs/scripts/gen-cldr-data.js +++ b/libraries/botbuilder-dialogs/scripts/gen-cldr-data.js @@ -61,7 +61,7 @@ async function main() { await exec( process.platform === 'win32' ? 'npm.cmd' : 'npm', ['i', `${cldrDataPackageName}@${cldrDataPackageVersion}`, '--no-save'], - { cwd: tempDirectory, env: process.env } + { cwd: tempDirectory, env: process.env }, ); } catch (err) { plog('Could not install cldr-data'); @@ -88,17 +88,17 @@ async function main() { numbersDirectoryPaths.forEach((v) => { fs.copyFileSync( path.join(cldrDataDirectory, v, numbersFileName), - path.join(vendorDirectory, v, numbersFileName) + path.join(vendorDirectory, v, numbersFileName), ); }); fs.copyFileSync( path.join(cldrDataDirectory, supplementalDirectoryName, likelySubtagsFileName), - path.join(vendorDirectory, supplementalDirectoryName, likelySubtagsFileName) + path.join(vendorDirectory, supplementalDirectoryName, likelySubtagsFileName), ); fs.copyFileSync( path.join(cldrDataDirectory, supplementalDirectoryName, numberingSystemsFileName), - path.join(vendorDirectory, supplementalDirectoryName, numberingSystemsFileName) + path.join(vendorDirectory, supplementalDirectoryName, numberingSystemsFileName), ); } catch (err) { plog('Could not copy files'); diff --git a/libraries/botbuilder-dialogs/src/choices/choiceFactory.ts b/libraries/botbuilder-dialogs/src/choices/choiceFactory.ts index 83b48eb11f..4b6aa44924 100644 --- a/libraries/botbuilder-dialogs/src/choices/choiceFactory.ts +++ b/libraries/botbuilder-dialogs/src/choices/choiceFactory.ts @@ -96,7 +96,7 @@ export class ChoiceFactory { choices: (string | Choice)[], text?: string, speak?: string, - options?: ChoiceFactoryOptions + options?: ChoiceFactoryOptions, ): Partial { const channelId: string = typeof channelOrContext === 'string' ? channelOrContext : channel.getChannelId(channelOrContext); @@ -150,7 +150,7 @@ export class ChoiceFactory { title: choice.value, type: ActionTypes.ImBack, value: choice.value, - } as CardAction) + }) as CardAction, ); const attachment = CardFactory.heroCard(undefined, text, undefined, buttons); @@ -178,7 +178,7 @@ export class ChoiceFactory { choices: (string | Choice)[], text?: string, speak?: string, - options?: ChoiceFactoryOptions + options?: ChoiceFactoryOptions, ): Partial { const opt: ChoiceFactoryOptions = { inlineSeparator: ', ', @@ -229,7 +229,7 @@ export class ChoiceFactory { choices: (string | Choice)[], text?: string, speak?: string, - options?: ChoiceFactoryOptions + options?: ChoiceFactoryOptions, ): Partial { const opt: ChoiceFactoryOptions = { includeNumbers: true, diff --git a/libraries/botbuilder-dialogs/src/choices/findChoices.ts b/libraries/botbuilder-dialogs/src/choices/findChoices.ts index 3ec634968c..a62193a12f 100644 --- a/libraries/botbuilder-dialogs/src/choices/findChoices.ts +++ b/libraries/botbuilder-dialogs/src/choices/findChoices.ts @@ -135,13 +135,13 @@ export interface FoundChoice { export function findChoices( utterance: string, choices: (string | Choice)[], - options?: FindChoicesOptions + options?: FindChoicesOptions, ): ModelResult[] { const opt: FindChoicesOptions = options || {}; // Normalize choices const list: Choice[] = (choices || []).map((choice: Choice) => - typeof choice === 'string' ? { value: choice } : choice + typeof choice === 'string' ? { value: choice } : choice, ); // Build up full list of synonyms to search over. diff --git a/libraries/botbuilder-dialogs/src/choices/findValues.ts b/libraries/botbuilder-dialogs/src/choices/findValues.ts index 48786bf5d6..404662dfdd 100644 --- a/libraries/botbuilder-dialogs/src/choices/findValues.ts +++ b/libraries/botbuilder-dialogs/src/choices/findValues.ts @@ -88,7 +88,7 @@ export interface SortedValue { export function findValues( utterance: string, values: SortedValue[], - options?: FindValuesOptions + options?: FindValuesOptions, ): ModelResult[] { function indexOfToken(token: Token, startPos: number): number { for (let i: number = startPos; i < tokens.length; i++) { @@ -126,7 +126,7 @@ export function findValues( index: number, value: string, vTokens: Token[], - startPos: number + startPos: number, ): ModelResult | undefined { // Match value to utterance and calculate total deviation. // - The tokens are matched in order so "second last" will match in @@ -223,7 +223,7 @@ export function findValues( // Sort matches by score descending matches = matches.sort( - (a: ModelResult, b: ModelResult) => b.resolution.score - a.resolution.score + (a: ModelResult, b: ModelResult) => b.resolution.score - a.resolution.score, ); // Filter out duplicate matching indexes and overlapping characters. diff --git a/libraries/botbuilder-dialogs/src/choices/recognizeChoices.ts b/libraries/botbuilder-dialogs/src/choices/recognizeChoices.ts index ad0a7b42b3..f41c31505f 100644 --- a/libraries/botbuilder-dialogs/src/choices/recognizeChoices.ts +++ b/libraries/botbuilder-dialogs/src/choices/recognizeChoices.ts @@ -45,7 +45,7 @@ import { ModelResult } from './modelResult'; export function recognizeChoices( utterance: string, choices: (string | Choice)[], - options?: FindChoicesOptions + options?: FindChoicesOptions, ): ModelResult[] { function matchChoiceByIndex(match: ModelResult): void { try { @@ -77,14 +77,14 @@ export function recognizeChoices( recognizeNumbers: true, recognizeOrdinals: true, } as FindChoicesOptions, - options + options, ); // Normalize choices const list: Choice[] = (choices || []) .map((choice: Choice) => (typeof choice === 'string' ? { value: choice } : choice)) .filter( - (choice: Choice) => choice // TODO: does this do anything? + (choice: Choice) => choice, // TODO: does this do anything? ); // Try finding choices by text search first diff --git a/libraries/botbuilder-dialogs/src/dialogContext.ts b/libraries/botbuilder-dialogs/src/dialogContext.ts index ad936922ea..fcd151fe65 100644 --- a/libraries/botbuilder-dialogs/src/dialogContext.ts +++ b/libraries/botbuilder-dialogs/src/dialogContext.ts @@ -247,7 +247,7 @@ export class DialogContext { if (!dialog) { throw new DialogContextError( `DialogContext.beginDialog(): A dialog with an id of '${dialogId}' wasn't found.`, - this + this, ); } @@ -360,7 +360,7 @@ export class DialogContext { */ async prompt( dialogId: string, - promptOrOptions: string | Partial | PromptOptions + promptOrOptions: string | Partial | PromptOptions, ): Promise; /** @@ -383,7 +383,7 @@ export class DialogContext { async prompt( dialogId: string, promptOrOptions: string | Partial | PromptOptions, - choices: (string | Choice)[] + choices: (string | Choice)[], ): Promise; /** @@ -405,7 +405,7 @@ export class DialogContext { async prompt( dialogId: string, promptOrOptions: string | Partial, - choices?: (string | Choice)[] + choices?: (string | Choice)[], ): Promise { let options: PromptOptions; if ( @@ -466,7 +466,7 @@ export class DialogContext { if (!dialog) { throw new DialogContextError( `DialogContext.continueDialog(): Can't continue dialog. A dialog with an id of '${instance.id}' wasn't found.`, - this + this, ); } @@ -520,7 +520,7 @@ export class DialogContext { if (!dialog) { throw new DialogContextError( `DialogContext.endDialog(): Can't resume previous dialog. A dialog with an id of '${instance.id}' wasn't found.`, - this + this, ); } @@ -582,7 +582,7 @@ export class DialogContext { if (!dialog) { throw new DialogContextError( `DialogContext.repromptDialog(): Can't find a dialog with an id of '${instance.id}'.`, - this + this, ); } @@ -615,7 +615,6 @@ export class DialogContext { // eslint-disable-next-line @typescript-eslint/no-this-alias let dc: DialogContext = this; if (fromLeaf) { - // eslint-disable-next-line no-constant-condition while (true) { const childDc = dc.child; if (childDc != undefined) { diff --git a/libraries/botbuilder-dialogs/src/dialogContextError.ts b/libraries/botbuilder-dialogs/src/dialogContextError.ts index 279f6bafff..13acdf18af 100644 --- a/libraries/botbuilder-dialogs/src/dialogContextError.ts +++ b/libraries/botbuilder-dialogs/src/dialogContextError.ts @@ -24,7 +24,10 @@ export class DialogContextError extends Error { * @param {Error | string} error Source error or error message. * @param {DialogContext} dialogContext Dialog context that is the source of the error. */ - constructor(public readonly error: Error | string, dialogContext: DialogContext) { + constructor( + readonly error: Error | string, + dialogContext: DialogContext, + ) { super(); if (!(error instanceof Error) && typeof error !== 'string') { diff --git a/libraries/botbuilder-dialogs/src/dialogHelper.ts b/libraries/botbuilder-dialogs/src/dialogHelper.ts index 962d23b363..5724f6d70f 100644 --- a/libraries/botbuilder-dialogs/src/dialogHelper.ts +++ b/libraries/botbuilder-dialogs/src/dialogHelper.ts @@ -36,7 +36,7 @@ import { export async function runDialog( dialog: Dialog, context: TurnContext, - accessor: StatePropertyAccessor + accessor: StatePropertyAccessor, ): Promise { if (!dialog) { throw new Error('runDialog(): missing dialog'); @@ -76,7 +76,7 @@ export async function internalRun( context: TurnContext, dialogId: string, dialogContext: DialogContext, - dialogStateManagerConfiguration?: DialogStateManagerConfiguration + dialogStateManagerConfiguration?: DialogStateManagerConfiguration, ): Promise { // map TurnState into root dialog context.services context.turnState.forEach((service, key) => { @@ -122,7 +122,7 @@ export async function internalRun( async function innerRun( context: TurnContext, dialogId: string, - dialogContext: DialogContext + dialogContext: DialogContext, ): Promise { // Handle EoC and Reprompt event from a parent bot (can be root bot to skill or skill to skill) if (isFromParentToSkill(context)) { @@ -197,9 +197,8 @@ export function shouldSendEndOfConversationToParent(context: TurnContext, turnRe if (claimIdentity && SkillValidation.isSkillClaim(claimIdentity.claims)) { // EoC Activities returned by skills are bounced back to the bot by SkillHandler. // In those cases we will have a SkillConversationReference instance in state. - const skillConversationReference: SkillConversationReference = context.turnState.get( - SkillConversationReferenceKey - ); + const skillConversationReference: SkillConversationReference = + context.turnState.get(SkillConversationReferenceKey); if (skillConversationReference) { // If the skillConversationReference.OAuthScope is for one of the supported channels, we are at the root and we should not send an EoC. return ( @@ -259,7 +258,7 @@ const sendStateSnapshotTrace = async (dialogContext: DialogContext): Promise { + if (typeof (dialog as any as DialogDependencies).getDependencies == 'function') { + (dialog as any as DialogDependencies).getDependencies().forEach((child: Dialog): void => { this.add(child); }); } @@ -184,7 +184,7 @@ export class DialogSet { async createContext(context: TurnContext): Promise { if (!this.dialogState) { throw new Error( - 'DialogSet.createContext(): the dialog set was not bound to a stateProperty when constructed.' + 'DialogSet.createContext(): the dialog set was not bound to a stateProperty when constructed.', ); } const state: DialogState = await this.dialogState.get(context, { dialogStack: [] } as DialogState); diff --git a/libraries/botbuilder-dialogs/src/dialogsBotComponent.ts b/libraries/botbuilder-dialogs/src/dialogsBotComponent.ts index d4766f6ff6..776103a0bd 100644 --- a/libraries/botbuilder-dialogs/src/dialogsBotComponent.ts +++ b/libraries/botbuilder-dialogs/src/dialogsBotComponent.ts @@ -51,7 +51,7 @@ export class DialogsBotComponent extends BotComponent { new ClassMemoryScope(), new ThisMemoryScope(), new ConversationMemoryScope(), - new UserMemoryScope() + new UserMemoryScope(), ); }); @@ -61,8 +61,8 @@ export class DialogsBotComponent extends BotComponent { new HashPathResolver(), new AtAtPathResolver(), new AtPathResolver(), - new PercentPathResolver() - ) + new PercentPathResolver(), + ), ); } } diff --git a/libraries/botbuilder-dialogs/src/dialogsComponentRegistration.ts b/libraries/botbuilder-dialogs/src/dialogsComponentRegistration.ts index 5be3de209a..d51d17af92 100644 --- a/libraries/botbuilder-dialogs/src/dialogsComponentRegistration.ts +++ b/libraries/botbuilder-dialogs/src/dialogsComponentRegistration.ts @@ -16,7 +16,8 @@ import { ComponentMemoryScopes, ComponentPathResolvers, MemoryScope, PathResolve */ export class DialogsComponentRegistration extends ComponentRegistration - implements ComponentMemoryScopes, ComponentPathResolvers { + implements ComponentMemoryScopes, ComponentPathResolvers +{ private readonly services = new ServiceCollection({ memoryScopes: [], pathResolvers: [], diff --git a/libraries/botbuilder-dialogs/src/i18n.ts b/libraries/botbuilder-dialogs/src/i18n.ts index 745030a1fc..053e4239e5 100644 --- a/libraries/botbuilder-dialogs/src/i18n.ts +++ b/libraries/botbuilder-dialogs/src/i18n.ts @@ -6,7 +6,7 @@ * Licensed under the MIT License. */ -/* eslint-disable @typescript-eslint/no-var-requires */ +/* eslint-disable @typescript-eslint/no-require-imports */ const Chinese = require('../vendor/cldr-data/main/zh/numbers.json'); const English = require('../vendor/cldr-data/main/en/numbers.json'); const French = require('../vendor/cldr-data/main/fr/numbers.json'); diff --git a/libraries/botbuilder-dialogs/src/memory/componentPathResolvers.ts b/libraries/botbuilder-dialogs/src/memory/componentPathResolvers.ts index 11ff2f48ce..c57a823f96 100644 --- a/libraries/botbuilder-dialogs/src/memory/componentPathResolvers.ts +++ b/libraries/botbuilder-dialogs/src/memory/componentPathResolvers.ts @@ -18,7 +18,7 @@ export interface ComponentPathResolvers { const componentPathResolvers = z.custom( (val: any) => typeof val.getPathResolvers === 'function', - { message: 'ComponentPathResolvers' } + { message: 'ComponentPathResolvers' }, ); /** diff --git a/libraries/botbuilder-dialogs/src/memory/dialogStateManager.ts b/libraries/botbuilder-dialogs/src/memory/dialogStateManager.ts index a8dece5407..f061155e01 100644 --- a/libraries/botbuilder-dialogs/src/memory/dialogStateManager.ts +++ b/libraries/botbuilder-dialogs/src/memory/dialogStateManager.ts @@ -106,7 +106,7 @@ export class DialogStateManager { */ getValue(pathExpression: string, defaultValue?: T | (() => T)): T { function returnDefault(): T { - return typeof defaultValue == 'function' ? (defaultValue as Function)() : defaultValue; + return typeof defaultValue == 'function' ? (defaultValue as () => T)() : defaultValue; } // Get path segments @@ -119,7 +119,7 @@ export class DialogStateManager { const scope = this.getMemoryScope(segments[0].toString()); if (scope == undefined) { console.warn( - `DialogStateManager.getValue: a scope of '${segments[0]}' wasn't found for '${pathExpression}'.` + `DialogStateManager.getValue: a scope of '${segments[0]}' wasn't found for '${pathExpression}'.`, ); return returnDefault(); } @@ -170,7 +170,7 @@ export class DialogStateManager { // Only allow positive indexes if (key < 0) { throw new Error( - `DialogStateManager.setValue: unable to update value for '${pathExpression}'. Negative indexes aren't allowed.` + `DialogStateManager.setValue: unable to update value for '${pathExpression}'. Negative indexes aren't allowed.`, ); } @@ -386,7 +386,7 @@ export class DialogStateManager { segment += c; } else { throw new Error( - `DialogStateManager.normalizePath: Invalid path detected - ${pathExpression}` + `DialogStateManager.normalizePath: Invalid path detected - ${pathExpression}`, ); } break; diff --git a/libraries/botbuilder-dialogs/src/memory/scopes/settingsMemoryScope.ts b/libraries/botbuilder-dialogs/src/memory/scopes/settingsMemoryScope.ts index aa99e6a07b..4a0b2079bc 100644 --- a/libraries/botbuilder-dialogs/src/memory/scopes/settingsMemoryScope.ts +++ b/libraries/botbuilder-dialogs/src/memory/scopes/settingsMemoryScope.ts @@ -114,7 +114,7 @@ export class SettingsMemoryScope extends MemoryScope { const root = this.convertFlattenSettingToNode(Object.entries(configuration)); settings = root.children.reduce( (acc, child) => ({ ...acc, [child.value]: this.convertNodeToObject(child) }), - settings + settings, ); } diff --git a/libraries/botbuilder-dialogs/src/prompts/activityPrompt.ts b/libraries/botbuilder-dialogs/src/prompts/activityPrompt.ts index 7243c20cd8..ef9ab4cadd 100644 --- a/libraries/botbuilder-dialogs/src/prompts/activityPrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/activityPrompt.ts @@ -25,7 +25,10 @@ export class ActivityPrompt extends Dialog { * @param dialogId Unique ID of the dialog within its parent `DialogSet` or `ComponentDialog`. * @param validator Validator that will be called each time a new activity is received. */ - constructor(dialogId: string, private validator: PromptValidator) { + constructor( + dialogId: string, + private validator: PromptValidator, + ) { super(dialogId); } @@ -80,7 +83,7 @@ export class ActivityPrompt extends Dialog { const recognized: PromptRecognizerResult = await this.onRecognize( dc.context, state.state, - state.options + state.options, ); if (state.state['attemptCount'] === undefined) { @@ -162,7 +165,7 @@ export class ActivityPrompt extends Dialog { context: TurnContext, state: object, options: PromptOptions, - isRetry: boolean + isRetry: boolean, ): Promise { if (isRetry && options.retryPrompt) { await context.sendActivity(options.retryPrompt, undefined, InputHints.ExpectingInput); @@ -184,7 +187,7 @@ export class ActivityPrompt extends Dialog { protected async onRecognize( context: TurnContext, _state: object, - _options: PromptOptions + _options: PromptOptions, ): Promise> { return { succeeded: true, value: context.activity }; } diff --git a/libraries/botbuilder-dialogs/src/prompts/attachmentPrompt.ts b/libraries/botbuilder-dialogs/src/prompts/attachmentPrompt.ts index 1ef43b03d3..5a3ec97812 100644 --- a/libraries/botbuilder-dialogs/src/prompts/attachmentPrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/attachmentPrompt.ts @@ -40,7 +40,7 @@ export class AttachmentPrompt extends Prompt { context: TurnContext, state: any, options: PromptOptions, - isRetry: boolean + isRetry: boolean, ): Promise { if (isRetry && options.retryPrompt) { await context.sendActivity(options.retryPrompt, undefined, InputHints.ExpectingInput); @@ -61,7 +61,7 @@ export class AttachmentPrompt extends Prompt { protected async onRecognize( context: TurnContext, _state: any, - _options: PromptOptions + _options: PromptOptions, ): Promise> { const value: Attachment[] = context.activity.attachments; diff --git a/libraries/botbuilder-dialogs/src/prompts/choicePrompt.ts b/libraries/botbuilder-dialogs/src/prompts/choicePrompt.ts index 66864e96cc..2d1e3d5700 100644 --- a/libraries/botbuilder-dialogs/src/prompts/choicePrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/choicePrompt.ts @@ -66,7 +66,7 @@ export class ChoicePrompt extends Prompt { dialogId: string, validator?: PromptValidator, defaultLocale?: string, - choiceDefaults?: ChoiceDefaultsChoicePrompt + choiceDefaults?: ChoiceDefaultsChoicePrompt, ) { super(dialogId, validator); this.style = ListStyle.auto; @@ -104,7 +104,7 @@ export class ChoicePrompt extends Prompt { context: TurnContext, state: any, options: PromptOptions, - isRetry: boolean + isRetry: boolean, ): Promise { // Determine locale const locale = this.determineCulture(context.activity); @@ -140,7 +140,7 @@ export class ChoicePrompt extends Prompt { protected async onRecognize( context: TurnContext, state: any, - options: PromptOptions + options: PromptOptions, ): Promise> { const result: PromptRecognizerResult = { succeeded: false }; const activity = context.activity; @@ -168,7 +168,7 @@ export class ChoicePrompt extends Prompt { private determineCulture(activity: Activity, opt?: FindChoicesOptions): string { const optLocale = opt && opt.locale ? opt.locale : null; let culture = PromptCultureModels.mapToNearestLanguage( - activity.locale || optLocale || this.defaultLocale || PromptCultureModels.English.locale + activity.locale || optLocale || this.defaultLocale || PromptCultureModels.English.locale, ); if (!(culture && this.choiceDefaults[culture])) { culture = PromptCultureModels.English.locale; diff --git a/libraries/botbuilder-dialogs/src/prompts/confirmPrompt.ts b/libraries/botbuilder-dialogs/src/prompts/confirmPrompt.ts index 79ff6d6fc4..c41d991aa6 100644 --- a/libraries/botbuilder-dialogs/src/prompts/confirmPrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/confirmPrompt.ts @@ -66,7 +66,7 @@ export class ConfirmPrompt extends Prompt { dialogId: string, validator?: PromptValidator, defaultLocale?: string, - choiceDefaults?: ChoiceDefaultsConfirmPrompt + choiceDefaults?: ChoiceDefaultsConfirmPrompt, ) { super(dialogId, validator); this.style = ListStyle.auto; @@ -107,7 +107,7 @@ export class ConfirmPrompt extends Prompt { context: TurnContext, state: any, options: PromptOptions, - isRetry: boolean + isRetry: boolean, ): Promise { // Format prompt to send let prompt: Partial; @@ -138,7 +138,7 @@ export class ConfirmPrompt extends Prompt { protected async onRecognize( context: TurnContext, _state, - _options: PromptOptions + _options: PromptOptions, ): Promise> { const result: PromptRecognizerResult = { succeeded: false }; const activity = context.activity; @@ -174,7 +174,7 @@ export class ConfirmPrompt extends Prompt { */ private determineCulture(activity: Activity): string { let culture = PromptCultureModels.mapToNearestLanguage( - activity.locale || this.defaultLocale || PromptCultureModels.English.locale + activity.locale || this.defaultLocale || PromptCultureModels.English.locale, ); if (!(culture && this.choiceDefaults[culture])) { culture = PromptCultureModels.English.locale; diff --git a/libraries/botbuilder-dialogs/src/prompts/datetimePrompt.ts b/libraries/botbuilder-dialogs/src/prompts/datetimePrompt.ts index 20f080c9f9..ef8738b69c 100644 --- a/libraries/botbuilder-dialogs/src/prompts/datetimePrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/datetimePrompt.ts @@ -71,7 +71,7 @@ export class DateTimePrompt extends Prompt { context: TurnContext, state: any, options: PromptOptions, - isRetry: boolean + isRetry: boolean, ): Promise { if (isRetry && options.retryPrompt) { await context.sendActivity(options.retryPrompt, undefined, InputHints.ExpectingInput); @@ -93,7 +93,7 @@ export class DateTimePrompt extends Prompt { protected async onRecognize( context: TurnContext, _state: any, - _options: PromptOptions + _options: PromptOptions, ): Promise> { const result: PromptRecognizerResult = { succeeded: false }; const activity: Activity = context.activity; diff --git a/libraries/botbuilder-dialogs/src/prompts/numberPrompt.ts b/libraries/botbuilder-dialogs/src/prompts/numberPrompt.ts index 14438c0746..f91ab42e66 100644 --- a/libraries/botbuilder-dialogs/src/prompts/numberPrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/numberPrompt.ts @@ -6,9 +6,9 @@ * Licensed under the MIT License. */ -/* eslint-disable @typescript-eslint/no-var-requires */ +/* eslint-disable-next-line @typescript-eslint/no-require-imports */ const Globalize = require('globalize'); -import Recognizers from '@microsoft/recognizers-text-number'; +import { recognizeNumber } from '@microsoft/recognizers-text-number'; import * as locales from '../i18n'; import { InputHints, TurnContext } from 'botbuilder-core'; import { Prompt, PromptOptions, PromptRecognizerResult, PromptValidator } from './prompt'; @@ -56,7 +56,7 @@ export class NumberPrompt extends Prompt { context: TurnContext, state: unknown, options: PromptOptions, - isRetry: boolean + isRetry: boolean, ): Promise { if (isRetry && options.retryPrompt) { await context.sendActivity(options.retryPrompt, undefined, InputHints.ExpectingInput); @@ -78,7 +78,7 @@ export class NumberPrompt extends Prompt { protected async onRecognize( context: TurnContext, _state: unknown, - _options: PromptOptions + _options: PromptOptions, ): Promise> { const result: PromptRecognizerResult = { succeeded: false }; const activity = context.activity; @@ -91,7 +91,7 @@ export class NumberPrompt extends Prompt { const defaultLocale = this.defaultLocale || 'en-us'; const locale = activity.locale || defaultLocale; - const [{ resolution = null } = {}] = Recognizers.recognizeNumber(utterance, locale) || []; + const [{ resolution = null } = {}] = recognizeNumber(utterance, locale) || []; if (resolution) { result.succeeded = true; diff --git a/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts b/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts index 8360a3379e..c2fd2db8b6 100644 --- a/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts @@ -171,7 +171,7 @@ export class OAuthPrompt extends Dialog { constructor( dialogId: string, private settings: OAuthPromptSettings, - private validator?: PromptValidator + private validator?: PromptValidator, ) { super(dialogId); } @@ -326,7 +326,7 @@ export class OAuthPrompt extends Dialog { static async sendOAuthCard( settings: OAuthPromptSettings, turnContext: TurnContext, - prompt?: string | Partial + prompt?: string | Partial, ): Promise { // Initialize outgoing message const msg: Partial = @@ -377,7 +377,7 @@ export class OAuthPrompt extends Dialog { settings.text, link, signInResource.tokenExchangeResource, - signInResource.tokenPostResource + signInResource.tokenPostResource, ); // Set the appropriate ActionType for the button. @@ -425,7 +425,7 @@ export class OAuthPrompt extends Dialog { context, context.activity.serviceUrl, claimsIdentity, - state.scope + state.scope, ); context.turnState.set(context.adapter.ConnectorClientKey, connectorClient); @@ -450,8 +450,8 @@ export class OAuthPrompt extends Dialog { await context.sendActivity( this.getTokenExchangeInvokeResponse( StatusCodes.BAD_REQUEST, - 'The bot received an InvokeActivity that is missing a TokenExchangeInvokeRequest value. This is required to be sent with the InvokeActivity.' - ) + 'The bot received an InvokeActivity that is missing a TokenExchangeInvokeRequest value. This is required to be sent with the InvokeActivity.', + ), ); } else if (context.activity.value.connectionName != this.settings.connectionName) { // Connection name on activity does not match that of setting @@ -459,8 +459,8 @@ export class OAuthPrompt extends Dialog { this.getTokenExchangeInvokeResponse( StatusCodes.BAD_REQUEST, 'The bot received an InvokeActivity with a TokenExchangeInvokeRequest containing a ConnectionName that does not match the ConnectionName' + - 'expected by the bots active OAuthPrompt. Ensure these names match when sending the InvokeActivityInvalid ConnectionName in the TokenExchangeInvokeRequest' - ) + 'expected by the bots active OAuthPrompt. Ensure these names match when sending the InvokeActivityInvalid ConnectionName in the TokenExchangeInvokeRequest', + ), ); } else { let tokenExchangeResponse: TokenResponse; @@ -478,12 +478,12 @@ export class OAuthPrompt extends Dialog { await context.sendActivity( this.getTokenExchangeInvokeResponse( StatusCodes.PRECONDITION_FAILED, - 'The bot is unable to exchange token. Proceed with regular login.' - ) + 'The bot is unable to exchange token. Proceed with regular login.', + ), ); } else { await context.sendActivity( - this.getTokenExchangeInvokeResponse(StatusCodes.OK, null, context.activity.value.id) + this.getTokenExchangeInvokeResponse(StatusCodes.OK, null, context.activity.value.id), ); token = { channelId: tokenExchangeResponse.channelId, diff --git a/libraries/botbuilder-dialogs/src/prompts/prompt.ts b/libraries/botbuilder-dialogs/src/prompts/prompt.ts index d8a276a7fe..8926a9920a 100644 --- a/libraries/botbuilder-dialogs/src/prompts/prompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/prompt.ts @@ -179,7 +179,10 @@ export abstract class Prompt extends Dialog { * @param dialogId Unique ID of the prompt within its parent `DialogSet` or `ComponentDialog`. * @param validator (Optional) custom validator used to provide additional validation and re-prompting logic for the prompt. */ - protected constructor(dialogId: string, private validator?: PromptValidator) { + protected constructor( + dialogId: string, + private validator?: PromptValidator, + ) { super(dialogId); } @@ -294,7 +297,7 @@ export abstract class Prompt extends Dialog { const recognized: PromptRecognizerResult = await this.onRecognize( dc.context, state.state, - state.options + state.options, ); return recognized.succeeded; } @@ -352,7 +355,7 @@ export abstract class Prompt extends Dialog { context: TurnContext, state: object, options: PromptOptions, - isRetry: boolean + isRetry: boolean, ): Promise; /** @@ -368,7 +371,7 @@ export abstract class Prompt extends Dialog { protected abstract onRecognize( context: TurnContext, state: object, - options: PromptOptions + options: PromptOptions, ): Promise>; /** @@ -386,7 +389,7 @@ export abstract class Prompt extends Dialog { channelId: string, choices: (string | Choice)[], style: ListStyle, - options?: ChoiceFactoryOptions + options?: ChoiceFactoryOptions, ): Partial { // Get base prompt text (if any) let text = ''; diff --git a/libraries/botbuilder-dialogs/src/prompts/textPrompt.ts b/libraries/botbuilder-dialogs/src/prompts/textPrompt.ts index 2de237d3fc..fd47eba6c4 100644 --- a/libraries/botbuilder-dialogs/src/prompts/textPrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/textPrompt.ts @@ -43,7 +43,7 @@ export class TextPrompt extends Prompt { context: TurnContext, state: any, options: PromptOptions, - isRetry: boolean + isRetry: boolean, ): Promise { if (isRetry && options.retryPrompt) { await context.sendActivity(options.retryPrompt, undefined, InputHints.ExpectingInput); @@ -65,7 +65,7 @@ export class TextPrompt extends Prompt { protected async onRecognize( context: TurnContext, _state: any, - _options: PromptOptions + _options: PromptOptions, ): Promise> { const value: string = context.activity.text; diff --git a/libraries/botbuilder-dialogs/src/prompts/userTokenAccess.ts b/libraries/botbuilder-dialogs/src/prompts/userTokenAccess.ts index 3aeebc8af2..4b938a8983 100644 --- a/libraries/botbuilder-dialogs/src/prompts/userTokenAccess.ts +++ b/libraries/botbuilder-dialogs/src/prompts/userTokenAccess.ts @@ -15,7 +15,6 @@ import { } from 'botframework-connector'; const ExtendedUserTokenProviderT = z.custom( - // eslint-disable-next-line @typescript-eslint/no-explicit-any (val: any) => typeof val.exchangeToken === 'function' && typeof val.getSignInResource === 'function' && @@ -23,23 +22,22 @@ const ExtendedUserTokenProviderT = z.custom( typeof val.signOutUser === 'function', { message: 'ExtendedUserTokenProvider', - } + }, ); type ConnectorClientBuilder = { createConnectorClientWithIdentity: ( serviceUrl: string, claimsIdentity: ClaimsIdentity, - audience: string + audience: string, ) => Promise; }; const ConnectorClientBuilderT = z.custom( - // eslint-disable-next-line @typescript-eslint/no-explicit-any (val: any) => typeof val.createConnectorClientWithIdentity === 'function', { message: 'ConnectorClientBuilder', - } + }, ); /** @@ -48,10 +46,10 @@ const ConnectorClientBuilderT = z.custom( export async function getUserToken( context: TurnContext, settings: OAuthPromptSettings, - magicCode: string + magicCode: string, ): Promise { const userTokenClient = context.turnState.get( - (context.adapter as CloudAdapterBase).UserTokenClientKey + (context.adapter as CloudAdapterBase).UserTokenClientKey, ); const extendedUserTokenProvider = ExtendedUserTokenProviderT.safeParse(context.adapter); @@ -60,14 +58,14 @@ export async function getUserToken( context.activity?.from?.id, settings.connectionName, context.activity?.channelId, - magicCode + magicCode, ); } else if (extendedUserTokenProvider.success) { return extendedUserTokenProvider.data.getUserToken( context, settings.connectionName, magicCode, - settings.oAuthAppCredentials + settings.oAuthAppCredentials, ); } else { throw new Error('OAuth prompt is not supported by the current adapter'); @@ -79,10 +77,10 @@ export async function getUserToken( */ export async function getSignInResource( context: TurnContext, - settings: OAuthPromptSettings + settings: OAuthPromptSettings, ): Promise { const userTokenClient = context.turnState.get( - (context.adapter as CloudAdapterBase).UserTokenClientKey + (context.adapter as CloudAdapterBase).UserTokenClientKey, ); const extendedUserTokenProvider = ExtendedUserTokenProviderT.safeParse(context.adapter); if (userTokenClient) { @@ -93,7 +91,7 @@ export async function getSignInResource( settings.connectionName, context.activity?.from?.id, undefined, - settings.oAuthAppCredentials + settings.oAuthAppCredentials, ); } else { throw new Error('OAuth prompt is not supported by the current adapter'); @@ -105,21 +103,21 @@ export async function getSignInResource( */ export async function signOutUser(context: TurnContext, settings: OAuthPromptSettings): Promise { const userTokenClient = context.turnState.get( - (context.adapter as CloudAdapterBase).UserTokenClientKey + (context.adapter as CloudAdapterBase).UserTokenClientKey, ); const extendedUserTokenProvider = ExtendedUserTokenProviderT.safeParse(context.adapter); if (userTokenClient) { await userTokenClient.signOutUser( context.activity?.from?.id, settings.connectionName, - context.activity?.channelId + context.activity?.channelId, ); } else if (extendedUserTokenProvider.success) { await extendedUserTokenProvider.data.signOutUser( context, settings.connectionName, context.activity?.from?.id, - settings.oAuthAppCredentials + settings.oAuthAppCredentials, ); } else { throw new Error('OAuth prompt is not supported by the current adapter'); @@ -132,10 +130,10 @@ export async function signOutUser(context: TurnContext, settings: OAuthPromptSet export async function exchangeToken( context: TurnContext, settings: OAuthPromptSettings, - tokenExchangeRequest: TokenExchangeRequest + tokenExchangeRequest: TokenExchangeRequest, ): Promise { const userTokenClient = context.turnState.get( - (context.adapter as CloudAdapterBase).UserTokenClientKey + (context.adapter as CloudAdapterBase).UserTokenClientKey, ); const extendedUserTokenProvider = ExtendedUserTokenProviderT.safeParse(context.adapter); @@ -144,14 +142,14 @@ export async function exchangeToken( context.activity?.from?.id, settings.connectionName, context.activity?.channelId, - tokenExchangeRequest + tokenExchangeRequest, ); } else if (extendedUserTokenProvider.success) { return extendedUserTokenProvider.data.exchangeToken( context, settings.connectionName, context.activity?.from?.id, - tokenExchangeRequest + tokenExchangeRequest, ); } else { throw new Error('OAuth prompt is not supported by the current adapter'); @@ -165,10 +163,10 @@ export async function createConnectorClient( context: TurnContext, serviceUrl: string, claimsIdentity: ClaimsIdentity, - audience: string + audience: string, ): Promise { const connectorFactory = context.turnState.get( - (context.adapter as CloudAdapterBase).ConnectorFactoryKey + (context.adapter as CloudAdapterBase).ConnectorFactoryKey, ); const connectorClientBuilder = ConnectorClientBuilderT.safeParse(context.adapter); if (connectorFactory) { diff --git a/libraries/botbuilder-dialogs/src/recognizer.ts b/libraries/botbuilder-dialogs/src/recognizer.ts index 6e28043276..f613acf02e 100644 --- a/libraries/botbuilder-dialogs/src/recognizer.ts +++ b/libraries/botbuilder-dialogs/src/recognizer.ts @@ -17,7 +17,7 @@ import { import { Configurable } from './configurable'; import { DialogContext } from './dialogContext'; import { DialogTurnStateConstants } from './dialogTurnStateConstants'; -import omit = require('lodash/omit'); +import omit from 'lodash/omit'; export interface RecognizerConfiguration { id?: string; @@ -51,7 +51,7 @@ export class Recognizer extends Configurable implements RecognizerConfiguration _dialogContext: DialogContext, _activity: Partial, _telemetryProperties?: Record, - _telemetryMetrics?: Record + _telemetryMetrics?: Record, ): Promise { throw new Error('Please implement recognize function.'); } @@ -113,7 +113,7 @@ export class Recognizer extends Configurable implements RecognizerConfiguration protected fillRecognizerResultTelemetryProperties( recognizerResult: RecognizerResult, telemetryProperties: Record, - _dialogContext?: DialogContext + _dialogContext?: DialogContext, ): Record { const { intent, score } = getTopScoringIntent(recognizerResult); const intents = Object.entries(recognizerResult.intents); @@ -126,7 +126,7 @@ export class Recognizer extends Configurable implements RecognizerConfiguration Intents: intents.length > 0 ? JSON.stringify(recognizerResult.intents) : undefined, Entities: recognizerResult.entities ? JSON.stringify(recognizerResult.entities) : undefined, AdditionalProperties: JSON.stringify( - omit(recognizerResult, ['text', 'alteredText', 'intents', 'entities']) + omit(recognizerResult, ['text', 'alteredText', 'intents', 'entities']), ), }; @@ -161,7 +161,7 @@ export class Recognizer extends Configurable implements RecognizerConfiguration dialogContext: DialogContext, eventName: string, telemetryProperties?: Record, - telemetryMetrics?: Record + telemetryMetrics?: Record, ): void { if (this.telemetryClient instanceof NullTelemetryClient) { const turnStateTelemetryClient = diff --git a/libraries/botbuilder-dialogs/src/skillDialog.ts b/libraries/botbuilder-dialogs/src/skillDialog.ts index 8a7cf0ef6d..8395b462af 100644 --- a/libraries/botbuilder-dialogs/src/skillDialog.ts +++ b/libraries/botbuilder-dialogs/src/skillDialog.ts @@ -82,7 +82,7 @@ export class SkillDialog extends Dialog> { const skillActivity = TurnContext.applyConversationReference( clonedActivity, TurnContext.getConversationReference(dc.context.activity), - true + true, ) as Activity; // Store delivery mode and connection name in dialog state for later use. @@ -161,7 +161,7 @@ export class SkillDialog extends Dialog> { const activity = TurnContext.applyConversationReference( { type: ActivityTypes.EndOfConversation }, reference, - true + true, ); activity.channelData = context.activity.channelData; @@ -253,7 +253,7 @@ export class SkillDialog extends Dialog> { private async sendToSkill( context: TurnContext, activity: Activity, - skillConversationId: string + skillConversationId: string, ): Promise { if (activity.type === ActivityTypes.Invoke) { // Force ExpectReplies for invoke activities so we can get the replies right away and send them back to the channel if needed. @@ -272,13 +272,13 @@ export class SkillDialog extends Dialog> { skillInfo.skillEndpoint, this.dialogOptions.skillHostEndpoint, skillConversationId, - activity + activity, ); // Inspect the skill response status if (!isSuccessStatusCode(response.status)) { throw new Error( - `Error invoking the skill id: "${skillInfo.id}" at "${skillInfo.skillEndpoint}" (status is ${response.status}). \r\n ${response.body}` + `Error invoking the skill id: "${skillInfo.id}" at "${skillInfo.skillEndpoint}" (status is ${response.status}). \r\n ${response.body}`, ); } @@ -331,14 +331,14 @@ export class SkillDialog extends Dialog> { private async interceptOAuthCards( context: TurnContext, activity: Activity, - connectionName: string + connectionName: string, ): Promise { if (!connectionName) { return false; } const oAuthCardAttachment: Attachment = (activity.attachments || []).find( - (c) => c.contentType === CardFactory.contentTypes.oauthCard + (c) => c.contentType === CardFactory.contentTypes.oauthCard, ); if (!oAuthCardAttachment) { return false; @@ -382,7 +382,7 @@ export class SkillDialog extends Dialog> { incomingActivity: Activity, id: string, connectionName: string, - token: string + token: string, ): Promise { const ref: Partial = TurnContext.getConversationReference(incomingActivity); const activity: Activity = TurnContext.applyConversationReference({ ...incomingActivity }, ref) as any; @@ -398,7 +398,7 @@ export class SkillDialog extends Dialog> { skillInfo.skillEndpoint, this.dialogOptions.skillHostEndpoint, incomingActivity.conversation.id, - activity + activity, ); // Check response status: true if success, false if failure @@ -423,15 +423,16 @@ export class SkillDialog extends Dialog> { // Create a conversationId to interact with the skill and send the activity let skillConversationId: string; try { - skillConversationId = await this.dialogOptions.conversationIdFactory.createSkillConversationIdWithOptions( - conversationIdFactoryOptions - ); + skillConversationId = + await this.dialogOptions.conversationIdFactory.createSkillConversationIdWithOptions( + conversationIdFactoryOptions, + ); } catch (err) { if (err.message !== 'Not Implemented') throw err; // If the SkillConversationIdFactoryBase implementation doesn't support createSkillConversationIdWithOptions(), // use createSkillConversationId() instead. skillConversationId = await this.dialogOptions.conversationIdFactory.createSkillConversationId( - TurnContext.getConversationReference(activity) as ConversationReference + TurnContext.getConversationReference(activity) as ConversationReference, ); } return skillConversationId; diff --git a/libraries/botbuilder-dialogs/src/waterfallDialog.ts b/libraries/botbuilder-dialogs/src/waterfallDialog.ts index 35774cc91d..1ba66bc5d5 100644 --- a/libraries/botbuilder-dialogs/src/waterfallDialog.ts +++ b/libraries/botbuilder-dialogs/src/waterfallDialog.ts @@ -6,10 +6,10 @@ * Licensed under the MIT License. */ import { v4 as uuidv4 } from 'uuid'; -import { ActivityTypes } from 'botbuilder-core'; -import { TurnContext, telemetryTrackDialogView } from 'botbuilder-core'; -import { DialogInstance } from './dialog'; -import { Dialog, DialogReason, DialogTurnResult } from './dialog'; +import { ActivityTypes, TurnContext, telemetryTrackDialogView } from 'botbuilder-core'; + +import { DialogInstance, Dialog, DialogReason, DialogTurnResult } from './dialog'; + import { DialogContext } from './dialogContext'; import { WaterfallStepContext } from './waterfallStepContext'; @@ -260,7 +260,7 @@ export class WaterfallDialog extends Dialog { dc: DialogContext, index: number, reason: DialogReason, - result?: any + result?: any, ): Promise { if (index < this.steps.length) { // Update persisted step index @@ -278,7 +278,7 @@ export class WaterfallDialog extends Dialog { onNext: async (stepResult?: any): Promise> => { if (nextCalled) { throw new Error( - `WaterfallStepContext.next(): method already called for dialog and step '${this.id}[${index}]'.` + `WaterfallStepContext.next(): method already called for dialog and step '${this.id}[${index}]'.`, ); } nextCalled = true; diff --git a/libraries/botbuilder-dialogs/tests/activityPrompt.test.js b/libraries/botbuilder-dialogs/tests/activityPrompt.test.js index 88a65d8cd2..cffe225c7e 100644 --- a/libraries/botbuilder-dialogs/tests/activityPrompt.test.js +++ b/libraries/botbuilder-dialogs/tests/activityPrompt.test.js @@ -40,7 +40,7 @@ describe('ActivityPrompt', function () { assert(prompt, 'validator missing PromptValidatorContext.'); assert(typeof prompt.recognized.value === 'object', 'recognized.value was not an object.'); return true; - }) + }), ); await adapter @@ -73,7 +73,7 @@ describe('ActivityPrompt', function () { assert(prompt, 'validator missing PromptValidatorContext.'); assert(typeof prompt.recognized.value === 'object', 'recognized.value was not an object.'); return false; - }) + }), ); await adapter @@ -106,7 +106,7 @@ describe('ActivityPrompt', function () { assert(prompt, 'validator missing PromptValidatorContext.'); assert(typeof prompt.recognized.value === 'object', 'recognized.value was not an object.'); return false; - }) + }), ); await adapter @@ -132,7 +132,7 @@ describe('ActivityPrompt', function () { return false; } return true; - }) + }), ); const adapter = new TestAdapter(async (turnContext) => { diff --git a/libraries/botbuilder-dialogs/tests/attachmentPrompt.test.js b/libraries/botbuilder-dialogs/tests/attachmentPrompt.test.js index 50e34880b8..e434150052 100644 --- a/libraries/botbuilder-dialogs/tests/attachmentPrompt.test.js +++ b/libraries/botbuilder-dialogs/tests/attachmentPrompt.test.js @@ -68,7 +68,7 @@ describe('AttachmentPrompt', function () { new AttachmentPrompt('prompt', async (prompt) => { assert(prompt); return prompt.recognized.succeeded; - }) + }), ); await adapter @@ -102,7 +102,7 @@ describe('AttachmentPrompt', function () { new AttachmentPrompt('prompt', async (prompt) => { assert(prompt); return prompt.recognized.succeeded; - }) + }), ); await adapter @@ -142,7 +142,7 @@ describe('AttachmentPrompt', function () { await prompt.context.sendActivity('Bad input.'); } return prompt.recognized.succeeded; - }) + }), ); await adapter diff --git a/libraries/botbuilder-dialogs/tests/choicePrompt.test.js b/libraries/botbuilder-dialogs/tests/choicePrompt.test.js index 95f649a79a..183d06c175 100644 --- a/libraries/botbuilder-dialogs/tests/choicePrompt.test.js +++ b/libraries/botbuilder-dialogs/tests/choicePrompt.test.js @@ -120,7 +120,7 @@ describe('ChoicePrompt', function () { 'Please choose a color.', stringChoices.map((choice) => { return { value: choice, action: {} }; - }) + }), ); } else if (results.status === DialogTurnStatus.complete) { const selectedChoice = results.result; @@ -286,7 +286,7 @@ describe('ChoicePrompt', function () { } return prompt.recognized.succeeded; }, - 'es-es' + 'es-es', ); dialogs.add(choicePrompt); @@ -362,7 +362,7 @@ describe('ChoicePrompt', function () { } return prompt.recognized.succeeded; }, - 'es-es' + 'es-es', ); dialogs.add(choicePrompt); @@ -439,7 +439,7 @@ describe('ChoicePrompt', function () { } return prompt.recognized.succeeded; }, - 'es-es' + 'es-es', ); dialogs.add(choicePrompt); @@ -454,9 +454,9 @@ describe('ChoicePrompt', function () { assert.strictEqual(activity.text, expectedAnswer); }) .startTest(); - }) + }), ); - }) + }), ); }); @@ -489,7 +489,7 @@ describe('ChoicePrompt', function () { } return prompt.recognized.succeeded; }, - null + null, ); dialogs.add(choicePrompt); @@ -504,7 +504,7 @@ describe('ChoicePrompt', function () { assert.strictEqual(activity.text, `Please choose a color.${expectedChoices}`); }) .startTest(); - }) + }), ); }); @@ -553,7 +553,7 @@ describe('ChoicePrompt', function () { return prompt.recognized.succeeded; }, culture.locale, - customDict + customDict, ); dialogs.add(choicePrompt); diff --git a/libraries/botbuilder-dialogs/tests/choices_recognizers.test.js b/libraries/botbuilder-dialogs/tests/choices_recognizers.test.js index 46b88ff686..90258d5fb4 100644 --- a/libraries/botbuilder-dialogs/tests/choices_recognizers.test.js +++ b/libraries/botbuilder-dialogs/tests/choices_recognizers.test.js @@ -26,7 +26,7 @@ function assertChoice(result, value, index, score, synonym) { if (synonym) { assert( resolution.synonym === synonym, - `Invalid resolution.synonym of '${resolution.synonym}' for '${value}' choice.` + `Invalid resolution.synonym of '${resolution.synonym}' for '${value}' choice.`, ); } } @@ -59,152 +59,154 @@ const valuesWithSpecialCharacters = [ { value: 'A ??? B', index: 2 }, ]; -describe('findValues()', function () { - this.timeout(5000); +describe('Choices Recognizers Tests', function () { + describe('findValues()', function () { + this.timeout(5000); - it('should find a simple value in an single word utterance.', function () { - const found = findValues('red', colorValues); - assert(found.length === 1, `Invalid token count of '${found.length}' returned.`); - assertResult(found[0], 0, 2, 'red'); - assertValue(found[0], 'red', 0, 1.0); - }); + it('should find a simple value in an single word utterance.', function () { + const found = findValues('red', colorValues); + assert(found.length === 1, `Invalid token count of '${found.length}' returned.`); + assertResult(found[0], 0, 2, 'red'); + assertValue(found[0], 'red', 0, 1.0); + }); - it('should find a simple value in an utterance.', function () { - const found = findValues('the red one please.', colorValues); - assert(found.length === 1, `Invalid token count of '${found.length}' returned.`); - assertResult(found[0], 4, 6, 'red'); - assertValue(found[0], 'red', 0, 1.0); - }); + it('should find a simple value in an utterance.', function () { + const found = findValues('the red one please.', colorValues); + assert(found.length === 1, `Invalid token count of '${found.length}' returned.`); + assertResult(found[0], 4, 6, 'red'); + assertValue(found[0], 'red', 0, 1.0); + }); - it('should find multiple values within an utterance.', function () { - const found = findValues('the red and blue ones please.', colorValues); - assert(found.length === 2, `Invalid token count of '${found.length}' returned.`); - assertResult(found[0], 4, 6, 'red'); - assertValue(found[0], 'red', 0, 1.0); - assertValue(found[1], 'blue', 2, 1.0); - }); + it('should find multiple values within an utterance.', function () { + const found = findValues('the red and blue ones please.', colorValues); + assert(found.length === 2, `Invalid token count of '${found.length}' returned.`); + assertResult(found[0], 4, 6, 'red'); + assertValue(found[0], 'red', 0, 1.0); + assertValue(found[1], 'blue', 2, 1.0); + }); - it('should find multiple values that overlap.', function () { - const found = findValues('the bread pudding and bread please.', overlappingValues); - assert(found.length === 2, `Invalid token count of '${found.length}' returned.`); - assertResult(found[0], 4, 16, 'bread pudding'); - assertValue(found[0], 'bread pudding', 1, 1.0); - assertValue(found[1], 'bread', 0, 1.0); - }); + it('should find multiple values that overlap.', function () { + const found = findValues('the bread pudding and bread please.', overlappingValues); + assert(found.length === 2, `Invalid token count of '${found.length}' returned.`); + assertResult(found[0], 4, 16, 'bread pudding'); + assertValue(found[0], 'bread pudding', 1, 1.0); + assertValue(found[1], 'bread', 0, 1.0); + }); - it('should correctly disambiguate between very similar values.', function () { - const found = findValues('option B', similarValues, { allowPartialMatches: true }); - assert(found.length === 1, `Invalid token count of '${found.length}' returned.`); - assertValue(found[0], 'option B', 1, 1.0); - }); + it('should correctly disambiguate between very similar values.', function () { + const found = findValues('option B', similarValues, { allowPartialMatches: true }); + assert(found.length === 1, `Invalid token count of '${found.length}' returned.`); + assertValue(found[0], 'option B', 1, 1.0); + }); - it('should prefer exact match.', function () { - const index = 1; - const utterance = valuesWithSpecialCharacters[index].value; - const found = findValues(utterance, valuesWithSpecialCharacters); - assert(found.length === 1, `Invalid token count of '${found.length}' returned.`); - assertValue(found[0], utterance, index, 1); + it('should prefer exact match.', function () { + const index = 1; + const utterance = valuesWithSpecialCharacters[index].value; + const found = findValues(utterance, valuesWithSpecialCharacters); + assert(found.length === 1, `Invalid token count of '${found.length}' returned.`); + assertValue(found[0], utterance, index, 1); + }); }); -}); -//============================================================================= -// findChoices() tests -//============================================================================= + //============================================================================= + // findChoices() tests + //============================================================================= -const colorChoices = ['red', 'green', 'blue']; -const overlappingChoices = ['bread', 'bread pudding', 'pudding']; + const colorChoices = ['red', 'green', 'blue']; + const overlappingChoices = ['bread', 'bread pudding', 'pudding']; -describe('findChoices()', function () { - this.timeout(5000); + describe('findChoices()', function () { + this.timeout(5000); - it('should find a single choice in an utterance.', function () { - const found = findChoices('the red one please.', colorChoices); - assert(found.length === 1, `Invalid token count of '${found.length}' returned.`); - assertResult(found[0], 4, 6, 'red'); - assertChoice(found[0], 'red', 0, 1.0, 'red'); - }); + it('should find a single choice in an utterance.', function () { + const found = findChoices('the red one please.', colorChoices); + assert(found.length === 1, `Invalid token count of '${found.length}' returned.`); + assertResult(found[0], 4, 6, 'red'); + assertChoice(found[0], 'red', 0, 1.0, 'red'); + }); - it('should find multiple choices within an utterance.', function () { - const found = findChoices('the red and blue ones please.', colorChoices); - assert(found.length === 2, `Invalid token count of '${found.length}' returned.`); - assertResult(found[0], 4, 6, 'red'); - assertChoice(found[0], 'red', 0, 1.0); - assertChoice(found[1], 'blue', 2, 1.0); - }); + it('should find multiple choices within an utterance.', function () { + const found = findChoices('the red and blue ones please.', colorChoices); + assert(found.length === 2, `Invalid token count of '${found.length}' returned.`); + assertResult(found[0], 4, 6, 'red'); + assertChoice(found[0], 'red', 0, 1.0); + assertChoice(found[1], 'blue', 2, 1.0); + }); - it('should find multiple choices that overlap.', function () { - const found = findChoices('the bread pudding and bread please.', overlappingChoices); - assert(found.length === 2, `Invalid token count of '${found.length}' returned.`); - assertResult(found[0], 4, 16, 'bread pudding'); - assertChoice(found[0], 'bread pudding', 1, 1.0); - assertChoice(found[1], 'bread', 0, 1.0); + it('should find multiple choices that overlap.', function () { + const found = findChoices('the bread pudding and bread please.', overlappingChoices); + assert(found.length === 2, `Invalid token count of '${found.length}' returned.`); + assertResult(found[0], 4, 16, 'bread pudding'); + assertChoice(found[0], 'bread pudding', 1, 1.0); + assertChoice(found[1], 'bread', 0, 1.0); + }); }); -}); -//============================================================================= -// recognizeChoices() tests -//============================================================================= + //============================================================================= + // recognizeChoices() tests + //============================================================================= -describe('recognizeChoices()', function () { - this.timeout(5000); + describe('recognizeChoices()', function () { + this.timeout(5000); - it('should find a choice in an utterance by name.', function () { - const found = recognizeChoices('the red one please.', colorChoices); - assert(found.length === 1, `Invalid token count of '${found.length}' returned.`); - assertResult(found[0], 4, 6, 'red'); - assertChoice(found[0], 'red', 0, 1.0, 'red'); - }); + it('should find a choice in an utterance by name.', function () { + const found = recognizeChoices('the red one please.', colorChoices); + assert(found.length === 1, `Invalid token count of '${found.length}' returned.`); + assertResult(found[0], 4, 6, 'red'); + assertChoice(found[0], 'red', 0, 1.0, 'red'); + }); - it('should find a choice in an utterance by ordinal position.', function () { - const found = recognizeChoices('the first one please.', colorChoices); - assert(found.length === 1, `Invalid token count of '${found.length}' returned.`); - assertResult(found[0], 4, 8, 'first'); - assertChoice(found[0], 'red', 0, 1.0); - }); + it('should find a choice in an utterance by ordinal position.', function () { + const found = recognizeChoices('the first one please.', colorChoices); + assert(found.length === 1, `Invalid token count of '${found.length}' returned.`); + assertResult(found[0], 4, 8, 'first'); + assertChoice(found[0], 'red', 0, 1.0); + }); - it('should find multiple choices in an utterance by ordinal position.', function () { - const found = recognizeChoices('the first and third one please.', colorChoices); - assert(found.length === 2, `Invalid token count of '${found.length}' returned.`); - assertChoice(found[0], 'red', 0, 1.0); - assertChoice(found[1], 'blue', 2, 1.0); - }); + it('should find multiple choices in an utterance by ordinal position.', function () { + const found = recognizeChoices('the first and third one please.', colorChoices); + assert(found.length === 2, `Invalid token count of '${found.length}' returned.`); + assertChoice(found[0], 'red', 0, 1.0); + assertChoice(found[1], 'blue', 2, 1.0); + }); - it('should find a choice in an utterance by numerical index (as digit.)', function () { - const found = recognizeChoices('1', colorChoices); - assert(found.length === 1, `Invalid token count of '${found.length}' returned.`); - assertResult(found[0], 0, 0, '1'); - assertChoice(found[0], 'red', 0, 1.0); - }); + it('should find a choice in an utterance by numerical index (as digit.)', function () { + const found = recognizeChoices('1', colorChoices); + assert(found.length === 1, `Invalid token count of '${found.length}' returned.`); + assertResult(found[0], 0, 0, '1'); + assertChoice(found[0], 'red', 0, 1.0); + }); - it('should find a choice in an utterance by numerical index (as text.)', function () { - const found = recognizeChoices('one', colorChoices); - assert(found.length === 1, `Invalid token count of '${found.length}' returned.`); - assertResult(found[0], 0, 2, 'one'); - assertChoice(found[0], 'red', 0, 1.0); - }); + it('should find a choice in an utterance by numerical index (as text.)', function () { + const found = recognizeChoices('one', colorChoices); + assert(found.length === 1, `Invalid token count of '${found.length}' returned.`); + assertResult(found[0], 0, 2, 'one'); + assertChoice(found[0], 'red', 0, 1.0); + }); - it('should find multiple choices in an utterance by numerical index.', function () { - const found = recognizeChoices('option one and 3.', colorChoices); - assert(found.length === 2, `Invalid token count of '${found.length}' returned.`); - assertChoice(found[0], 'red', 0, 1.0); - assertChoice(found[1], 'blue', 2, 1.0); - }); + it('should find multiple choices in an utterance by numerical index.', function () { + const found = recognizeChoices('option one and 3.', colorChoices); + assert(found.length === 2, `Invalid token count of '${found.length}' returned.`); + assertChoice(found[0], 'red', 0, 1.0); + assertChoice(found[1], 'blue', 2, 1.0); + }); - it('should not find a choice if recognizeOrdinals option disabled.', function () { - const found = recognizeChoices('first', colorChoices, { recognizeOrdinals: false }); - assert(found.length === 0, `Invalid token count of '${found.length}' returned.`); - }); + it('should not find a choice if recognizeOrdinals option disabled.', function () { + const found = recognizeChoices('first', colorChoices, { recognizeOrdinals: false }); + assert(found.length === 0, `Invalid token count of '${found.length}' returned.`); + }); - it('should not find a choice if recognizeNumbers option disabled.', function () { - const found = recognizeChoices('1', colorChoices, { recognizeNumbers: false }); - assert(found.length === 0, `Invalid token count of '${found.length}' returned.`); - }); + it('should not find a choice if recognizeNumbers option disabled.', function () { + const found = recognizeChoices('1', colorChoices, { recognizeNumbers: false }); + assert(found.length === 0, `Invalid token count of '${found.length}' returned.`); + }); - it('should not find a choice if both recognizeOrdinals and recognizeNumbers options are disabled.', function () { - const found = recognizeChoices('the first and third one please.', colorChoices, { - recognizeOrdinals: false, - recognizeNumbers: false, + it('should not find a choice if both recognizeOrdinals and recognizeNumbers options are disabled.', function () { + const found = recognizeChoices('the first and third one please.', colorChoices, { + recognizeOrdinals: false, + recognizeNumbers: false, + }); + assert(found.length === 0, `Invalid token count of '${found.length}' returned.`); }); - assert(found.length === 0, `Invalid token count of '${found.length}' returned.`); }); }); diff --git a/libraries/botbuilder-dialogs/tests/choices_tokenizer.test.js b/libraries/botbuilder-dialogs/tests/choices_tokenizer.test.js index 9e897803a4..21cbae00d7 100644 --- a/libraries/botbuilder-dialogs/tests/choices_tokenizer.test.js +++ b/libraries/botbuilder-dialogs/tests/choices_tokenizer.test.js @@ -7,7 +7,7 @@ function assertToken(token, start, end, text, normalized) { assert(token.text === text, `Invalid token.text of '${token.text}' for '${text}' token.`); assert( token.normalized === normalized || text, - `Invalid token.normalized of '${token.normalized}' for '${text}' token.` + `Invalid token.normalized of '${token.normalized}' for '${text}' token.`, ); } diff --git a/libraries/botbuilder-dialogs/tests/componentDialog.test.js b/libraries/botbuilder-dialogs/tests/componentDialog.test.js index 1d534a2139..ff8a9e10ea 100644 --- a/libraries/botbuilder-dialogs/tests/componentDialog.test.js +++ b/libraries/botbuilder-dialogs/tests/componentDialog.test.js @@ -29,7 +29,7 @@ describe('ComponentDialog', function () { component.addDialog(simpleH2ofall); assert( component.initialDialogId === 'simpleWaterfall', - `unexpected change in initialDialogId, it is now ${component.initialDialogId}` + `unexpected change in initialDialogId, it is now ${component.initialDialogId}`, ); }); @@ -101,7 +101,7 @@ describe('ComponentDialog', function () { const results = await dc.beginDialog('composite'); assert( results.status === DialogTurnStatus.complete, - `unexpected DialogTurnStatus received: ${results.status}` + `unexpected DialogTurnStatus received: ${results.status}`, ); assert(results.result === undefined, `unexpected results.result received: ${results.result}`); }); @@ -134,7 +134,7 @@ describe('ComponentDialog', function () { const results = await dc.beginDialog('composite'); assert( results.status === DialogTurnStatus.waiting, - `unexpected DialogTurnStatus received: ${results.status}` + `unexpected DialogTurnStatus received: ${results.status}`, ); assert(results.result === undefined, `unexpected results.result received: ${results.result}`); }); @@ -187,7 +187,7 @@ describe('ComponentDialog', function () { } else { assert( results.status === DialogTurnStatus.complete, - `results.status should be 'complete' not ${results.status}` + `results.status should be 'complete' not ${results.status}`, ); assert(results.result === undefined, `results.result should be undefined, not ${results.result}`); await turnContext.sendActivity('Done.'); @@ -242,11 +242,11 @@ describe('ComponentDialog', function () { const results = await dc.beginDialog('component'); assert( results.status === DialogTurnStatus.cancelled, - `should have returned ${DialogTurnStatus.cancelled} not ${results.status}` + `should have returned ${DialogTurnStatus.cancelled} not ${results.status}`, ); assert( dc.stack.length === 0, - `should have a dialogStack without 0 dialogs, not ${dc.stack.length} dialogs` + `should have a dialogStack without 0 dialogs, not ${dc.stack.length} dialogs`, ); }); @@ -270,7 +270,7 @@ describe('ComponentDialog', function () { simpleStepContextCheck(step); assert( step.reason === DialogReason.endCalled, - `called ComponentDialog should have bubbled up "cancelCalled" not "${step.reason}".` + `called ComponentDialog should have bubbled up "cancelCalled" not "${step.reason}".`, ); await step.context.sendActivity('Cancelled successfully.'); return await step.endDialog(); @@ -327,7 +327,7 @@ describe('ComponentDialog', function () { await step.context.sendActivity('Child finished.'); return await step.endDialog(); }, - ]) + ]), ); const parentComponent = new ComponentDialog('parentComponent'); @@ -339,7 +339,7 @@ describe('ComponentDialog', function () { await step.context.sendActivity(`Parent called with: ${step.options.value}`); return await step.endDialog(step.options.value); }, - ]) + ]), ); const dialogs = new DialogSet(dialogState); @@ -354,7 +354,7 @@ describe('ComponentDialog', function () { } else { assert( results.status === DialogTurnStatus.complete, - `results.status should be 'complete' not ${results.status}` + `results.status should be 'complete' not ${results.status}`, ); assert(results.result === undefined, `results.result should be undefined, not ${results.result}`); await turnContext.sendActivity('Done.'); @@ -408,7 +408,7 @@ describe('ComponentDialog', function () { } else { assert( results.status === DialogTurnStatus.complete, - `results.status should be 'complete' not ${results.status}` + `results.status should be 'complete' not ${results.status}`, ); assert(results.result === undefined, `results.result should be undefined, not ${results.result}`); await turnContext.sendActivity('Done.'); diff --git a/libraries/botbuilder-dialogs/tests/confirmPrompt.test.js b/libraries/botbuilder-dialogs/tests/confirmPrompt.test.js index 90655b9c62..0a22bd720b 100644 --- a/libraries/botbuilder-dialogs/tests/confirmPrompt.test.js +++ b/libraries/botbuilder-dialogs/tests/confirmPrompt.test.js @@ -311,7 +311,7 @@ describe('ConfirmPrompt', function () { } return prompt.recognized.succeeded; }, - 'ja-jp' + 'ja-jp', ); dialogs.add(confirmPrompt); @@ -393,7 +393,7 @@ describe('ConfirmPrompt', function () { } return prompt.recognized.succeeded; }, - 'es-es' + 'es-es', ); dialogs.add(confirmPrompt); @@ -474,7 +474,7 @@ describe('ConfirmPrompt', function () { } return prompt.recognized.succeeded; }, - testLocale + testLocale, ); dialogs.add(confirmPrompt); @@ -489,9 +489,9 @@ describe('ConfirmPrompt', function () { assert.strictEqual(activity.text, expectedAnswer); }) .startTest(); - }) + }), ); - }) + }), ); }); @@ -547,7 +547,7 @@ describe('ConfirmPrompt', function () { return prompt.recognized.succeeded; }, culture.locale, - customDict + customDict, ); dialogs.add(confirmPrompt); diff --git a/libraries/botbuilder-dialogs/tests/datetimePrompt.test.js b/libraries/botbuilder-dialogs/tests/datetimePrompt.test.js index e228d06e56..2d61c83af9 100644 --- a/libraries/botbuilder-dialogs/tests/datetimePrompt.test.js +++ b/libraries/botbuilder-dialogs/tests/datetimePrompt.test.js @@ -88,7 +88,7 @@ describe('DatetimePrompt', function () { new DateTimePrompt('prompt', async (prompt) => { assert(prompt); return prompt.recognized.succeeded; - }) + }), ); await adapter @@ -124,7 +124,7 @@ describe('DatetimePrompt', function () { new DateTimePrompt('prompt', async (prompt) => { assert(prompt); return prompt.recognized.succeeded; - }) + }), ); await adapter @@ -165,7 +165,7 @@ describe('DatetimePrompt', function () { await prompt.context.sendActivity('That was a bad date.'); } return prompt.recognized.succeeded; - }) + }), ); await adapter @@ -200,7 +200,7 @@ describe('DatetimePrompt', function () { new DateTimePrompt('prompt', async (prompt) => { assert(prompt); return prompt.recognized.succeeded; - }) + }), ); await adapter.send('Hello').send(invalidMessage).send(answerMessage2).assertReply('2012-09-02').startTest(); diff --git a/libraries/botbuilder-dialogs/tests/dialogContext.test.js b/libraries/botbuilder-dialogs/tests/dialogContext.test.js index d74847766a..6dfc0935ee 100644 --- a/libraries/botbuilder-dialogs/tests/dialogContext.test.js +++ b/libraries/botbuilder-dialogs/tests/dialogContext.test.js @@ -32,7 +32,7 @@ describe('DialogContext', function () { assert(step, 'WaterfallStepContext not passed in to WaterfallStep.'); return await step.endDialog(true); }, - ]) + ]), ); await adapter.send(beginMessage).startTest(); @@ -60,7 +60,7 @@ describe('DialogContext', function () { assert(step.options.z === 'z', 'Correct DialogOptions was not passed in to WaterfallDialog.'); return await step.endDialog(true); }, - ]) + ]), ); await adapter.send(beginMessage).startTest(); @@ -79,13 +79,13 @@ describe('DialogContext', function () { assert.strictEqual( err.message, "DialogContext.beginDialog(): A dialog with an id of 'b' wasn't found.", - `unexpected error message thrown: "${err.message}"` + `unexpected error message thrown: "${err.message}"`, ); assert(err instanceof DialogContextError, 'err should be a DialogContextError'); assert(err.dialogContext, 'err should include dialogContext'); return true; - } + }, ); }); @@ -98,7 +98,7 @@ describe('DialogContext', function () { async function (step) { return await step.endDialog(); }, - ]) + ]), ); await adapter.send(beginMessage).startTest(); @@ -123,11 +123,11 @@ describe('DialogContext', function () { assert.strictEqual( step.options.prompt, 'test', - 'promptOrOptions arg was not correctly passed through.' + 'promptOrOptions arg was not correctly passed through.', ); return await step.endDialog(); }, - ]) + ]), ); await adapter.send(beginMessage).startTest(); @@ -151,7 +151,7 @@ describe('DialogContext', function () { assert(step, 'WaterfallStepContext not passed in to WaterfallStep.'); return await step.endDialog(); }, - ]) + ]), ); await adapter.send(beginMessage).startTest(); @@ -177,7 +177,7 @@ describe('DialogContext', function () { assert.strictEqual(step.options.choices.length, 3, 'not all choices were passed in.'); return await step.endDialog(); }, - ]) + ]), ); await adapter.send(beginMessage).startTest(); @@ -207,7 +207,7 @@ describe('DialogContext', function () { assert.strictEqual(step.result, 120, "incorrect step.result value received from 'b' dialog."); return await step.endDialog(119); }, - ]) + ]), ); dialogs.add( @@ -216,7 +216,7 @@ describe('DialogContext', function () { assert(step, 'WaterfallStepContext not passed in to WaterfallStep.'); return await step.endDialog(120); }, - ]) + ]), ); await adapter.send(beginMessage).startTest(); @@ -254,7 +254,7 @@ describe('DialogContext', function () { assert(step, 'WaterfallStepContext not passed in to WaterfallStep.'); return await step.endDialog(true); }, - ]) + ]), ); await adapter.send(beginMessage).send(continueMessage).startTest(); @@ -286,7 +286,7 @@ describe('DialogContext', function () { async function () { assert(false, "shouldn't continue"); }, - ]) + ]), ); await assert.rejects( @@ -296,13 +296,13 @@ describe('DialogContext', function () { assert.strictEqual( err.message, "DialogContext.continueDialog(): Can't continue dialog. A dialog with an id of 'b' wasn't found.", - `unexpected error message thrown: "${err.message}"` + `unexpected error message thrown: "${err.message}"`, ); assert(err instanceof DialogContextError, 'err should be a DialogContextError'); assert(err.dialogContext, 'err should include dialogContext'); return true; - } + }, ); }); @@ -349,7 +349,7 @@ describe('DialogContext', function () { assert(step.result, 'ended dialog.', 'unexpected step.result received.'); return await step.endDialog(true); }, - ]) + ]), ); dialogs.add( @@ -358,7 +358,7 @@ describe('DialogContext', function () { assert(step, 'WaterfallStepContext not passed in to WaterfallStep.'); return await step.endDialog('ended dialog.'); }, - ]) + ]), ); await adapter.send(beginMessage).startTest(); @@ -374,7 +374,7 @@ describe('DialogContext', function () { assert.strictEqual( results.result, undefined, - 'received unexpected value for results.result (expected undefined).' + 'received unexpected value for results.result (expected undefined).', ); }); @@ -389,7 +389,7 @@ describe('DialogContext', function () { assert(step, 'WaterfallStepContext not passed in to WaterfallStep.'); return await step.replaceDialog('b', { z: step.options.z }); }, - ]) + ]), ); await adapter.send(beginMessage).startTest(); @@ -415,7 +415,7 @@ describe('DialogContext', function () { assert(step, 'WaterfallStepContext not passed in to WaterfallStep.'); return await step.replaceDialog('b', { z: step.options.z }); }, - ]) + ]), ); dialogs.add( @@ -426,7 +426,7 @@ describe('DialogContext', function () { assert.strictEqual(step.options.z, 'z', 'incorrect step.options received.'); return await step.endDialog(step.options.z); }, - ]) + ]), ); await adapter.send(beginMessage).startTest(); @@ -450,7 +450,7 @@ describe('DialogContext', function () { assert(step, 'WaterfallStepContext not passed in to WaterfallStep.'); return await step.endDialog(); }, - ]) + ]), ); await adapter.send(beginMessage).startTest(); diff --git a/libraries/botbuilder-dialogs/tests/dialogHelper.test.js b/libraries/botbuilder-dialogs/tests/dialogHelper.test.js index 0b9f93135f..9100830268 100644 --- a/libraries/botbuilder-dialogs/tests/dialogHelper.test.js +++ b/libraries/botbuilder-dialogs/tests/dialogHelper.test.js @@ -114,10 +114,9 @@ class SimpleComponentDialog extends ComponentDialog { this.WaterfallDialog = 'WaterfallDialog'; this.addDialog(new TextPrompt(this.TextPrompt)); this.addDialog( - new WaterfallDialog(this.WaterfallDialog, [this.promptForName.bind(this), this.finalStep.bind(this)]) + new WaterfallDialog(this.WaterfallDialog, [this.promptForName.bind(this), this.finalStep.bind(this)]), ); this.initialDialogId = this.WaterfallDialog; - this.endReason; } async onEndDialog(context, instance, reason) { @@ -144,7 +143,6 @@ class ComponentDialogWithPrematureEnd extends ComponentDialog { const waterfallDialog = 'waterfallDialog'; this.addDialog(new WaterfallDialog(waterfallDialog, [this.finalStep.bind(this)])); this.initialDialogId = waterfallDialog; - this.endReason; } async onEndDialog(context, instance, reason) { @@ -163,7 +161,6 @@ class ComponentDialogWithCancellation extends ComponentDialog { const waterfallDialog = 'waterfallDialog'; this.addDialog(new WaterfallDialog(waterfallDialog, [this.finalStep.bind(this)])); this.initialDialogId = waterfallDialog; - this.endReason; } async onEndDialog(context, instance, reason) { @@ -259,6 +256,7 @@ describe('runDialog()', function () { assert.strictEqual(_eocSent.type, ActivityTypes.EndOfConversation); assert.strictEqual(_eocSent.code, EndOfConversationCodes.CompletedSuccessfully); }); + it('handles premature dialog cancellation', async function () { const dialog = new ComponentDialogWithCancellation(); const testFlow = createTestFlow(dialog, FlowTestCase.MiddleSkill); diff --git a/libraries/botbuilder-dialogs/tests/dialogManager.test.js b/libraries/botbuilder-dialogs/tests/dialogManager.test.js index ebbbcbefdc..c76dfab5f9 100644 --- a/libraries/botbuilder-dialogs/tests/dialogManager.test.js +++ b/libraries/botbuilder-dialogs/tests/dialogManager.test.js @@ -118,7 +118,7 @@ function createTestFlow(dialog, testCase = FlowTestCase.RootBotOnly, enabledTrac _dmTurnResult = await dm.onTurn(context); }, convRef, - enabledTrace + enabledTrace, ); adapter.use(new AutoSaveStateMiddleware(userState, convoState)); @@ -133,10 +133,9 @@ class SimpleComponentDialog extends ComponentDialog { this.WaterfallDialog = 'WaterfallDialog'; this.addDialog(new TextPrompt(this.TextPrompt)); this.addDialog( - new WaterfallDialog(this.WaterfallDialog, [this.promptForName.bind(this), this.finalStep.bind(this)]) + new WaterfallDialog(this.WaterfallDialog, [this.promptForName.bind(this), this.finalStep.bind(this)]), ); this.initialDialogId = this.WaterfallDialog; - this.endReason; } async onEndDialog(context, instance, reason) { @@ -378,7 +377,7 @@ describe('DialogManager', function () { // Leaf nodes / non-containers should not be registered. strictEqual( dm.dialogs.getDialogs().find((d) => d instanceof SendActivity), - undefined + undefined, ); }); diff --git a/libraries/botbuilder-dialogs/tests/dialogSet.test.js b/libraries/botbuilder-dialogs/tests/dialogSet.test.js index 6d479c8f71..008c95531a 100644 --- a/libraries/botbuilder-dialogs/tests/dialogSet.test.js +++ b/libraries/botbuilder-dialogs/tests/dialogSet.test.js @@ -24,7 +24,7 @@ describe('DialogSet', function () { function (step) { assert(step); }, - ]) + ]), ); }); @@ -32,7 +32,7 @@ describe('DialogSet', function () { const dialogs = new DialogSet(); await assert.rejects( dialogs.createContext({ type: 'message', text: 'hi' }), - new Error('DialogSet.createContext(): the dialog set was not bound to a stateProperty when constructed.') + new Error('DialogSet.createContext(): the dialog set was not bound to a stateProperty when constructed.'), ); }); @@ -45,14 +45,14 @@ describe('DialogSet', function () { function (dc) { assert(dc); }, - ]) + ]), ) .add( new WaterfallDialog('B', [ function (dc) { assert(dc); }, - ]) + ]), ); assert(dialogs.find('A'), 'dialog A not found.'); assert(dialogs.find('B'), 'dialog B not found.'); @@ -92,7 +92,7 @@ describe('DialogSet', function () { await step.context.sendActivity('Good bye!'); return await step.endDialog(); }, - ]) + ]), ); const adapter = new TestAdapter(async (turnContext) => { diff --git a/libraries/botbuilder-dialogs/tests/memory/dialogStateManager.test.js b/libraries/botbuilder-dialogs/tests/memory/dialogStateManager.test.js index 4027b21f0e..cd62921c09 100644 --- a/libraries/botbuilder-dialogs/tests/memory/dialogStateManager.test.js +++ b/libraries/botbuilder-dialogs/tests/memory/dialogStateManager.test.js @@ -114,8 +114,8 @@ describe('Dialog State Manager', function () { const config = this.dc.state.configuration; assert( config.memoryScopes.find( - (scope) => scope instanceof ConversationMemoryScope && scope.name === 'conversation' - ) + (scope) => scope instanceof ConversationMemoryScope && scope.name === 'conversation', + ), ); assert(config.memoryScopes.find((scope) => scope instanceof UserMemoryScope && scope.name === 'user')); }); @@ -142,7 +142,7 @@ describe('Dialog State Manager', function () { it(`read & write values to ${scope} memory scope`, function () { this.dc.state.setValue(`${scope}.foo`, 'bar'); assert.strictEqual(this.dc.state.getValue(`${scope}.foo`), 'bar'); - }) + }), ); [ @@ -154,7 +154,7 @@ describe('Dialog State Manager', function () { this.dc.state.setValue(`${short}foo`, value); assertion(this.dc.state.getValue(`${long}.foo`), value); assertion(this.dc.state.getValue(`${short}foo`), value); - }) + }), ); it('read entities using @ alias.', function () { @@ -224,7 +224,7 @@ describe('Dialog State Manager', function () { it('support passing a function to getValue() for the default.', function () { assert.strictEqual( this.dc.state.getValue('', () => 'default'), - 'default' + 'default', ); }); diff --git a/libraries/botbuilder-dialogs/tests/memory/memoryScopes.test.js b/libraries/botbuilder-dialogs/tests/memory/memoryScopes.test.js index bdfd87dc01..6dd8598ef9 100644 --- a/libraries/botbuilder-dialogs/tests/memory/memoryScopes.test.js +++ b/libraries/botbuilder-dialogs/tests/memory/memoryScopes.test.js @@ -223,7 +223,7 @@ describe('Memory Scopes', function () { it('returns parent containers state for children', async function () { const { dc, scope } = await initialize( - new TestContainer('container', new TestDialog('child', 'test message')) + new TestContainer('container', new TestDialog('child', 'test message')), ); assert(dc.child); @@ -238,7 +238,7 @@ describe('Memory Scopes', function () { it('overwrites parents memory', async function () { const { dc, scope } = await initialize( - new TestContainer('container', new TestDialog('child', 'test message')) + new TestContainer('container', new TestDialog('child', 'test message')), ); assert(dc.child); @@ -334,7 +334,7 @@ describe('Memory Scopes', function () { }, }, BlobsStorage: {}, - } + }, ); }); @@ -365,7 +365,7 @@ describe('Memory Scopes', function () { 'to_be_overridden', 'MicrosoftAppPassword', 'runtimeSettings', - 'BlobsStorage' + 'BlobsStorage', ), { array: ['one', 'two'], @@ -381,7 +381,7 @@ describe('Memory Scopes', function () { }, }, BlobsStorage: {}, - } + }, ); }); diff --git a/libraries/botbuilder-dialogs/tests/numberPrompt.test.js b/libraries/botbuilder-dialogs/tests/numberPrompt.test.js index c4f93ae4d6..f7518c545d 100644 --- a/libraries/botbuilder-dialogs/tests/numberPrompt.test.js +++ b/libraries/botbuilder-dialogs/tests/numberPrompt.test.js @@ -34,7 +34,7 @@ describe('NumberPrompt', function () { it('should call NumberPrompt using dc.prompt().', async function () { const adapter = createAdapter( (dialogContext) => dialogContext.prompt('prompt', 'Please send a number.'), - (turnContext, result) => turnContext.sendActivity(result.toString()) + (turnContext, result) => turnContext.sendActivity(result.toString()), ); await adapter.send('Hello').assertReply('Please send a number.').send('35').assertReply('35').startTest(); @@ -48,7 +48,7 @@ describe('NumberPrompt', function () { assert(prompt); const value = prompt.recognized.value; return value !== undefined && value >= 1 && value <= 100; - } + }, ); await adapter @@ -73,7 +73,7 @@ describe('NumberPrompt', function () { assert(prompt); const value = prompt.recognized.value; return value !== undefined && value >= 1 && value <= 100; - } + }, ); await adapter @@ -102,7 +102,7 @@ describe('NumberPrompt', function () { await prompt.context.sendActivity('out of range'); } return valid; - } + }, ); await adapter @@ -123,7 +123,7 @@ describe('NumberPrompt', function () { assert(prompt); const value = prompt.recognized.value; return value !== undefined && value >= 1 && value <= 100; - } + }, ); await adapter.send('Hello').send('0').send('25').assertReply('25').startTest(); @@ -137,7 +137,7 @@ describe('NumberPrompt', function () { (prompt) => { assert(prompt); return prompt.recognized.value === 0; - } + }, ); await adapter @@ -166,7 +166,7 @@ describe('NumberPrompt', function () { } return true; - } + }, ); await adapter @@ -201,7 +201,7 @@ describe('NumberPrompt', function () { return turnContext.sendActivity(reply); }, undefined, - 'es-es' + 'es-es', ); await adapter.send('Hello').assertReply('Please send a number.').send('3,14').startTest(); @@ -215,7 +215,7 @@ describe('NumberPrompt', function () { return turnContext.sendActivity(reply); }, undefined, - 'en-us' + 'en-us', ); await adapter @@ -231,7 +231,7 @@ describe('NumberPrompt', function () { (turnContext, reply) => { assert.strictEqual(reply, 1500.25); return turnContext.sendActivity(reply); - } + }, ); await adapter.send('Hello').assertReply('Please send a number.').send('1,500.25').startTest(); @@ -243,7 +243,7 @@ describe('NumberPrompt', function () { (turnContext, reply) => { assert.strictEqual(reply, 3.14); return turnContext.sendActivity(reply); - } + }, ); await adapter diff --git a/libraries/botbuilder-dialogs/tests/oauthPrompt.test.js b/libraries/botbuilder-dialogs/tests/oauthPrompt.test.js index e7a762652e..0d5bfccefb 100644 --- a/libraries/botbuilder-dialogs/tests/oauthPrompt.test.js +++ b/libraries/botbuilder-dialogs/tests/oauthPrompt.test.js @@ -60,7 +60,7 @@ describe('OAuthPrompt', function () { connectionName, title: 'Login', timeout: 300000, - }) + }), ); await adapter @@ -124,7 +124,7 @@ describe('OAuthPrompt', function () { connectionName, title: 'Login', timeout: 300000, - }) + }), ); await adapter @@ -207,8 +207,8 @@ describe('OAuthPrompt', function () { } return false; - } - ) + }, + ), ); // Initialize TestAdapter. @@ -240,7 +240,7 @@ describe('OAuthPrompt', function () { activity.channelId, activity.recipient.id, exchangeToken, - token + token, ); }) .send('invalid text message here') @@ -274,8 +274,8 @@ describe('OAuthPrompt', function () { } prompt.context.sendActivity(`attemptCount ${prompt.attemptCount}`); return false; - } - ) + }, + ), ); // Initialize TestAdapter. @@ -315,7 +315,7 @@ describe('OAuthPrompt', function () { adapter.signOutUser( new TurnContext(adapter, { channelId: activity.channelId, from: activity.recipient }), - connectionName + connectionName, ); }) .send('Another!') @@ -368,7 +368,7 @@ describe('OAuthPrompt', function () { connectionName, title: 'Login', timeout: 300000, - }) + }), ); const streamingActivity = { @@ -465,7 +465,7 @@ describe('OAuthPrompt', function () { await assert.rejects( OAuthPrompt.sendOAuthCard({}, context), - new Error('OAuth prompt is not supported by the current adapter') + new Error('OAuth prompt is not supported by the current adapter'), ); }); @@ -541,7 +541,7 @@ describe('OAuthPrompt', function () { { type: 'azp', value: uuid() }, { type: 'ver', value: '2.0' }, { type: 'aud', value: uuid() }, - ]) + ]), ); // Override sendActivity context.sendActivity = async function (activity) { @@ -623,7 +623,7 @@ describe('OAuthPrompt', function () { { type: 'azp', value: uuid() }, { type: 'ver', value: '2.0' }, { type: 'aud', value: AuthenticationConstants.ToBotFromChannelTokenIssuer }, - ]) + ]), ); // Override sendActivity context.sendActivity = async function (activity) { @@ -668,7 +668,7 @@ describe('OAuthPrompt', function () { name: tokenResponseEventName, conversation: { id: 'conversationId' }, channelId: Channels.Test, - }) + }), ); function setActiveDialog(dc, dialog) { // Create stack if not already there. @@ -706,7 +706,7 @@ describe('OAuthPrompt', function () { undefined, undefined, credsFactory, - { requiredEndorsements: [] } + { requiredEndorsements: [] }, ); const adapter = new TestCloudAdapter(botFrameworkAuthentication); const oAuthPrompt = new OAuthPrompt('OAuthPrompt'); @@ -766,7 +766,7 @@ describe('OAuthPrompt', function () { undefined, undefined, credsFactory, - { requiredEndorsements: [] } + { requiredEndorsements: [] }, ); const adapter = new TestCloudAdapter(botFrameworkAuthentication); const oAuthPrompt = new OAuthPrompt('OAuthPrompt'); @@ -829,7 +829,7 @@ describe('OAuthPrompt', function () { title: 'Sign in', timeout: 30000, text: 'Please sign in', - }) + }), ); const adapter = new TestAdapter(async (turnContext) => { @@ -866,7 +866,7 @@ describe('OAuthPrompt', function () { title: 'Sign in', timeout: 30000, text: 'Please sign in', - }) + }), ); const adapter = new SignInTestAdapter(async (turnContext) => { @@ -906,7 +906,7 @@ describe('OAuthPrompt', function () { turnContext.activity.channelId, userId, exchangeToken, - token + token, ); // Positive case: Token @@ -968,7 +968,7 @@ describe('OAuthPrompt', function () { title: 'Sign in', timeout: 30000, text: 'Please sign in', - }) + }), ); }); @@ -986,7 +986,7 @@ describe('OAuthPrompt', function () { activity.channelId, activity.recipient.id, exchangeToken, - token + token, ); }) .send({ @@ -1194,7 +1194,7 @@ async function testTimeout( oauthPromptActivity, shouldSucceed = true, tokenResponse = 'Failed', - noTokenResponse = 'Ended' + noTokenResponse = 'Ended', ) { const connectionName = 'myConnection'; const token = 'abc123'; @@ -1223,8 +1223,8 @@ async function testTimeout( assert(!shouldSucceed, 'recognition failed during testTimeout'); return false; - } - ) + }, + ), ); const adapter = new TestAdapter(async (turnContext) => { @@ -1266,7 +1266,7 @@ async function testTimeout( activity.channelId, activity.recipient.id, exchangeToken, - token + token, ); }) .send(oauthPromptActivity) diff --git a/libraries/botbuilder-dialogs/tests/skillDialog.test.js b/libraries/botbuilder-dialogs/tests/skillDialog.test.js index 55c9e1efde..2c34a9fc27 100644 --- a/libraries/botbuilder-dialogs/tests/skillDialog.test.js +++ b/libraries/botbuilder-dialogs/tests/skillDialog.test.js @@ -31,7 +31,7 @@ describe('SkillDialog', function () { BOTBUILDER_TESTING = require('../../botbuilder-testing'); } catch (_err) { console.warn( - '=====\nUnable to load botbuilder or botbuilder-testing module. "beginDialog should call skill" tests will not be run.\n' + '=====\nUnable to load botbuilder or botbuilder-testing module. "beginDialog should call skill" tests will not be run.\n', ); } @@ -67,7 +67,7 @@ describe('SkillDialog', function () { conversationState, skillClient, undefined, - useCreateSkillConversationId + useCreateSkillConversationId, ); let createSkillConversationIdSpy; @@ -86,7 +86,7 @@ describe('SkillDialog', function () { dialog, { activity: activityToSend }, undefined, - conversationState + conversationState, ); assert.strictEqual(dialogOptions.conversationIdFactory.createCount, 0); @@ -123,12 +123,12 @@ describe('SkillDialog', function () { assert.strictEqual( await dialogOptions.conversationIdFactory.getSkillConversationReference('Convo1'), undefined, - 'no test should use TestAdapter ConversationId as SkillConversationId.' + 'no test should use TestAdapter ConversationId as SkillConversationId.', ); assert.strictEqual( await dialogOptions.conversationIdFactory.getSkillConversationReference(undefined), undefined, - 'no test should use TestAdapter ConversationId as SkillConversationId.' + 'no test should use TestAdapter ConversationId as SkillConversationId.', ); } @@ -153,7 +153,7 @@ describe('SkillDialog', function () { return; }, undefined, - expectedReplies + expectedReplies, ); const conversationState = new ConversationState(new MemoryStorage()); const dialogOptions = createSkillDialogOptions(conversationState, skillClient, undefined, false); @@ -217,7 +217,7 @@ describe('SkillDialog', function () { dialog, { activity: activityToSend }, undefined, - conversationState + conversationState, ); assert.strictEqual(dialogOptions.conversationIdFactory.createCount, 0); @@ -298,7 +298,7 @@ describe('SkillDialog', function () { assert.strictEqual(validatedActivity.text, 'Hello SkillDialog!'); }); - it('should fail if options is falsy', function () { + it('should fail if options is falsy second case', function () { const dialog = new SkillDialog({}, 'SkillDialog'); assert.throws(() => dialog.validateBeginDialogArgs(), new TypeError('Missing options parameter')); }); @@ -307,7 +307,7 @@ describe('SkillDialog', function () { const dialog = new SkillDialog({}, 'SkillDialog'); assert.throws( () => dialog.validateBeginDialogArgs({}), - new TypeError('"activity" is undefined or null in options.') + new TypeError('"activity" is undefined or null in options.'), ); }); }); @@ -330,7 +330,7 @@ describe('SkillDialog', function () { skill: {}, skillHostEndpoint: 'http://localhost:3980/api/messages', }, - 'SkillDialog' + 'SkillDialog', ); dialog.state = {}; @@ -368,7 +368,7 @@ describe('SkillDialog', function () { }, }, }, - 'SkillDialog' + 'SkillDialog', ); dialog.state = {}; @@ -421,14 +421,14 @@ describe('SkillDialog', function () { dialogUnderTest, beginSkillDialogOptions, [new AutoSaveStateMiddleware(conversationState)], - conversationState + conversationState, ); client._testAdapter.addExchangeableToken( connectionName, Channels.Test, 'user1', 'https://test', - 'https://test1' + 'https://test1', ); const finalActivity = await client.sendActivity('irrelevant'); @@ -456,14 +456,14 @@ describe('SkillDialog', function () { dialogUnderTest, beginSkillDialogOptions, [new AutoSaveStateMiddleware(conversationState)], - conversationState + conversationState, ); client._testAdapter.addExchangeableToken( connectionName, Channels.Test, 'user1', 'https://test', - 'https://test1' + 'https://test1', ); const finalActivity = await client.sendActivity('irrelevant'); @@ -491,7 +491,7 @@ describe('SkillDialog', function () { dialogUnderTest, beginSkillDialogOptions, [new AutoSaveStateMiddleware(conversationState)], - conversationState + conversationState, ); // dont add exchangeable token to test adapter const finalActivity = await client.sendActivity('irrelevant'); @@ -521,7 +521,7 @@ describe('SkillDialog', function () { dialogUnderTest, beginSkillDialogOptions, [new AutoSaveStateMiddleware(conversationState)], - conversationState + conversationState, ); client._testAdapter.addExchangeableToken(connectionName, Channels.Test, 'user1', 'https://test'); @@ -553,14 +553,14 @@ describe('SkillDialog', function () { dialogUnderTest, beginSkillDialogOptions, [new AutoSaveStateMiddleware(conversationState)], - conversationState + conversationState, ); client._testAdapter.addExchangeableToken( connectionName, Channels.Test, 'user1', 'https://test', - 'https://test1' + 'https://test1', ); const finalActivity = await client.sendActivity('irrelevant'); @@ -586,7 +586,7 @@ function createSkillClientAndStub(captureAction, returnStatusCode = StatusCodes. if (captureAction && typeof captureAction !== 'function') { throw new TypeError( - `Failed test arrangement - createSkillClientAndStub() received ${typeof captureAction} instead of undefined or a function.` + `Failed test arrangement - createSkillClientAndStub() received ${typeof captureAction} instead of undefined or a function.`, ); } diff --git a/libraries/botbuilder-dialogs/tests/textPrompt.test.js b/libraries/botbuilder-dialogs/tests/textPrompt.test.js index 8eae6f292e..29a7513ae4 100644 --- a/libraries/botbuilder-dialogs/tests/textPrompt.test.js +++ b/libraries/botbuilder-dialogs/tests/textPrompt.test.js @@ -56,7 +56,7 @@ describe('TextPrompt', function () { new TextPrompt('prompt', async (prompt) => { assert(prompt); return prompt.recognized.value.length >= 3; - }) + }), ); await adapter @@ -157,7 +157,7 @@ describe('TextPrompt', function () { await prompt.context.sendActivity('too short'); } return valid; - }) + }), ); await adapter diff --git a/libraries/botbuilder-dialogs/tests/waterfallDialog.test.js b/libraries/botbuilder-dialogs/tests/waterfallDialog.test.js index f9b0f31e54..ff4fbb479b 100644 --- a/libraries/botbuilder-dialogs/tests/waterfallDialog.test.js +++ b/libraries/botbuilder-dialogs/tests/waterfallDialog.test.js @@ -66,7 +66,7 @@ describe('WaterfallDialog', function () { assert(step); return await step.endDialog('ending WaterfallDialog.'); }, - ]) + ]), ); await adapter @@ -179,7 +179,7 @@ describe('WaterfallDialog', function () { assert(step); return await step.endDialog(step.result); }, - ]) + ]), ); await adapter @@ -217,7 +217,7 @@ describe('WaterfallDialog', function () { assert.strictEqual( step.options.test, 'test', - `step.options.test "${step.options.test}", was not expected value of "test".` + `step.options.test "${step.options.test}", was not expected value of "test".`, ); await step.context.sendActivity('bot responding.'); return Dialog.EndOfTurn; @@ -226,7 +226,7 @@ describe('WaterfallDialog', function () { assert(step); return await step.endDialog('ending WaterfallDialog.'); }, - ]) + ]), ); await adapter @@ -265,7 +265,7 @@ describe('WaterfallDialog', function () { assert.strictEqual( step.options.test, 'test1', - `step.options.test "${step.options.test}", was not expected value of "test1".` + `step.options.test "${step.options.test}", was not expected value of "test1".`, ); step.options.test = 'test2'; await step.context.sendActivity('bot responding.'); @@ -277,7 +277,7 @@ describe('WaterfallDialog', function () { assert.strictEqual( step.options.test, 'test2', - `step.options.test "${step.options.test}", was not expected value of "test2".` + `step.options.test "${step.options.test}", was not expected value of "test2".`, ); step.options.test = 'test3'; await step.context.sendActivity('bot responding again.'); @@ -288,11 +288,11 @@ describe('WaterfallDialog', function () { assert.strictEqual( step.options.test, 'test3', - `step.options.test "${step.options.test}", was not expected value of "test3".` + `step.options.test "${step.options.test}", was not expected value of "test3".`, ); return await step.endDialog('ending WaterfallDialog.'); }, - ]) + ]), ); await adapter @@ -340,7 +340,7 @@ describe('WaterfallDialog', function () { assert.strictEqual( step.values.test, 'test1', - `step.values.test ["${step.values.test}"] was not expected value "test1".` + `step.values.test ["${step.values.test}"] was not expected value "test1".`, ); step.values.test2 = 'test2'; await step.context.sendActivity('bot responding again.'); @@ -352,16 +352,16 @@ describe('WaterfallDialog', function () { assert.strictEqual( step.values.test, 'test1', - `step.values.test ["${step.values.test}"] was not expected value "test1".` + `step.values.test ["${step.values.test}"] was not expected value "test1".`, ); assert.strictEqual( step.values.test2, 'test2', - `step.values.test2 ["${step.values.test2}"] was not expected value "test2".` + `step.values.test2 ["${step.values.test2}"] was not expected value "test2".`, ); return await step.endDialog('ending WaterfallDialog.'); }, - ]) + ]), ); await adapter @@ -409,16 +409,16 @@ describe('WaterfallDialog', function () { assert.strictEqual( step.values.test, 'test1', - `step.values.test ["${step.values.test}"] was not expected value "test1".` + `step.values.test ["${step.values.test}"] was not expected value "test1".`, ); assert.strictEqual( step.values.test_b, undefined, - "step.values.test_b should not be available in WaterfallDialog('a')." + "step.values.test_b should not be available in WaterfallDialog('a').", ); return await step.endDialog('ending WaterfallDialog.'); }, - ]) + ]), ); dialogs.add( @@ -428,11 +428,11 @@ describe('WaterfallDialog', function () { assert.equal( typeof step.values, 'object', - 'new step.values for second WaterfallDialog should be an object.' + 'new step.values for second WaterfallDialog should be an object.', ); assert( !step.values.test, - "new WaterfallDialog's step.values shouldn't have values from parent dialog's step.values." + "new WaterfallDialog's step.values shouldn't have values from parent dialog's step.values.", ); // Add a new value to this WaterfallDialog's step.values. @@ -445,21 +445,21 @@ describe('WaterfallDialog', function () { assert.equal( typeof step.values, 'object', - 'step.values for second WaterfallDialog should be an object.' + 'step.values for second WaterfallDialog should be an object.', ); assert( !step.values.test, - "new WaterfallDialog's step.values shouldn't have values from parent dialog's step.values." + "new WaterfallDialog's step.values shouldn't have values from parent dialog's step.values.", ); assert.strictEqual( step.values.test_b, 'test_b', - "step.values.test_b should not be available in WaterfallDialog 'a'." + "step.values.test_b should not be available in WaterfallDialog 'a'.", ); return await step.endDialog(); }, - ]) + ]), ); await adapter @@ -498,7 +498,7 @@ describe('WaterfallDialog', function () { assert.strictEqual( step.options.test_a, 'test_a', - `step.options.test_a "${step.options.test_a}", was not expected value of "test_a".` + `step.options.test_a "${step.options.test_a}", was not expected value of "test_a".`, ); await step.context.sendActivity('bot responding.'); return await step.beginDialog('b'); @@ -509,11 +509,11 @@ describe('WaterfallDialog', function () { assert.strictEqual( step.options.test_a, 'test_a', - `step.options.test_a "${step.options.test_a}", was not expected value of "test_a".` + `step.options.test_a "${step.options.test_a}", was not expected value of "test_a".`, ); return await step.endDialog('ending WaterfallDialog.'); }, - ]) + ]), ); dialogs.add( @@ -524,7 +524,7 @@ describe('WaterfallDialog', function () { assert.strictEqual( step.options.test_a, undefined, - `step.options.test_a "${step.options.test_a}", was not expected value of "undefined".` + `step.options.test_a "${step.options.test_a}", was not expected value of "undefined".`, ); step.options.test_b = 'test_b'; return Dialog.EndOfTurn; @@ -535,11 +535,11 @@ describe('WaterfallDialog', function () { assert.strictEqual( step.options.test_b, 'test_b', - `step.options.test_b "${step.options.test_b}", was not expected value of "test_b".` + `step.options.test_b "${step.options.test_b}", was not expected value of "test_b".`, ); return await step.endDialog(); }, - ]) + ]), ); await adapter @@ -581,7 +581,7 @@ describe('WaterfallDialog', function () { assert(step, 'step not found.'); return Dialog.EndOfTurn; }, - ]) + ]), ); await adapter @@ -625,7 +625,7 @@ describe('WaterfallDialog', function () { assert( err.message === "WaterfallStepContext.next(): method already called for dialog and step 'a[0]'.", - err.message + err.message, ); } return Dialog.EndOfTurn; @@ -636,7 +636,7 @@ describe('WaterfallDialog', function () { async function (step) { assert(step, 'step not found.'); }, - ]) + ]), ); await adapter.send(beginMessage).assertReply('bot responding.').startTest(); @@ -672,11 +672,11 @@ describe('WaterfallDialog', function () { assert(step, 'step not found.'); assert( step.context.activity.text === 'continue.', - `expected "continue." not ${step.context.activity.text}` + `expected "continue." not ${step.context.activity.text}`, ); return await step.endDialog('done.'); }, - ]) + ]), ); await adapter @@ -697,7 +697,7 @@ describe('WaterfallDialog', function () { trackEvent(telemetry) { assert( telemetry.properties.StepName == dialog.steps[index].name, - `telemetry contains incorrect step name: "${telemetry.properties.StepName}"` + `telemetry contains incorrect step name: "${telemetry.properties.StepName}"`, ); trackEventCalled = true; }, @@ -711,7 +711,7 @@ describe('WaterfallDialog', function () { values: { instanceId: '(guid)' }, }, }, - DialogReason.cancelCalled + DialogReason.cancelCalled, ); assert(trackEventCalled, 'trackEvent was never called.'); }); From 21bc218bb7cd0a3575f80b59d0d297fffe3b2513 Mon Sep 17 00:00:00 2001 From: JhontSouth Date: Thu, 14 Nov 2024 10:21:32 -0500 Subject: [PATCH 2/4] add eslint config file --- libraries/botbuilder-dialogs/eslint.config.cjs | 8 ++++++++ libraries/botbuilder-dialogs/package.json | 5 ++--- libraries/botbuilder-dialogs/src/waterfallDialog.ts | 2 -- 3 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 libraries/botbuilder-dialogs/eslint.config.cjs diff --git a/libraries/botbuilder-dialogs/eslint.config.cjs b/libraries/botbuilder-dialogs/eslint.config.cjs new file mode 100644 index 0000000000..d2cc418c22 --- /dev/null +++ b/libraries/botbuilder-dialogs/eslint.config.cjs @@ -0,0 +1,8 @@ +const sharedConfig = require('../../eslint.config.cjs'); + +module.exports = [ + ...sharedConfig, + { + ignores: ['**/vendor/'], + }, +]; diff --git a/libraries/botbuilder-dialogs/package.json b/libraries/botbuilder-dialogs/package.json index 23ded5b613..e02294e682 100644 --- a/libraries/botbuilder-dialogs/package.json +++ b/libraries/botbuilder-dialogs/package.json @@ -33,8 +33,7 @@ "@microsoft/recognizers-text-suite": "1.1.4", "botbuilder-core": "4.1.6", "botbuilder-dialogs-adaptive-runtime-core": "4.1.6", - "botframework-connector": "4.1.6", - "eslint-plugin-only-warn": "^1.1.0", + "botframework-connector": "4.1.6", "globalize": "^1.7.0", "lodash": "^4.17.21", "uuid": "^10.0.0", @@ -50,7 +49,7 @@ "build:rollup": "yarn clean && yarn build && api-extractor run --verbose --local", "clean": "rimraf _ts3.4 lib tsconfig.tsbuildinfo", "depcheck": "depcheck --config ../../.depcheckrc", - "lint": "eslint . --config ../../eslint.config.cjs", + "lint": "eslint .", "postbuild": "downlevel-dts lib _ts3.4/lib --checksum", "test": "npm-run-all build test:mocha", "test:mocha": "nyc mocha --recursive --require source-map-support/register tests", diff --git a/libraries/botbuilder-dialogs/src/waterfallDialog.ts b/libraries/botbuilder-dialogs/src/waterfallDialog.ts index 1ba66bc5d5..481046d0aa 100644 --- a/libraries/botbuilder-dialogs/src/waterfallDialog.ts +++ b/libraries/botbuilder-dialogs/src/waterfallDialog.ts @@ -7,9 +7,7 @@ */ import { v4 as uuidv4 } from 'uuid'; import { ActivityTypes, TurnContext, telemetryTrackDialogView } from 'botbuilder-core'; - import { DialogInstance, Dialog, DialogReason, DialogTurnResult } from './dialog'; - import { DialogContext } from './dialogContext'; import { WaterfallStepContext } from './waterfallStepContext'; From 63ea16268ce84467a709e796cb5a4af5f08f50c6 Mon Sep 17 00:00:00 2001 From: JhontSouth Date: Thu, 14 Nov 2024 10:22:21 -0500 Subject: [PATCH 3/4] combine unit tests and remove duplicated --- libraries/botbuilder-dialogs/tests/skillDialog.test.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libraries/botbuilder-dialogs/tests/skillDialog.test.js b/libraries/botbuilder-dialogs/tests/skillDialog.test.js index 2c34a9fc27..bf05b063a5 100644 --- a/libraries/botbuilder-dialogs/tests/skillDialog.test.js +++ b/libraries/botbuilder-dialogs/tests/skillDialog.test.js @@ -296,10 +296,6 @@ describe('SkillDialog', function () { const validatedActivity = validatedArgs.activity; assert.strictEqual(validatedActivity.type, ActivityTypes.Message); assert.strictEqual(validatedActivity.text, 'Hello SkillDialog!'); - }); - - it('should fail if options is falsy second case', function () { - const dialog = new SkillDialog({}, 'SkillDialog'); assert.throws(() => dialog.validateBeginDialogArgs(), new TypeError('Missing options parameter')); }); From 777b14fb638dc28fc041ff49169b2432d5ba6dd2 Mon Sep 17 00:00:00 2001 From: JhontSouth Date: Thu, 14 Nov 2024 10:44:25 -0500 Subject: [PATCH 4/4] initialize this.endReason --- libraries/botbuilder-dialogs/src/skillDialog.ts | 4 ++-- libraries/botbuilder-dialogs/tests/dialogHelper.test.js | 3 +++ libraries/botbuilder-dialogs/tests/dialogManager.test.js | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libraries/botbuilder-dialogs/src/skillDialog.ts b/libraries/botbuilder-dialogs/src/skillDialog.ts index 8395b462af..c9cd94b664 100644 --- a/libraries/botbuilder-dialogs/src/skillDialog.ts +++ b/libraries/botbuilder-dialogs/src/skillDialog.ts @@ -355,7 +355,7 @@ export class SkillDialog extends Dialog> { const result: TokenResponse = await UserTokenAccess.exchangeToken( context, { title: 'Sign In', connectionName: connectionName }, - { uri } + { uri }, ); if (!result || !result.token) { @@ -367,7 +367,7 @@ export class SkillDialog extends Dialog> { activity, oAuthCard.tokenExchangeResource.id, oAuthCard.connectionName, - result.token + result.token, ); } catch { // Failures in token exchange are not fatal. They simply mean that the user needs to be shown the skill's OAuthCard. diff --git a/libraries/botbuilder-dialogs/tests/dialogHelper.test.js b/libraries/botbuilder-dialogs/tests/dialogHelper.test.js index 9100830268..0dca013cb8 100644 --- a/libraries/botbuilder-dialogs/tests/dialogHelper.test.js +++ b/libraries/botbuilder-dialogs/tests/dialogHelper.test.js @@ -117,6 +117,7 @@ class SimpleComponentDialog extends ComponentDialog { new WaterfallDialog(this.WaterfallDialog, [this.promptForName.bind(this), this.finalStep.bind(this)]), ); this.initialDialogId = this.WaterfallDialog; + this.endReason = ''; } async onEndDialog(context, instance, reason) { @@ -143,6 +144,7 @@ class ComponentDialogWithPrematureEnd extends ComponentDialog { const waterfallDialog = 'waterfallDialog'; this.addDialog(new WaterfallDialog(waterfallDialog, [this.finalStep.bind(this)])); this.initialDialogId = waterfallDialog; + this.endReason = ''; } async onEndDialog(context, instance, reason) { @@ -161,6 +163,7 @@ class ComponentDialogWithCancellation extends ComponentDialog { const waterfallDialog = 'waterfallDialog'; this.addDialog(new WaterfallDialog(waterfallDialog, [this.finalStep.bind(this)])); this.initialDialogId = waterfallDialog; + this.endReason = ''; } async onEndDialog(context, instance, reason) { diff --git a/libraries/botbuilder-dialogs/tests/dialogManager.test.js b/libraries/botbuilder-dialogs/tests/dialogManager.test.js index c76dfab5f9..f853429eac 100644 --- a/libraries/botbuilder-dialogs/tests/dialogManager.test.js +++ b/libraries/botbuilder-dialogs/tests/dialogManager.test.js @@ -136,6 +136,7 @@ class SimpleComponentDialog extends ComponentDialog { new WaterfallDialog(this.WaterfallDialog, [this.promptForName.bind(this), this.finalStep.bind(this)]), ); this.initialDialogId = this.WaterfallDialog; + this.endReason = ''; } async onEndDialog(context, instance, reason) {