diff --git a/libraries/botbuilder-dialogs-declarative/eslint.config.cjs b/libraries/botbuilder-dialogs-declarative/eslint.config.cjs deleted file mode 100644 index 63647b52cc..0000000000 --- a/libraries/botbuilder-dialogs-declarative/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-declarative/package.json b/libraries/botbuilder-dialogs-declarative/package.json index f44b9e5206..2d615130b1 100644 --- a/libraries/botbuilder-dialogs-declarative/package.json +++ b/libraries/botbuilder-dialogs-declarative/package.json @@ -31,7 +31,6 @@ "botbuilder-dialogs": "4.1.6", "botbuilder-stdlib": "4.1.6", "chokidar": "^3.6.0", - "eslint-plugin-only-warn": "^1.1.0", "zod": "^3.23.8" }, "devDependencies": { @@ -45,7 +44,7 @@ "build-docs": "typedoc --theme markdown --entryPoint botbuilder-dialogs-adaptive --excludePrivate --includeDeclarations --ignoreCompilerErrors --module amd --out ..\\..\\doc\\botbuilder-dialogs .\\lib\\index.d.ts --hideGenerator --name \"Bot Builder SDK - Dialogs\" --readme none", "clean": "rimraf _ts3.4 lib tsconfig.tsbuildinfo", "depcheck": "depcheck --config ../../.depcheckrc --ignores botbuilder-ai,botbuilder-dialogs-adaptive", - "lint": "eslint .", + "lint": "eslint . --config ../../eslint.config.cjs", "postbuild": "downlevel-dts lib _ts3.4/lib --checksum", "test": "yarn build && nyc mocha tests/**/*.test.js --exit", "test:compat": "api-extractor run --verbose" diff --git a/libraries/botbuilder-dialogs-declarative/src/componentDeclarativeTypes.ts b/libraries/botbuilder-dialogs-declarative/src/componentDeclarativeTypes.ts index 6ff9196107..e4f06c14d9 100644 --- a/libraries/botbuilder-dialogs-declarative/src/componentDeclarativeTypes.ts +++ b/libraries/botbuilder-dialogs-declarative/src/componentDeclarativeTypes.ts @@ -19,7 +19,7 @@ export interface ComponentDeclarativeTypes { const componentDeclarativeTypes = z.custom( (val: any) => typeof val.getDeclarativeTypes === 'function', - { message: 'ComponentDeclarativeTypes' } + { message: 'ComponentDeclarativeTypes' }, ); /** diff --git a/libraries/botbuilder-dialogs-declarative/src/pathUtil.ts b/libraries/botbuilder-dialogs-declarative/src/pathUtil.ts index 48d3b12a1c..1ee033356f 100644 --- a/libraries/botbuilder-dialogs-declarative/src/pathUtil.ts +++ b/libraries/botbuilder-dialogs-declarative/src/pathUtil.ts @@ -20,6 +20,7 @@ export class PathUtil { * @returns True if the path is a directory; false otherwise. */ static isDirectory(path: string): boolean { + // eslint-disable-next-line security/detect-non-literal-fs-filename return lstatSync(path).isDirectory(); } @@ -30,6 +31,7 @@ export class PathUtil { * @returns Sub folders in the directory. */ static getDirectories(path: string): string[] { + // eslint-disable-next-line security/detect-non-literal-fs-filename return readdirSync(path) .map((name: string): string => join(path, name)) .filter(PathUtil.isDirectory); @@ -43,6 +45,7 @@ export class PathUtil { * @returns The files in the directory. */ static getFiles(path: string, includeSubFolders = true): string[] { + // eslint-disable-next-line security/detect-non-literal-fs-filename return readdirSync(path) .map((name: string): string => join(path, name)) .reduce((files: string[], file: string): string[] => { diff --git a/libraries/botbuilder-dialogs-declarative/src/resources/fileResource.ts b/libraries/botbuilder-dialogs-declarative/src/resources/fileResource.ts index 04ed6a551f..21da8ec0dc 100644 --- a/libraries/botbuilder-dialogs-declarative/src/resources/fileResource.ts +++ b/libraries/botbuilder-dialogs-declarative/src/resources/fileResource.ts @@ -1,4 +1,3 @@ -/* eslint-disable security/detect-non-literal-fs-filename */ /** * @module botbuilder-dialogs-declarative */ @@ -7,7 +6,7 @@ * Licensed under the MIT License. */ -import fs = require('fs'); +import { readFileSync } from 'fs'; import { Resource } from './resource'; /** @@ -33,7 +32,8 @@ export class FileResource extends Resource { */ readText(): string { const filePath = this._fullname; - const text = fs.readFileSync(filePath, 'utf-8'); + // eslint-disable-next-line security/detect-non-literal-fs-filename + const text = readFileSync(filePath, 'utf-8'); return text; } } diff --git a/libraries/botbuilder-dialogs-declarative/src/resources/folderResourceProvider.ts b/libraries/botbuilder-dialogs-declarative/src/resources/folderResourceProvider.ts index 3fa2505547..f2a6b11f74 100644 --- a/libraries/botbuilder-dialogs-declarative/src/resources/folderResourceProvider.ts +++ b/libraries/botbuilder-dialogs-declarative/src/resources/folderResourceProvider.ts @@ -73,7 +73,7 @@ export class FolderResourceProvider extends ResourceProvider { this._resources.clear(); const files: string[] = PathUtil.getFiles(this.directory, this.includeSubFolders); const filteredFiles: string[] = files.filter((filename): boolean => - this.resourceExplorer.resourceTypes.has(extname(filename).toLowerCase().replace(/^\./, '')) + this.resourceExplorer.resourceTypes.has(extname(filename).toLowerCase().replace(/^\./, '')), ); for (let i = 0; i < filteredFiles.length; i++) { const filename = filteredFiles[i]; diff --git a/libraries/botbuilder-dialogs-declarative/src/resources/resourceExplorer.ts b/libraries/botbuilder-dialogs-declarative/src/resources/resourceExplorer.ts index 882618087f..399057dc59 100644 --- a/libraries/botbuilder-dialogs-declarative/src/resources/resourceExplorer.ts +++ b/libraries/botbuilder-dialogs-declarative/src/resources/resourceExplorer.ts @@ -208,7 +208,7 @@ export class ResourceExplorer { registerType( kind: string, type: Newable, - loader?: CustomDeserializer> + loader?: CustomDeserializer>, ): ResourceExplorer { this.registerComponentTypes(); this.registerTypeInternal(kind, type, loader); @@ -286,7 +286,7 @@ export class ResourceExplorer { return value; } return this.load(value as { $kind: string } & Record); - }) + }), ); if (result instanceof Dialog && !config['id']) { diff --git a/libraries/botbuilder-dialogs-declarative/tests/jsonLoad.test.js b/libraries/botbuilder-dialogs-declarative/tests/jsonLoad.test.js index c168751e18..aa60255286 100644 --- a/libraries/botbuilder-dialogs-declarative/tests/jsonLoad.test.js +++ b/libraries/botbuilder-dialogs-declarative/tests/jsonLoad.test.js @@ -201,7 +201,7 @@ const buildQnAMakerTestFlowPreciseAnswer = ( resourceExplorer, testName, enablePreciseAnswer, - displayPreciseAnswerOnly + displayPreciseAnswerOnly, ) => { const adapter = initializeAdapter(testName); const dialog = resourceExplorer.loadType('QnAMakerBot.main.dialog'); @@ -213,6 +213,7 @@ const buildQnAMakerTestFlowPreciseAnswer = ( describe('Json load tests', function () { let resourceExplorer; + beforeEach(function () { const services = new ServiceCollection({ declarativeTypes: [], @@ -226,7 +227,7 @@ describe('Json load tests', function () { resourceExplorer = new ResourceExplorer({ declarativeTypes }).addFolder( path.join(__dirname, 'resources/JsonDialog'), true, - false + false, ); }); @@ -510,7 +511,7 @@ describe('Json load tests', function () { const suggestionActivity = QnACardBuilder.getSuggestionsCard( suggestionList, 'Did you mean:', - 'None of the above.' + 'None of the above.', ); await buildQnAMakerTestFlow(resourceExplorer, this.fullTitle()) .send('Q11') @@ -528,7 +529,7 @@ describe('Json load tests', function () { const suggestionActivity = QnACardBuilder.getSuggestionsCard( suggestionList, 'Did you mean:', - 'None of the above.' + 'None of the above.', ); const noAnswerActivity = 'No QnAMaker answers found.'; await buildQnAMakerTestFlow(resourceExplorer, this.fullTitle()) @@ -547,7 +548,7 @@ describe('Json load tests', function () { const suggestionActivity = QnACardBuilder.getSuggestionsCard( suggestionList, 'Did you mean:', - 'None of the above.' + 'None of the above.', ); await buildQnAMakerTestFlow(resourceExplorer, this.fullTitle()) .send('Q11') diff --git a/libraries/botbuilder-dialogs-declarative/tests/resourceExplorer.test.js b/libraries/botbuilder-dialogs-declarative/tests/resourceExplorer.test.js index 4714a62cb7..68033438cb 100644 --- a/libraries/botbuilder-dialogs-declarative/tests/resourceExplorer.test.js +++ b/libraries/botbuilder-dialogs-declarative/tests/resourceExplorer.test.js @@ -19,7 +19,7 @@ function assertResourceFound(explorer, id) { const dialogs = explorer.getResources('dialog'); assert( dialogs.some((dialog) => dialog.id == id), - "getResources('dialog') should return resources" + "getResources('dialog') should return resources", ); } @@ -29,7 +29,7 @@ function assertResourceNotFound(explorer, id) { const dialogs = explorer.getResources('dialog'); assert( dialogs.every((dialog) => dialog.id != id), - "getResouces('dialog') should not return resources" + "getResouces('dialog') should not return resources", ); } @@ -110,7 +110,7 @@ describe('ResourceExplorer', function () { assert.strictEqual( dialog.id, 'test.dialog', - 'resource id should be used as default dialog id if none assigned.' + 'resource id should be used as default dialog id if none assigned.', ); assert.strictEqual(dialog.triggers[0].actions[0].id, '1234567890'); assert.strictEqual(dialog.triggers[0].actions[1].id, 'test3.dialog'); @@ -275,7 +275,7 @@ describe('ResourceExplorer', function () { const resourceExplorer = new ResourceExplorer({ declarativeTypes }).addFolder( join(__dirname, './resources/CycleDetection'), false, - false + false, ); const root = resourceExplorer.loadType('root.dialog'); diff --git a/libraries/botbuilder-dialogs-declarative/tests/schemaMergeTest.js b/libraries/botbuilder-dialogs-declarative/tests/schemaMergeTest.js index cc858cae7b..33d29d243b 100644 --- a/libraries/botbuilder-dialogs-declarative/tests/schemaMergeTest.js +++ b/libraries/botbuilder-dialogs-declarative/tests/schemaMergeTest.js @@ -4,7 +4,6 @@ const assert = require('assert'); const fs = require('fs'); const Validator = require('jsonschema').Validator; const util = require('util'); -// eslint-disable-next-line security/detect-child-process const exec = util.promisify(require('child_process').exec); // Note: This file is intentionally not named *.test.js to ensure it isn't run @@ -30,7 +29,7 @@ describe('Schema Merge Tests', function () { resourceExplorer, path.join(__dirname, '..', '..'), true, - false + false, ); const dialogResources = resourceProvider.getResources('dialog'); const dialogs = dialogResources @@ -92,7 +91,7 @@ describe('Schema Merge Tests', function () { [ 'Generated schema differs from committed schema.', 'Run this test locally and commit the tests.*schema files to upload the correct and updated schema.', - ].join('\n') + ].join('\n'), ); }