diff --git a/libraries/botbuilder-ai-orchestrator/eslint.config.cjs b/libraries/botbuilder-ai-orchestrator/eslint.config.cjs deleted file mode 100644 index c56fd90ec6..0000000000 --- a/libraries/botbuilder-ai-orchestrator/eslint.config.cjs +++ /dev/null @@ -1,11 +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-ai-orchestrator/package.json b/libraries/botbuilder-ai-orchestrator/package.json index c738a05935..38e21fb972 100644 --- a/libraries/botbuilder-ai-orchestrator/package.json +++ b/libraries/botbuilder-ai-orchestrator/package.json @@ -35,7 +35,6 @@ "botbuilder-dialogs-adaptive": "4.1.6", "botbuilder-dialogs-adaptive-runtime-core": "4.1.6", "botbuilder-dialogs-declarative": "4.1.6", - "eslint-plugin-only-warn": "^1.1.0", "@microsoft/orchestrator-core": "~4.15.1", "uuid": "^10.0.0" }, @@ -45,7 +44,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": "yarn build && nyc mocha tests/", "test:compat": "api-extractor run --verbose" diff --git a/libraries/botbuilder-ai-orchestrator/src/orchestratorBotComponent.ts b/libraries/botbuilder-ai-orchestrator/src/orchestratorBotComponent.ts index ebde0032d9..be75f28dce 100644 --- a/libraries/botbuilder-ai-orchestrator/src/orchestratorBotComponent.ts +++ b/libraries/botbuilder-ai-orchestrator/src/orchestratorBotComponent.ts @@ -25,7 +25,7 @@ export class OrchestratorBotComponent extends BotComponent { }, ]; }, - }) + }), ); } } diff --git a/libraries/botbuilder-ai-orchestrator/src/orchestratorRecognizer.ts b/libraries/botbuilder-ai-orchestrator/src/orchestratorRecognizer.ts index e571ef22ee..4a204e9abd 100644 --- a/libraries/botbuilder-ai-orchestrator/src/orchestratorRecognizer.ts +++ b/libraries/botbuilder-ai-orchestrator/src/orchestratorRecognizer.ts @@ -24,7 +24,7 @@ import { AdaptiveRecognizer } from 'botbuilder-dialogs-adaptive'; import { Activity, RecognizerResult } from 'botbuilder-core'; import { Converter, ConverterFactory, DialogContext, Recognizer, RecognizerConfiguration } from 'botbuilder-dialogs'; -// eslint-disable-next-line @typescript-eslint/no-var-requires +//eslint-disable-next-line @typescript-eslint/no-require-imports const oc = require('@microsoft/orchestrator-core'); export interface OrchestratorRecognizerConfiguration extends RecognizerConfiguration { @@ -173,7 +173,7 @@ export class OrchestratorRecognizer extends AdaptiveRecognizer implements Orches dc: DialogContext, activity: Partial, telemetryProperties?: Record, - telemetryMetrics?: Record + telemetryMetrics?: Record, ): Promise { if (!this._resolver) { const modelFolder: string = this.modelFolder.getValue(dc.state); @@ -209,30 +209,28 @@ export class OrchestratorRecognizer extends AdaptiveRecognizer implements Orches // add all scores recognizerResult.intents = results.reduce(function ( intents: { [index: string]: { score: number } }, - result + result, ) { intents[result.label.name] = { score: result.score }; return intents; - }, - {}); + }, {}); recognizerResult.intents.None = { score: 1.0 }; } else { // add all scores recognizerResult.intents = results.reduce(function ( intents: { [index: string]: { score: number } }, - result + result, ) { intents[result.label.name] = { score: result.score }; return intents; - }, - {}); + }, {}); // disambiguate if (detectAmbiguity) { const disambiguationScoreThreshold = this.disambiguationScoreThreshold.getValue(dc.state); const classifyingScore = topScore - disambiguationScoreThreshold; const ambiguousResults = results.filter( - (item: { score: number }) => item.score >= classifyingScore + (item: { score: number }) => item.score >= classifyingScore, ); if (ambiguousResults.length > 1) { const recognizerResults: Record = ambiguousResults @@ -242,7 +240,7 @@ export class OrchestratorRecognizer extends AdaptiveRecognizer implements Orches alteredText: result.closest_text, entities: recognizerResult.entities, intents: { [result.label.name]: { score: result.score } }, - }) + }), ) .reduce((results: Record, result: RecognizerResult) => { const guid = uuidv4(); @@ -266,7 +264,7 @@ export class OrchestratorRecognizer extends AdaptiveRecognizer implements Orches dc, activity, telemetryProperties, - telemetryMetrics + telemetryMetrics, ); recognizerResult.entities = externalResults.entities; } @@ -277,13 +275,13 @@ export class OrchestratorRecognizer extends AdaptiveRecognizer implements Orches 'OrchestratorRecognizer', recognizerResult, 'OrchestratorRecognizer', - 'Orchestrator Recognition' + 'Orchestrator Recognition', ); this.trackRecognizerResult( dc, 'OrchestratorRecognizerResult', this.fillRecognizerResultTelemetryProperties(recognizerResult, telemetryProperties, dc), - telemetryMetrics + telemetryMetrics, ); return recognizerResult; @@ -318,7 +316,7 @@ export class OrchestratorRecognizer extends AdaptiveRecognizer implements Orches protected fillRecognizerResultTelemetryProperties( recognizerResult: RecognizerResult, telemetryProperties?: Record, - dialogContext?: DialogContext + dialogContext?: DialogContext, ): Record { const topTwo = this.getTopTwoIntents(recognizerResult); const intent = Object.entries(recognizerResult.intents); @@ -379,16 +377,19 @@ export class OrchestratorRecognizer extends AdaptiveRecognizer implements Orches this._orchestrator = OrchestratorRecognizer.orchestratorMap.has(fullModelFolder) ? OrchestratorRecognizer.orchestratorMap.get(fullModelFolder) : ((): OrchestratorDictionaryEntry => { + // eslint-disable-next-line security/detect-non-literal-fs-filename if (!existsSync(fullModelFolder)) { throw new Error(`Model folder does not exist at ${fullModelFolder}.`); } + const entityModelFolder: string = resolve(modelFolder, 'entity'); + // eslint-disable-next-line security/detect-non-literal-fs-filename const isEntityExtractionCapable: boolean = existsSync(entityModelFolder); const orchestrator = new oc.Orchestrator(); if (isEntityExtractionCapable) { if (!orchestrator.load(fullModelFolder, entityModelFolder)) { throw new Error( - `Model load failed - model folder ${fullModelFolder}, entity model folder ${entityModelFolder}.` + `Model load failed - model folder ${fullModelFolder}, entity model folder ${entityModelFolder}.`, ); } } else { @@ -405,11 +406,13 @@ export class OrchestratorRecognizer extends AdaptiveRecognizer implements Orches })(); const fullSnapshotPath = resolve(snapshotFile); + // eslint-disable-next-line security/detect-non-literal-fs-filename if (!existsSync(fullSnapshotPath)) { throw new Error(`Snapshot file does not exist at ${fullSnapshotPath}.`); } // Load the snapshot + // eslint-disable-next-line security/detect-non-literal-fs-filename const snapshot: Uint8Array = readFileSync(fullSnapshotPath); // Load snapshot and create resolver diff --git a/libraries/botbuilder-ai-orchestrator/tests/mockResolver.js b/libraries/botbuilder-ai-orchestrator/tests/mockResolver.js index 7e4cc78919..46331d40c6 100644 --- a/libraries/botbuilder-ai-orchestrator/tests/mockResolver.js +++ b/libraries/botbuilder-ai-orchestrator/tests/mockResolver.js @@ -3,8 +3,6 @@ * Licensed under the MIT License. */ -/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ - const { LabelType } = require('../lib'); class MockResolver { constructor(score, entityScore) {