diff --git a/libraries/botbuilder-dialogs-adaptive-runtime/eslint.config.cjs b/libraries/botbuilder-dialogs-adaptive-runtime/eslint.config.cjs deleted file mode 100644 index 63647b52cc..0000000000 --- a/libraries/botbuilder-dialogs-adaptive-runtime/eslint.config.cjs +++ /dev/null @@ -1,10 +0,0 @@ -const onlyWarn = require("eslint-plugin-only-warn"); -const sharedConfig = require("../../eslint.config.cjs") - -module.exports = [ - ...sharedConfig, - { - plugins: { - "only-warn": onlyWarn, - }, - }]; diff --git a/libraries/botbuilder-dialogs-adaptive-runtime/package.json b/libraries/botbuilder-dialogs-adaptive-runtime/package.json index 559b1cbb87..6d1b01ed2d 100644 --- a/libraries/botbuilder-dialogs-adaptive-runtime/package.json +++ b/libraries/botbuilder-dialogs-adaptive-runtime/package.json @@ -39,7 +39,6 @@ "botbuilder-dialogs-adaptive-runtime-core": "4.1.6", "botbuilder-dialogs-declarative": "4.1.6", "botframework-connector": "4.1.6", - "eslint-plugin-only-warn": "^1.1.0", "nconf": "^0.12.1", "yargs-parser": "^21.1.1", "zod": "^3.23.8" @@ -53,7 +52,7 @@ "build": "tsc -b", "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": "nyc mocha", "test:min": "nyc --silent mocha --reporter dot" diff --git a/libraries/botbuilder-dialogs-adaptive-runtime/src/configurationResourceExplorer.ts b/libraries/botbuilder-dialogs-adaptive-runtime/src/configurationResourceExplorer.ts index 55d19fabb0..e0ce266652 100644 --- a/libraries/botbuilder-dialogs-adaptive-runtime/src/configurationResourceExplorer.ts +++ b/libraries/botbuilder-dialogs-adaptive-runtime/src/configurationResourceExplorer.ts @@ -22,7 +22,7 @@ export class ConfigurationResourceExporer extends ResourceExplorer { this.addFolders( applicationRoot, ['node_modules'], // Composer copies to `dialogs/imported` so `node_modules` will contain dupes - configuration.string(['NODE_ENV']) === 'dev' // watch in dev only! + configuration.string(['NODE_ENV']) === 'dev', // watch in dev only! ); } } diff --git a/libraries/botbuilder-dialogs-adaptive-runtime/src/coreBot.ts b/libraries/botbuilder-dialogs-adaptive-runtime/src/coreBot.ts index 6d3440d5b0..dc2c4b9447 100644 --- a/libraries/botbuilder-dialogs-adaptive-runtime/src/coreBot.ts +++ b/libraries/botbuilder-dialogs-adaptive-runtime/src/coreBot.ts @@ -48,7 +48,7 @@ export class CoreBot extends ActivityHandler { defaultLocale: string, defaultRootDialog: string, memoryScopes: MemoryScope[], - pathResolvers: PathResolver[] + pathResolvers: PathResolver[], ) { super(); diff --git a/libraries/botbuilder-dialogs-adaptive-runtime/src/coreBotAdapter.ts b/libraries/botbuilder-dialogs-adaptive-runtime/src/coreBotAdapter.ts index 612b0baf54..4c00425c71 100644 --- a/libraries/botbuilder-dialogs-adaptive-runtime/src/coreBotAdapter.ts +++ b/libraries/botbuilder-dialogs-adaptive-runtime/src/coreBotAdapter.ts @@ -16,7 +16,7 @@ export class CoreBotAdapter extends CloudAdapter { constructor( botFrameworkAuthentication: BotFrameworkAuthentication, private readonly conversationState: ConversationState, - userState: UserState + userState: UserState, ) { super(botFrameworkAuthentication); diff --git a/libraries/botbuilder-dialogs-adaptive-runtime/src/index.ts b/libraries/botbuilder-dialogs-adaptive-runtime/src/index.ts index 7fd764f8f6..3912c6dfa1 100644 --- a/libraries/botbuilder-dialogs-adaptive-runtime/src/index.ts +++ b/libraries/botbuilder-dialogs-adaptive-runtime/src/index.ts @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/* eslint-disable @typescript-eslint/no-explicit-any */ - import * as z from 'zod'; import fs from 'fs'; import path from 'path'; @@ -82,12 +80,12 @@ function addFeatures(services: ServiceCollection, configuration: Configuration): voiceFontName: z.string().optional(), fallbackToTextForSpeechIfEmpty: z.boolean(), }) - .nonstrict() + .nonstrict(), ); if (setSpeak) { middlewareSet.use( - new SetSpeakMiddleware(setSpeak.voiceFontName ?? null, setSpeak.fallbackToTextForSpeechIfEmpty) + new SetSpeakMiddleware(setSpeak.voiceFontName ?? null, setSpeak.fallbackToTextForSpeechIfEmpty), ); } @@ -100,15 +98,15 @@ function addFeatures(services: ServiceCollection, configuration: Configuration): containerName: z.string(), decodeTranscriptKey: z.boolean().optional(), }) - .nonstrict() + .nonstrict(), ); middlewareSet.use( new TranscriptLoggerMiddleware( blobsTranscript ? new BlobsTranscriptStore(blobsTranscript.connectionString, blobsTranscript.containerName) - : new ConsoleTranscriptLogger() - ) + : new ConsoleTranscriptLogger(), + ), ); } @@ -118,7 +116,7 @@ function addFeatures(services: ServiceCollection, configuration: Configuration): } return middlewareSet; - } + }, ); } @@ -132,7 +130,7 @@ function addTelemetry(services: ServiceCollection, configuration: Configuration) instrumentationKey: z.string(), }) .partial() - .nonstrict() + .nonstrict(), ); const setupString = telemetryOptions?.connectionString ?? telemetryOptions?.instrumentationKey; @@ -150,8 +148,8 @@ function addTelemetry(services: ServiceCollection, configuration: Configuration) ({ botTelemetryClient }) => new TelemetryInitializerMiddleware( new TelemetryLoggerMiddleware(botTelemetryClient, configuration.bool(['logPersonalInformation'])), - configuration.bool(['logActivities']) - ) + configuration.bool(['logActivities']), + ), ); } @@ -159,13 +157,13 @@ function addStorage(services: ServiceCollection, configuration: Configuration): services.addFactory( 'conversationState', ['storage'], - ({ storage }) => new ConversationState(storage) + ({ storage }) => new ConversationState(storage), ); services.addFactory( 'userState', ['storage'], - ({ storage }) => new UserState(storage) + ({ storage }) => new UserState(storage), ); services.addFactory('storage', () => { @@ -180,7 +178,7 @@ function addStorage(services: ServiceCollection, configuration: Configuration): connectionString: z.string(), containerName: z.string(), }) - .nonstrict() + .nonstrict(), ); if (!blobsStorage) { @@ -203,7 +201,7 @@ function addStorage(services: ServiceCollection, configuration: Configuration): databaseId: z.string(), keySuffix: z.string().optional(), }) - .nonstrict() + .nonstrict(), ); if (!cosmosOptions) { @@ -234,7 +232,7 @@ function addSkills(services: ServiceCollection, configuration: Configuration): v services.addFactory( 'skillConversationIdFactory', ['storage'], - ({ storage }) => new SkillConversationIdFactory(storage) + ({ storage }) => new SkillConversationIdFactory(storage), ); // If TenantId is specified in config, add the tenant as a valid JWT token issuer for Bot to Skill conversation. @@ -263,9 +261,9 @@ function addSkills(services: ServiceCollection, configuration: Configuration): v .object({ msAppId: z.string(), }) - .nonstrict() - ) - ) ?? {} + .nonstrict(), + ), + ) ?? {}, ); if (skills.length) { @@ -274,7 +272,7 @@ function addSkills(services: ServiceCollection, configuration: Configuration): v return new AuthenticationConfiguration( undefined, allowedCallersClaimsValidator(skills.map((skill) => skill.msAppId)), - validTokenIssuers + validTokenIssuers, ); } else { // If the config entry for runtimeSettings.skills.allowedCallers contains entries, then we are a skill and @@ -282,7 +280,7 @@ function addSkills(services: ServiceCollection, configuration: Configuration): v return new AuthenticationConfiguration( undefined, allowedCallers.length ? allowedCallersClaimsValidator(allowedCallers) : undefined, - validTokenIssuers + validTokenIssuers, ); } }); @@ -303,14 +301,14 @@ function addSkills(services: ServiceCollection, configuration: Configuration): v dependencies.adapter, (context) => dependencies.bot.run(context), dependencies.skillConversationIdFactory, - dependencies.botFrameworkAuthentication - ) + dependencies.botFrameworkAuthentication, + ), ); services.addFactory( 'channelServiceRoutes', ['channelServiceHandler'], - (dependencies) => new ChannelServiceRoutes(dependencies.channelServiceHandler) + (dependencies) => new ChannelServiceRoutes(dependencies.channelServiceHandler), ); } @@ -337,8 +335,8 @@ function addCoreBot(services: ServiceCollection, configuration: Configuration): dependencies.serviceClientCredentialsFactory, dependencies.authenticationConfiguration, dependencies.botFrameworkClientFetch, - dependencies.connectorClientOptions - ) + dependencies.connectorClientOptions, + ), ); services.addFactory< @@ -376,8 +374,8 @@ function addCoreBot(services: ServiceCollection, configuration: Configuration): configuration.string(['defaultLocale']) ?? 'en-us', configuration.string(['defaultRootDialog']) ?? 'main.dialog', dependencies.memoryScopes, - dependencies.pathResolvers - ) + dependencies.pathResolvers, + ), ); services.addFactory< @@ -396,10 +394,10 @@ function addCoreBot(services: ServiceCollection, configuration: Configuration): new CoreBotAdapter( dependencies.botFrameworkAuthentication, dependencies.conversationState, - dependencies.userState + dependencies.userState, ) .use(dependencies.middlewares) - .use(dependencies.telemetryMiddleware) + .use(dependencies.telemetryMiddleware), ); } @@ -433,8 +431,8 @@ async function addSettingsBotComponents(services: ServiceCollection, configurati name: z.string(), settingsPrefix: z.string().optional(), }) - .nonstrict() - ) + .nonstrict(), + ), ) ?? []; const loadErrors: Array<{ error: Error; name: string }> = []; @@ -453,8 +451,8 @@ async function addSettingsBotComponents(services: ServiceCollection, configurati loadErrors.forEach(({ name, error }) => console.warn( `${name} failed to load. Consider removing this component from the list of components in your application settings.`, - error - ) + error, + ), ); } } @@ -501,9 +499,9 @@ async function normalizeConfiguration(configuration: Configuration, applicationR await new Promise((resolve, reject) => // eslint-disable-next-line security/detect-non-literal-fs-filename fs.readdir(applicationRoot, (err, files) => - err ? reject(err) : resolve(files.find((file) => file.endsWith('.dialog'))) - ) - ) + err ? reject(err) : resolve(files.find((file) => file.endsWith('.dialog'))), + ), + ), ); addComposerConfiguration(configuration); @@ -571,7 +569,7 @@ function registerQnAComponents(services: ServiceCollection, configuration: Confi export async function getRuntimeServices( applicationRoot: string, settingsDirectory: string, - defaultServices?: Record + defaultServices?: Record, ): Promise<[ServiceCollection, Configuration]>; /** @@ -585,7 +583,7 @@ export async function getRuntimeServices( export async function getRuntimeServices( applicationRoot: string, configuration: Configuration, - defaultServices?: Record + defaultServices?: Record, ): Promise<[ServiceCollection, Configuration]>; /** @@ -594,7 +592,7 @@ export async function getRuntimeServices( export async function getRuntimeServices( applicationRoot: string, configurationOrSettingsDirectory: Configuration | string, - defaultServices: Record = {} + defaultServices: Record = {}, ): Promise<[ServiceCollection, Configuration]> { // Resolve configuration let configuration: Configuration; @@ -632,7 +630,7 @@ export async function getRuntimeServices( services.addFactory( 'resourceExplorer', ['declarativeTypes'], - ({ declarativeTypes }) => new ConfigurationResourceExporer(configuration, declarativeTypes) + ({ declarativeTypes }) => new ConfigurationResourceExporer(configuration, declarativeTypes), ); registerAdaptiveComponents(services, configuration); diff --git a/libraries/botbuilder-dialogs-adaptive-runtime/test/index.test.ts b/libraries/botbuilder-dialogs-adaptive-runtime/test/index.test.ts index 4155e350aa..0aece00335 100644 --- a/libraries/botbuilder-dialogs-adaptive-runtime/test/index.test.ts +++ b/libraries/botbuilder-dialogs-adaptive-runtime/test/index.test.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import sinon from 'sinon'; +import sinon, { createSandbox, match } from 'sinon'; import { AuthenticationConfiguration, AuthenticationConstants, SkillValidation } from 'botframework-connector'; import { BlobsStorage } from 'botbuilder-azure-blobs'; import { Configuration, getRuntimeServices } from '../src'; @@ -22,8 +22,9 @@ import { describe('getRuntimeServices', function () { let sandbox: sinon.SinonSandbox; + beforeEach(function () { - sandbox = sinon.createSandbox(); + sandbox = createSandbox(); }); afterEach(function () { @@ -173,10 +174,10 @@ describe('getRuntimeServices', function () { services.mustMakeInstance('middlewares'); - ok(spy.calledWith(sinon.match.instanceOf(ShowTypingMiddleware)), 'ShowTypingMiddleware'); - ok(spy.calledWith(sinon.match.instanceOf(SetSpeakMiddleware)), 'SetSpeakMiddleware'); - ok(spy.calledWith(sinon.match.instanceOf(TranscriptLoggerMiddleware)), 'TranscriptLoggerMiddleware'); - ok(spy.calledWith(sinon.match.instanceOf(InspectionMiddleware)), 'InspectionMiddleware'); + ok(spy.calledWith(match.instanceOf(ShowTypingMiddleware)), 'ShowTypingMiddleware'); + ok(spy.calledWith(match.instanceOf(SetSpeakMiddleware)), 'SetSpeakMiddleware'); + ok(spy.calledWith(match.instanceOf(TranscriptLoggerMiddleware)), 'TranscriptLoggerMiddleware'); + ok(spy.calledWith(match.instanceOf(InspectionMiddleware)), 'InspectionMiddleware'); }); }); @@ -193,9 +194,8 @@ describe('getRuntimeServices', function () { }); const [services] = await getRuntimeServices(__dirname, configuration); - const authenticationConfiguration = services.mustMakeInstance( - 'authenticationConfiguration' - ); + const authenticationConfiguration = + services.mustMakeInstance('authenticationConfiguration'); const { validateClaims } = authenticationConfiguration; ok(validateClaims); @@ -213,7 +213,7 @@ describe('getRuntimeServices', function () { type: AuthenticationConstants.AppIdClaim, value: 'BadAppId', }, - ]) + ]), ); }); @@ -230,9 +230,8 @@ describe('getRuntimeServices', function () { }); const [services] = await getRuntimeServices(__dirname, configuration); - const authenticationConfiguration = services.mustMakeInstance( - 'authenticationConfiguration' - ); + const authenticationConfiguration = + services.mustMakeInstance('authenticationConfiguration'); const { validateClaims } = authenticationConfiguration; ok(validateClaims); @@ -258,7 +257,7 @@ describe('getRuntimeServices', function () { type: AuthenticationConstants.AppIdClaim, value: 'AppC', }, - ]) + ]), ); }); });