Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: [#4684] ESLint issues in botbuilder-dialogs-adaptive-runtime #4810

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class CoreBot extends ActivityHandler {
defaultLocale: string,
defaultRootDialog: string,
memoryScopes: MemoryScope[],
pathResolvers: PathResolver[]
pathResolvers: PathResolver[],
) {
super();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class CoreBotAdapter extends CloudAdapter {
constructor(
botFrameworkAuthentication: BotFrameworkAuthentication,
private readonly conversationState: ConversationState,
userState: UserState
userState: UserState,
) {
super(botFrameworkAuthentication);

Expand Down
80 changes: 39 additions & 41 deletions libraries/botbuilder-dialogs-adaptive-runtime/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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),
);
}

Expand All @@ -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(),
),
);
}

Expand All @@ -118,7 +116,7 @@ function addFeatures(services: ServiceCollection, configuration: Configuration):
}

return middlewareSet;
}
},
);
}

Expand All @@ -132,7 +130,7 @@ function addTelemetry(services: ServiceCollection, configuration: Configuration)
instrumentationKey: z.string(),
})
.partial()
.nonstrict()
.nonstrict(),
);

const setupString = telemetryOptions?.connectionString ?? telemetryOptions?.instrumentationKey;
Expand All @@ -150,22 +148,22 @@ function addTelemetry(services: ServiceCollection, configuration: Configuration)
({ botTelemetryClient }) =>
new TelemetryInitializerMiddleware(
new TelemetryLoggerMiddleware(botTelemetryClient, configuration.bool(['logPersonalInformation'])),
configuration.bool(['logActivities'])
)
configuration.bool(['logActivities']),
),
);
}

function addStorage(services: ServiceCollection, configuration: Configuration): void {
services.addFactory<ConversationState, { storage: Storage }>(
'conversationState',
['storage'],
({ storage }) => new ConversationState(storage)
({ storage }) => new ConversationState(storage),
);

services.addFactory<UserState, { storage: Storage }>(
'userState',
['storage'],
({ storage }) => new UserState(storage)
({ storage }) => new UserState(storage),
);

services.addFactory<Storage>('storage', () => {
Expand All @@ -180,7 +178,7 @@ function addStorage(services: ServiceCollection, configuration: Configuration):
connectionString: z.string(),
containerName: z.string(),
})
.nonstrict()
.nonstrict(),
);

if (!blobsStorage) {
Expand All @@ -203,7 +201,7 @@ function addStorage(services: ServiceCollection, configuration: Configuration):
databaseId: z.string(),
keySuffix: z.string().optional(),
})
.nonstrict()
.nonstrict(),
);

if (!cosmosOptions) {
Expand Down Expand Up @@ -234,7 +232,7 @@ function addSkills(services: ServiceCollection, configuration: Configuration): v
services.addFactory<SkillConversationIdFactoryBase, { storage: Storage }>(
'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.
Expand Down Expand Up @@ -263,9 +261,9 @@ function addSkills(services: ServiceCollection, configuration: Configuration): v
.object({
msAppId: z.string(),
})
.nonstrict()
)
) ?? {}
.nonstrict(),
),
) ?? {},
);

if (skills.length) {
Expand All @@ -274,15 +272,15 @@ 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
// we validate caller against this list
return new AuthenticationConfiguration(
undefined,
allowedCallers.length ? allowedCallersClaimsValidator(allowedCallers) : undefined,
validTokenIssuers
validTokenIssuers,
);
}
});
Expand All @@ -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: ChannelServiceHandler }>(
'channelServiceRoutes',
['channelServiceHandler'],
(dependencies) => new ChannelServiceRoutes(dependencies.channelServiceHandler)
(dependencies) => new ChannelServiceRoutes(dependencies.channelServiceHandler),
);
}

Expand All @@ -337,8 +335,8 @@ function addCoreBot(services: ServiceCollection, configuration: Configuration):
dependencies.serviceClientCredentialsFactory,
dependencies.authenticationConfiguration,
dependencies.botFrameworkClientFetch,
dependencies.connectorClientOptions
)
dependencies.connectorClientOptions,
),
);

services.addFactory<
Expand Down Expand Up @@ -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<
Expand All @@ -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),
);
}

Expand Down Expand Up @@ -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 }> = [];
Expand All @@ -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,
),
);
}
}
Expand Down Expand Up @@ -501,9 +499,9 @@ async function normalizeConfiguration(configuration: Configuration, applicationR
await new Promise<string | undefined>((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);
Expand Down Expand Up @@ -571,7 +569,7 @@ function registerQnAComponents(services: ServiceCollection, configuration: Confi
export async function getRuntimeServices(
applicationRoot: string,
settingsDirectory: string,
defaultServices?: Record<string, any>
defaultServices?: Record<string, any>,
): Promise<[ServiceCollection, Configuration]>;

/**
Expand All @@ -585,7 +583,7 @@ export async function getRuntimeServices(
export async function getRuntimeServices(
applicationRoot: string,
configuration: Configuration,
defaultServices?: Record<string, any>
defaultServices?: Record<string, any>,
): Promise<[ServiceCollection, Configuration]>;

/**
Expand All @@ -594,7 +592,7 @@ export async function getRuntimeServices(
export async function getRuntimeServices(
applicationRoot: string,
configurationOrSettingsDirectory: Configuration | string,
defaultServices: Record<string, any> = {}
defaultServices: Record<string, any> = {},
): Promise<[ServiceCollection, Configuration]> {
// Resolve configuration
let configuration: Configuration;
Expand Down Expand Up @@ -632,7 +630,7 @@ export async function getRuntimeServices(
services.addFactory<ResourceExplorer, { declarativeTypes: ComponentDeclarativeTypes[] }>(
'resourceExplorer',
['declarativeTypes'],
({ declarativeTypes }) => new ConfigurationResourceExporer(configuration, declarativeTypes)
({ declarativeTypes }) => new ConfigurationResourceExporer(configuration, declarativeTypes),
);

registerAdaptiveComponents(services, configuration);
Expand Down
Loading
Loading