diff --git a/src/deviceOauthService.ts b/src/deviceOauthService.ts index e565c64620..1be7e485e4 100644 --- a/src/deviceOauthService.ts +++ b/src/deviceOauthService.ts @@ -11,7 +11,7 @@ import Transport from 'jsforce/lib/transport'; import { AsyncCreatable, Duration, parseJsonMap } from '@salesforce/kit'; import { HttpRequest, OAuth2Config } from 'jsforce'; import { ensureString, JsonMap, Nullable } from '@salesforce/ts-types'; -import * as FormData from 'form-data'; +import FormData from 'form-data'; import { Logger } from './logger/logger'; import { AuthInfo, DEFAULT_CONNECTED_APP_INFO, SFDX_HTTP_HEADERS } from './org'; import { SfError } from './sfError'; diff --git a/src/org/connection.ts b/src/org/connection.ts index 19680cfb22..0880717170 100644 --- a/src/org/connection.ts +++ b/src/org/connection.ts @@ -8,7 +8,7 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */ import { URL } from 'url'; -import { AsyncResult, DeployOptions, DeployResultLocator } from 'jsforce/api/metadata'; +import type { AsyncResult, DeployOptions, DeployResultLocator } from 'jsforce/lib/api/metadata'; import { Duration, env, maxBy } from '@salesforce/kit'; import { asString, ensure, isString, JsonMap, Optional } from '@salesforce/ts-types'; import { diff --git a/src/status/streamingClient.ts b/src/status/streamingClient.ts index 700a911555..ac50a92d94 100644 --- a/src/status/streamingClient.ts +++ b/src/status/streamingClient.ts @@ -8,7 +8,7 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */ import { resolve as resolveUrl } from 'url'; -import { AsyncOptionalCreatable, Duration, Env, env, set } from '@salesforce/kit/lib'; +import { AsyncOptionalCreatable, Duration, Env, env, set } from '@salesforce/kit'; import { AnyFunction, AnyJson, ensure, ensureString, JsonMap } from '@salesforce/ts-types/lib'; import * as Faye from 'faye'; import { Logger } from '../logger/logger'; diff --git a/src/util/sfdc.ts b/src/util/sfdc.ts index 848d936a7f..2c144eca9b 100644 --- a/src/util/sfdc.ts +++ b/src/util/sfdc.ts @@ -81,7 +81,7 @@ export const validatePathDoesNotContainInvalidChars = (value: string): boolean = */ export const findUpperCaseKeys = (data?: JsonMap, sectionBlocklist: string[] = []): Optional => { let key: Optional; - findKey(data, (val: AnyJson, k: string) => { + findKey(data, (val: AnyJson | undefined, k: string) => { if (/^[A-Z]/.test(k)) { key = k; } else if (isJsonMap(val)) { diff --git a/src/util/zipWriter.ts b/src/util/zipWriter.ts index a53bf89f1b..c0666bba7c 100644 --- a/src/util/zipWriter.ts +++ b/src/util/zipWriter.ts @@ -6,7 +6,7 @@ */ import { Readable, Writable } from 'stream'; -import * as JSZip from 'jszip'; +import JSZip from 'jszip'; import { Logger } from '../logger/logger'; import { SfError } from '../sfError'; import { StructuredWriter } from './structuredWriter'; diff --git a/test/tsconfig.json b/test/tsconfig.json index 9bd21999ad..e71a47e987 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -4,6 +4,9 @@ "compilerOptions": { "noEmit": true, "skipLibCheck": true, - "resolveJsonModule": true + "resolveJsonModule": true, + "moduleResolution": "Node16", + "module": "Node16", + "esModuleInterop": true } } diff --git a/test/unit/config/configAggregatorTest.ts b/test/unit/config/configAggregatorTest.ts index 6c820506e3..7fd0a27bfd 100644 --- a/test/unit/config/configAggregatorTest.ts +++ b/test/unit/config/configAggregatorTest.ts @@ -6,7 +6,7 @@ */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-call */ -import * as fs from 'fs'; +import fs from 'fs'; import { assert, expect, config as chaiConfig } from 'chai'; import { Config, ConfigProperties, SFDX_ALLOWED_PROPERTIES, SfdxPropertyKeys } from '../../../src/config/config'; import { ConfigAggregator, ConfigInfo } from '../../../src/config/configAggregator'; diff --git a/test/unit/config/configFileTest.ts b/test/unit/config/configFileTest.ts index 5e806d58a5..55b19bd928 100644 --- a/test/unit/config/configFileTest.ts +++ b/test/unit/config/configFileTest.ts @@ -7,8 +7,8 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-call */ -import * as Path from 'path'; -import * as fs from 'fs'; +import path from 'path'; +import fs from 'fs'; import { expect } from 'chai'; import { assert } from '@salesforce/ts-types'; @@ -71,10 +71,10 @@ describe('Config', () => { expect(config.getPath()).to.not.contain('.sf'); }); it('using local custom folder', () => { - const config = new TestConfig(TestConfig.getOptions('test', false, false, Path.join('my', 'path'))); + const config = new TestConfig(TestConfig.getOptions('test', false, false, path.join('my', 'path'))); expect(config.getPath()).to.contain(TestConfig.getTestLocalPath()); expect(config.getPath()).to.not.contain('.sf'); - expect(config.getPath()).to.contain(Path.join('my', 'path', 'test')); + expect(config.getPath()).to.contain(path.join('my', 'path', 'test')); }); }); describe('creation', () => { @@ -102,10 +102,10 @@ describe('Config', () => { expect(config.getPath()).to.not.contain('.sf'); }); it('using local custom folder', async () => { - const config = await TestConfig.create(TestConfig.getOptions('test', false, false, Path.join('my', 'path'))); + const config = await TestConfig.create(TestConfig.getOptions('test', false, false, path.join('my', 'path'))); expect(config.getPath()).to.contain(TestConfig.getTestLocalPath()); expect(config.getPath()).to.not.contain('.sf'); - expect(config.getPath()).to.contain(Path.join('my', 'path', 'test')); + expect(config.getPath()).to.contain(path.join('my', 'path', 'test')); }); }); diff --git a/test/unit/crypto/cryptoKeyFailuresTest.ts b/test/unit/crypto/cryptoKeyFailuresTest.ts index f7af64c085..b75b077057 100644 --- a/test/unit/crypto/cryptoKeyFailuresTest.ts +++ b/test/unit/crypto/cryptoKeyFailuresTest.ts @@ -6,9 +6,9 @@ */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ -import * as childProcess from 'child_process'; -import * as _crypto from 'crypto'; -import * as os from 'os'; +import childProcess from 'child_process'; +import crypto from 'crypto'; +import os from 'os'; import { AnyJson } from '@salesforce/ts-types'; import { assert, expect } from 'chai'; import { Crypto } from '../../../src/crypto/crypto'; @@ -67,7 +67,7 @@ if (os.platform() === 'darwin') { // Setup stubs so that the spawn process to the encryption program returns // a fake to cause errors. // @ts-expect-error - type mismatch - $$.SANDBOX.stub(_crypto, 'randomBytes').returns(buf); + $$.SANDBOX.stub(crypto, 'randomBytes').returns(buf); const spawnStub = $$.SANDBOX.stub(childProcess, 'spawn'); // @ts-expect-error - number of arguments spawnStub.withArgs(programArg, getOptionsArg).returns(spawnReturnFake); diff --git a/test/unit/crypto/cryptoTest.ts b/test/unit/crypto/cryptoTest.ts index 02cc8f1f05..aba622769f 100644 --- a/test/unit/crypto/cryptoTest.ts +++ b/test/unit/crypto/cryptoTest.ts @@ -6,7 +6,7 @@ */ /* eslint-disable @typescript-eslint/ban-types */ -import * as os from 'os'; +import os from 'os'; import { stubMethod } from '@salesforce/ts-sinon'; import { expect } from 'chai'; import { Crypto } from '../../../src/crypto/crypto'; diff --git a/test/unit/crypto/keyChainImplTest.ts b/test/unit/crypto/keyChainImplTest.ts index c597dba2b7..a217355989 100644 --- a/test/unit/crypto/keyChainImplTest.ts +++ b/test/unit/crypto/keyChainImplTest.ts @@ -11,7 +11,7 @@ /* eslint-disable no-underscore-dangle */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ -import * as fs from 'fs'; +import fs from 'fs'; import { assert, expect } from 'chai'; import { KeychainAccess, keyChainImpl } from '../../../src/crypto/keyChainImpl'; import { shouldThrow, TestContext } from '../../../src/testSetup'; diff --git a/test/unit/crypto/secureStringTest.ts b/test/unit/crypto/secureStringTest.ts index e7548433ef..2dd51e059d 100644 --- a/test/unit/crypto/secureStringTest.ts +++ b/test/unit/crypto/secureStringTest.ts @@ -4,7 +4,7 @@ * Licensed under the BSD 3-Clause license. * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ -import * as crypto from 'crypto'; +import crypto from 'crypto'; import { expect } from 'chai'; import { stub } from 'sinon'; import { SecureBuffer } from '../../../src/crypto/secureBuffer'; diff --git a/test/unit/lifecycleEventsTest.ts b/test/unit/lifecycleEventsTest.ts index d84a4a9121..4a41069144 100644 --- a/test/unit/lifecycleEventsTest.ts +++ b/test/unit/lifecycleEventsTest.ts @@ -6,7 +6,7 @@ */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ -import { Duration, sleep } from '@salesforce/kit/lib/duration'; +import { Duration, sleep } from '@salesforce/kit'; import { spyMethod } from '@salesforce/ts-sinon'; import * as chai from 'chai'; import { Lifecycle } from '../../src/lifecycleEvents'; diff --git a/test/unit/messagesTest.ts b/test/unit/messagesTest.ts index e283481a54..34c2d0cf25 100644 --- a/test/unit/messagesTest.ts +++ b/test/unit/messagesTest.ts @@ -7,8 +7,8 @@ /* eslint-disable @typescript-eslint/no-unsafe-argument */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ -import * as fs from 'fs'; -import * as path from 'path'; +import fs from 'fs'; +import path from 'path'; import { EOL } from 'os'; import { cloneJson } from '@salesforce/kit'; import { assert, expect } from 'chai'; diff --git a/test/unit/org/authInfoTest.ts b/test/unit/org/authInfoTest.ts index da940d85a4..556a347c81 100644 --- a/test/unit/org/authInfoTest.ts +++ b/test/unit/org/authInfoTest.ts @@ -9,9 +9,9 @@ /* eslint-disable @typescript-eslint/ban-types */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ -import * as pathImport from 'path'; -import * as dns from 'dns'; -import * as jwt from 'jsonwebtoken'; +import path from 'path'; +import dns from 'dns'; +import jwt from 'jsonwebtoken'; import { cloneJson, env, includes } from '@salesforce/kit'; import { spyMethod, stubMethod } from '@salesforce/ts-sinon'; import { AnyJson, getJsonMap, JsonMap, toJsonMap } from '@salesforce/ts-types'; @@ -1107,7 +1107,7 @@ describe('AuthInfo', () => { }); it('should path.resolve jwtkeyfilepath', async () => { - const resolveSpy = $$.SANDBOX.spy(pathImport, 'resolve'); + const resolveSpy = $$.SANDBOX.spy(path, 'resolve'); authInfoStubs.authJwt.restore(); stubMethod($$.SANDBOX, AuthInfo.prototype, 'authJwt').resolves({ diff --git a/test/unit/org/orgTest.ts b/test/unit/org/orgTest.ts index f72f8dfb98..42fa5d14e5 100644 --- a/test/unit/org/orgTest.ts +++ b/test/unit/org/orgTest.ts @@ -5,7 +5,7 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ import { deepStrictEqual, fail } from 'assert'; -import * as fs from 'fs'; +import fs from 'fs'; import { constants as fsConstants } from 'fs'; import { join as pathJoin } from 'path'; import { Duration, set } from '@salesforce/kit'; diff --git a/test/unit/status/myDomainResolverTest.ts b/test/unit/status/myDomainResolverTest.ts index e9ac414ba8..ac1a4fb5d6 100644 --- a/test/unit/status/myDomainResolverTest.ts +++ b/test/unit/status/myDomainResolverTest.ts @@ -4,7 +4,7 @@ * Licensed under the BSD 3-Clause license. * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ -import * as dns from 'dns'; +import dns from 'dns'; import { URL } from 'url'; import { Duration, Env } from '@salesforce/kit'; import { AnyFunction } from '@salesforce/ts-types'; diff --git a/test/unit/util/directoryWriterTest.ts b/test/unit/util/directoryWriterTest.ts index 1d4a8bda23..28177b9f2a 100644 --- a/test/unit/util/directoryWriterTest.ts +++ b/test/unit/util/directoryWriterTest.ts @@ -8,13 +8,11 @@ import * as os from 'os'; import * as fs from 'fs'; import * as path from 'path'; import { Readable } from 'stream'; -import * as chai from 'chai'; -import * as chaiString from 'chai-string'; +import { expect, use } from 'chai'; +import chaiString from 'chai-string'; import { DirectoryWriter } from '../../../src/util/directoryWriter'; -// eslint-disable-next-line @typescript-eslint/no-var-requires -const { expect } = chai; -chai.use(chaiString); +use(chaiString); function validateFileContents(filePath: string, expectedContents: string): void { const fileContents = fs.readFileSync(filePath, 'utf8'); diff --git a/test/unit/util/zipWriterTest.ts b/test/unit/util/zipWriterTest.ts index 4ff6fe4821..d276c4fb34 100644 --- a/test/unit/util/zipWriterTest.ts +++ b/test/unit/util/zipWriterTest.ts @@ -9,7 +9,7 @@ import * as fs from 'fs'; import * as path from 'path'; import { expect } from 'chai'; import * as sinon from 'sinon'; -import * as JSZip from 'jszip'; +import JSZip from 'jszip'; import { ZipWriter } from '../../../src/util/zipWriter'; describe('ZipWriter', () => { diff --git a/tsconfig.json b/tsconfig.json index 98e0fe92ed..858af7ddb5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,9 @@ "outDir": "./lib", "resolveJsonModule": true, "rootDir": "./src", + "moduleResolution": "Node16", + "module": "Node16", + "esModuleInterop": true, "plugins": [{ "transform": "./src/messageTransformer.ts" }] }, "include": ["./src/**/*.ts"]