From 925a2c6de80307a5d1cb0b9e478a86837f7ba9b2 Mon Sep 17 00:00:00 2001 From: Cecilia Avila <44245136+ceciliaavila@users.noreply.github.com> Date: Tue, 3 Dec 2024 18:51:34 -0300 Subject: [PATCH] fix: [#4684] ESLint issues in botbuilder-azure-blobs (#4802) * Fix ESLint issues in botbuilder-azure-blobs * Remove eslint-plugin-only-warn dependency --- libraries/botbuilder-azure-blobs/eslint.config.cjs | 10 ---------- libraries/botbuilder-azure-blobs/package.json | 3 +-- .../botbuilder-azure-blobs/src/blobsStorage.ts | 10 +++++----- .../src/blobsTranscriptStore.ts | 14 +++++++------- .../tests/blobsStorage.test.js | 5 +++-- .../tests/blobsTranscriptStore.test.js | 6 +++--- 6 files changed, 19 insertions(+), 29 deletions(-) delete mode 100644 libraries/botbuilder-azure-blobs/eslint.config.cjs diff --git a/libraries/botbuilder-azure-blobs/eslint.config.cjs b/libraries/botbuilder-azure-blobs/eslint.config.cjs deleted file mode 100644 index 63647b52cc..0000000000 --- a/libraries/botbuilder-azure-blobs/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-azure-blobs/package.json b/libraries/botbuilder-azure-blobs/package.json index 656322961d..0e34526d4b 100644 --- a/libraries/botbuilder-azure-blobs/package.json +++ b/libraries/botbuilder-azure-blobs/package.json @@ -30,7 +30,6 @@ "@azure/storage-blob": "^12.24.0", "botbuilder-core": "4.1.6", "botbuilder-stdlib": "4.1.6", - "eslint-plugin-only-warn": "^1.1.0", "p-map": "^4.0.0", "zod": "^3.23.8", "@azure/core-http": "^3.0.4" @@ -40,7 +39,7 @@ "build-docs": "typedoc --theme markdown --entryPoint botbuilder-azure-blobs --excludePrivate --includeDeclarations --ignoreCompilerErrors --module amd --out ..\\..\\doc\\botbuilder-azure-blobs .\\lib\\index.d.ts --hideGenerator --name \"Bot Builder SDK - Azure Blobs\" --readme none", "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 --check-leaks tests", "test:compat": "api-extractor run --verbose" diff --git a/libraries/botbuilder-azure-blobs/src/blobsStorage.ts b/libraries/botbuilder-azure-blobs/src/blobsStorage.ts index 985cd035c8..8b6825d89c 100644 --- a/libraries/botbuilder-azure-blobs/src/blobsStorage.ts +++ b/libraries/botbuilder-azure-blobs/src/blobsStorage.ts @@ -54,7 +54,7 @@ export class BlobsStorage implements Storage { containerName: string, options?: BlobsStorageOptions, url = '', - credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential + credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, ) { if (url != '' && credential != null) { z.object({ url: z.string() }).parse({ @@ -80,7 +80,7 @@ export class BlobsStorage implements Storage { this._containerClient = new ContainerClient( connectionString, containerName, - options?.storagePipelineOptions + options?.storagePipelineOptions, ); // At most one promise at a time to be friendly to local emulator users @@ -121,7 +121,7 @@ export class BlobsStorage implements Storage { const blob = await ignoreError( this._containerClient.getBlobClient(sanitizeBlobKey(key)).download(), - isStatusCodeError(404) + isStatusCodeError(404), ); if (!blob) { @@ -140,7 +140,7 @@ export class BlobsStorage implements Storage { }, { concurrency: this._concurrency, - } + }, ) ).reduce((acc, { key, value }) => (value ? { ...acc, [key]: value } : acc), {}); } @@ -196,7 +196,7 @@ export class BlobsStorage implements Storage { (key) => ignoreError(this._containerClient.deleteBlob(sanitizeBlobKey(key)), isStatusCodeError(404)), { concurrency: this._concurrency, - } + }, ); } } diff --git a/libraries/botbuilder-azure-blobs/src/blobsTranscriptStore.ts b/libraries/botbuilder-azure-blobs/src/blobsTranscriptStore.ts index 23f1919847..af31ec7e7c 100644 --- a/libraries/botbuilder-azure-blobs/src/blobsTranscriptStore.ts +++ b/libraries/botbuilder-azure-blobs/src/blobsTranscriptStore.ts @@ -44,7 +44,7 @@ function getBlobKey(activity: Activity, options?: BlobsTranscriptStoreOptions): return sanitizeBlobKey( [activity.channelId, activity.conversation.id, `${formatTicks(timestamp)}-${activity.id}.json`].join('/'), - options + options, ); } @@ -102,7 +102,7 @@ export class BlobsTranscriptStore implements TranscriptStore { containerName: string, options?: BlobsTranscriptStoreOptions, blobServiceUri = '', - tokenCredential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential + tokenCredential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, ) { if (blobServiceUri != '' && tokenCredential != null) { z.object({ blobServiceUri: z.string() }).parse({ @@ -116,7 +116,7 @@ export class BlobsTranscriptStore implements TranscriptStore { this._containerClient = new ContainerClient( blobServiceUri, tokenCredential, - options?.storagePipelineOptions + options?.storagePipelineOptions, ); // At most one promise at a time to be friendly to local emulator users @@ -132,7 +132,7 @@ export class BlobsTranscriptStore implements TranscriptStore { this._containerClient = new ContainerClient( connectionString, containerName, - options?.storagePipelineOptions + options?.storagePipelineOptions, ); // At most one promise at a time to be friendly to local emulator users @@ -170,7 +170,7 @@ export class BlobsTranscriptStore implements TranscriptStore { channelId: string, conversationId: string, continuationToken?: string, - startDate?: Date + startDate?: Date, ): Promise> { z.object({ channelId: z.string(), conversationId: z.string() }).parse({ channelId, conversationId }); @@ -195,7 +195,7 @@ export class BlobsTranscriptStore implements TranscriptStore { const fromIdx = startDate != null ? blobItems.findIndex( - (blobItem) => blobItem?.properties?.createdOn && blobItem?.properties?.createdOn >= startDate + (blobItem) => blobItem?.properties?.createdOn && blobItem?.properties?.createdOn >= startDate, ) : 0; @@ -213,7 +213,7 @@ export class BlobsTranscriptStore implements TranscriptStore { const activity = (await StreamConsumers.json(readableStreamBody)) as any; return { ...activity, timestamp: new Date(activity.timestamp) } as Activity; }, - { concurrency: this._concurrency } + { concurrency: this._concurrency }, ); activities.forEach((activity) => { diff --git a/libraries/botbuilder-azure-blobs/tests/blobsStorage.test.js b/libraries/botbuilder-azure-blobs/tests/blobsStorage.test.js index 348a4e7ce4..1a7fcb4dd8 100644 --- a/libraries/botbuilder-azure-blobs/tests/blobsStorage.test.js +++ b/libraries/botbuilder-azure-blobs/tests/blobsStorage.test.js @@ -26,7 +26,7 @@ describe('BlobsStorage', function () { assert.throws(() => new BlobsStorage(null, null, null, [], {}), 'throws for missing url'); assert.throws( () => new BlobsStorage(null, null, null, 'url', {}), - ReferenceError('Invalid credential type.') + ReferenceError('Invalid credential type.'), ); }); @@ -40,7 +40,7 @@ describe('BlobsStorage', function () { null, null, 'https://test.blob.core.windows.net/blob', - new StorageSharedKeyCredential('accountName', 'accountKey') + new StorageSharedKeyCredential('accountName', 'accountKey'), ); }); }); @@ -102,6 +102,7 @@ describe('BlobsStorage', function () { } let sandbox; + beforeEach(function () { sandbox = sinon.createSandbox({}); }); diff --git a/libraries/botbuilder-azure-blobs/tests/blobsTranscriptStore.test.js b/libraries/botbuilder-azure-blobs/tests/blobsTranscriptStore.test.js index 0399ad5255..96dc2157d5 100644 --- a/libraries/botbuilder-azure-blobs/tests/blobsTranscriptStore.test.js +++ b/libraries/botbuilder-azure-blobs/tests/blobsTranscriptStore.test.js @@ -72,7 +72,7 @@ describe('BlobsTranscriptStore', function () { assert.throws(() => new BlobsTranscriptStore(null, null, null, [], {}), 'throws for missing url'); assert.throws( () => new BlobsTranscriptStore(null, null, null, 'url', {}), - ReferenceError('Invalid credential type.') + ReferenceError('Invalid credential type.'), ); }); @@ -110,7 +110,7 @@ describe('BlobsTranscriptStore', function () { channelId, conversationId, undefined, - rest[0].timestamp + rest[0].timestamp, ); assert.deepStrictEqual(result.items, rest); }); @@ -154,7 +154,7 @@ describe('BlobsTranscriptStore', function () { channelId, id, created, - })) + })), ); }); });