Skip to content

Commit

Permalink
refactor: run all linters on mjs
Browse files Browse the repository at this point in the history
  • Loading branch information
eiri committed Sep 18, 2024
1 parent 99f918a commit c1d9576
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 29 deletions.
8 changes: 6 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = {
'overrides': [
// JavaScript specific rules
{
'files': ['**/*.js'],
'files': ['**/*.js', '**/*.mjs'],
'plugins': ['node', 'prettier'],
'extends': ['airbnb-base', 'prettier'],
'rules': {
Expand Down Expand Up @@ -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',
Expand Down
10 changes: 5 additions & 5 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -244,31 +244,31 @@
"hashed_secret": "37fa265330ad83eaa879efb1e2db6380896cf639",
"is_secret": false,
"is_verified": false,
"line_number": 83,
"line_number": 87,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "673089c80cdcfa4702d190544ea675affacf60ab",
"is_secret": false,
"is_verified": false,
"line_number": 97,
"line_number": 101,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "c2a6b03f190dfb2b4aa91f8af8d477a9bc3401dc",
"is_secret": false,
"is_verified": false,
"line_number": 136,
"line_number": 140,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "d4c3d66fd0c38547a3c7a4c6bdc29c36911bc030",
"is_secret": false,
"is_verified": false,
"line_number": 137,
"line_number": 141,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down
6 changes: 3 additions & 3 deletions test/integration/readme.integration.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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.'
);
});
});
8 changes: 6 additions & 2 deletions test/integration/timeout.integration.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/unit/cloudantBaseService.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion test/unit/couchdbSessionAuthenticator.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions test/unit/features/changesFollower.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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.`
);
}
);
Expand Down
23 changes: 17 additions & 6 deletions test/unit/features/changesResultIterator.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion test/unit/features/testDataProviders.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
4 changes: 3 additions & 1 deletion test/unit/features/testMocks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
5 changes: 3 additions & 2 deletions test/unit/features/testParams.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
},
};

Expand Down
3 changes: 1 addition & 2 deletions test/unit/getAuthenticatorFromEnvCloudantExtension.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/sessionTokenManager.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit c1d9576

Please sign in to comment.