diff --git a/.eslintrc.js b/.eslintrc.js index 36cb9719..27423b8f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -59,7 +59,7 @@ module.exports = { 'overrides': [ // JavaScript specific rules { - 'files': ['**/*.js'], + 'files': ['**/*.js', '**/*.mjs'], 'plugins': ['node', 'prettier'], 'extends': ['airbnb-base', 'prettier'], 'rules': { @@ -117,11 +117,15 @@ module.exports = { }, 'plugins': ['jest'], 'extends': ['plugin:jest/recommended', 'plugin:jest/style'], + 'rules': { + 'no-console': 'off', + 'import/namespace': 'off', + 'import/no-unresolved': 'off', + }, }, { 'files': ['test/**/*.test.js', 'test/**/*.test.mjs'], 'rules': { - 'import/namespace': 'off', 'jest/expect-expect': 'off', 'jest/no-conditional-expect': 'off', 'jest/no-done-callback': 'off', diff --git a/.secrets.baseline b/.secrets.baseline index f96595f5..c11b3636 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "stubs/.+\\.json|package-lock.json|^.secrets.baseline$", "lines": null }, - "generated_at": "2024-09-17T19:31:39Z", + "generated_at": "2024-09-18T13:10:46Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -244,7 +244,7 @@ "hashed_secret": "37fa265330ad83eaa879efb1e2db6380896cf639", "is_secret": false, "is_verified": false, - "line_number": 83, + "line_number": 87, "type": "Secret Keyword", "verified_result": null }, @@ -252,7 +252,7 @@ "hashed_secret": "673089c80cdcfa4702d190544ea675affacf60ab", "is_secret": false, "is_verified": false, - "line_number": 97, + "line_number": 101, "type": "Secret Keyword", "verified_result": null }, @@ -260,7 +260,7 @@ "hashed_secret": "c2a6b03f190dfb2b4aa91f8af8d477a9bc3401dc", "is_secret": false, "is_verified": false, - "line_number": 136, + "line_number": 140, "type": "Secret Keyword", "verified_result": null }, @@ -268,7 +268,7 @@ "hashed_secret": "d4c3d66fd0c38547a3c7a4c6bdc29c36911bc030", "is_secret": false, "is_verified": false, - "line_number": 137, + "line_number": 141, "type": "Secret Keyword", "verified_result": null } diff --git a/test/integration/readme.integration.test.mjs b/test/integration/readme.integration.test.mjs index 58c1b6ff..9eb07e69 100644 --- a/test/integration/readme.integration.test.mjs +++ b/test/integration/readme.integration.test.mjs @@ -15,7 +15,7 @@ */ import { request as httpRequest } from 'node:http'; import { readFileSync } from 'node:fs'; -import { default as sinon } from 'sinon'; +import * as sinon from 'sinon'; import { getInfoFromExistingDatabase } from '../examples/src/js/GetInfoFromExistingDatabase'; import { createDbAndDoc } from '../examples/src/js/CreateDbAndDoc'; import { updateDoc } from '../examples/src/js/UpdateDoc'; @@ -151,8 +151,8 @@ describe('Readme integration tests', () => { .map((a) => a.args[0]) .join('\n'); expect(consoleOutput).toBe( - 'Cannot delete document because either "orders" database' - + ' or the "example" document was not found.' + 'Cannot delete document because either "orders" database' + + ' or the "example" document was not found.' ); }); }); diff --git a/test/integration/timeout.integration.test.mjs b/test/integration/timeout.integration.test.mjs index d9e1f02a..df98089f 100644 --- a/test/integration/timeout.integration.test.mjs +++ b/test/integration/timeout.integration.test.mjs @@ -15,9 +15,13 @@ */ import assert from 'node:assert'; -import { default as sinon } from 'sinon'; +import * as sinon from 'sinon'; -import { BasicAuthenticator, IamAuthenticator, NoAuthAuthenticator } from 'ibm-cloud-sdk-core'; +import { + BasicAuthenticator, + IamAuthenticator, + NoAuthAuthenticator, +} from 'ibm-cloud-sdk-core'; import { CloudantV1, CouchdbSessionAuthenticator } from '../../index'; const DEFAULT_TIMEOUT = 150000; // (2.5m=150s) diff --git a/test/unit/cloudantBaseService.test.mjs b/test/unit/cloudantBaseService.test.mjs index 0793534a..cb741440 100644 --- a/test/unit/cloudantBaseService.test.mjs +++ b/test/unit/cloudantBaseService.test.mjs @@ -22,7 +22,7 @@ import { IamAuthenticator, NoAuthAuthenticator, } from 'ibm-cloud-sdk-core'; -import { default as sinon } from 'sinon'; +import * as sinon from 'sinon'; import { CookieJar, MemoryCookieStore } from 'tough-cookie'; import CloudantBaseService from '../../lib/cloudantBaseService'; import { CouchdbSessionAuthenticator } from '../../index'; diff --git a/test/unit/couchdbSessionAuthenticator.test.mjs b/test/unit/couchdbSessionAuthenticator.test.mjs index baaaf736..ece168a0 100644 --- a/test/unit/couchdbSessionAuthenticator.test.mjs +++ b/test/unit/couchdbSessionAuthenticator.test.mjs @@ -15,7 +15,7 @@ */ import assert from 'node:assert'; import { promisify } from 'node:util'; -import { default as sinon } from 'sinon'; +import * as sinon from 'sinon'; import { CookieJar } from 'tough-cookie'; import { CouchdbSessionAuthenticator } from '../../index'; import { SessionTokenManager } from '../../auth/sessionTokenManager'; diff --git a/test/unit/features/changesFollower.test.mjs b/test/unit/features/changesFollower.test.mjs index b02d6133..b22854b9 100644 --- a/test/unit/features/changesFollower.test.mjs +++ b/test/unit/features/changesFollower.test.mjs @@ -159,8 +159,8 @@ describe('Test ChangesFollower', () => { minimumTestParams ); }).toThrow( - `To use ChangesFollower the client read timeout must be at least 60000 ms.` - + ` The client read timeout is ${client.getTimeout()} ms.` + `To use ChangesFollower the client read timeout must be at least 60000 ms.` + + ` The client read timeout is ${client.getTimeout()} ms.` ); } ); diff --git a/test/unit/features/changesResultIterator.test.mjs b/test/unit/features/changesResultIterator.test.mjs index 6f3364a5..dd83ac99 100644 --- a/test/unit/features/changesResultIterator.test.mjs +++ b/test/unit/features/changesResultIterator.test.mjs @@ -14,21 +14,32 @@ * limitations under the License. */ -import { Action, getClient, getModes, getSuppressionSequences } from './testDataProviders'; import { - ChangesResultIterableIterator -} from '../../../cloudant/features/changesResultIterator'; + Action, + getClient, + getModes, + getSuppressionSequences, +} from './testDataProviders'; +import { ChangesResultIterableIterator } from '../../../cloudant/features/changesResultIterator'; import { testParams } from './testParams'; import { generateRandomChangesResults, mockPerpetualSupplier, perpetualSupplierResponse, mockPostChangesError, - mockPerptualSupplierRespectingLimit + mockPerptualSupplierRespectingLimit, } from './testMocks'; import { ChangesParamsHelper } from '../../../cloudant/features/changesParamsHelper'; -import { ChangesFollower, Mode } from '../../../cloudant/features/changesFollower'; -import { getTransientErrors, getTerminalErrors, getErrors, MockError } from './mockErrors'; +import { + ChangesFollower, + Mode, +} from '../../../cloudant/features/changesFollower'; +import { + getTransientErrors, + getTerminalErrors, + getErrors, + MockError, +} from './mockErrors'; import { delay } from './testUtils'; const service = getClient(); diff --git a/test/unit/features/testDataProviders.mjs b/test/unit/features/testDataProviders.mjs index b2379837..5a29cf8e 100644 --- a/test/unit/features/testDataProviders.mjs +++ b/test/unit/features/testDataProviders.mjs @@ -16,7 +16,10 @@ import { NoAuthAuthenticator } from 'ibm-cloud-sdk-core'; import { testParams } from './testParams'; -import { ChangesFollower, Mode } from '../../../cloudant/features/changesFollower'; +import { + ChangesFollower, + Mode, +} from '../../../cloudant/features/changesFollower'; import CloudantV1 from '../../../cloudant/v1'; import { ChangesParamsHelper } from '../../../cloudant/features/changesParamsHelper'; diff --git a/test/unit/features/testMocks.mjs b/test/unit/features/testMocks.mjs index fd2533e1..804aecc7 100644 --- a/test/unit/features/testMocks.mjs +++ b/test/unit/features/testMocks.mjs @@ -14,10 +14,12 @@ * limitations under the License. */ -import { NoAuthAuthenticator } from 'ibm-cloud-sdk-core'; +import * as core from 'ibm-cloud-sdk-core'; import { ChangesFollower } from '../../../cloudant/features/changesFollower'; import { getTransientErrors } from './mockErrors'; +const { NoAuthAuthenticator } = core; + function mockAuthenticator() { const authenticatorMock = jest.spyOn(core, 'getAuthenticatorFromEnvironment'); authenticatorMock.mockImplementation(() => new NoAuthAuthenticator()); diff --git a/test/unit/features/testParams.mjs b/test/unit/features/testParams.mjs index e27a2699..fbe9f8ec 100644 --- a/test/unit/features/testParams.mjs +++ b/test/unit/features/testParams.mjs @@ -165,8 +165,9 @@ const testParams = { timeout: 3600000, ...minimumTestParams, }, - expectedError: `${beginningOfErrorMsg}s 'descending', 'feed', 'heartbeat',` - + ` 'lastEventId', 'timeout' are ${endOfErrorMsg}`, + expectedError: + `${beginningOfErrorMsg}s 'descending', 'feed', 'heartbeat',` + + ` 'lastEventId', 'timeout' are ${endOfErrorMsg}`, }, }; diff --git a/test/unit/getAuthenticatorFromEnvCloudantExtension.test.mjs b/test/unit/getAuthenticatorFromEnvCloudantExtension.test.mjs index f52c24f5..2822306b 100644 --- a/test/unit/getAuthenticatorFromEnvCloudantExtension.test.mjs +++ b/test/unit/getAuthenticatorFromEnvCloudantExtension.test.mjs @@ -15,8 +15,7 @@ */ import assert from 'node:assert'; import { BasicAuthenticator } from 'ibm-cloud-sdk-core'; -import getAuthenticatorFromEnvCloudantExtension - from '../../lib/getAuthenticatorFromEnvCloudantExtension'; +import getAuthenticatorFromEnvCloudantExtension from '../../lib/getAuthenticatorFromEnvCloudantExtension'; import { CouchdbSessionAuthenticator } from '../../index'; describe('Test getAuthenticatorFromEnvCloudantExtension', () => { diff --git a/test/unit/sessionTokenManager.test.mjs b/test/unit/sessionTokenManager.test.mjs index c5137954..ec64e4f8 100644 --- a/test/unit/sessionTokenManager.test.mjs +++ b/test/unit/sessionTokenManager.test.mjs @@ -15,7 +15,7 @@ */ import assert from 'node:assert'; -import { default as sinon } from 'sinon'; +import * as sinon from 'sinon'; import { CookieJar } from 'tough-cookie'; import { SessionTokenManager } from '../../auth/sessionTokenManager';