From 83d15656846bbea5e7fa29114f76d89b65d7afa6 Mon Sep 17 00:00:00 2001 From: mshanemc Date: Fri, 5 Apr 2024 16:30:50 -0500 Subject: [PATCH] refactor: no-param-reassign --- src/utils/deploy.ts | 5 ++--- src/utils/flags.ts | 6 +++--- test/nuts/convert/mdapi.nut.ts | 4 ++-- test/nuts/convert/source.nut.ts | 4 ++-- test/nuts/digitalExperienceBundle/helper.ts | 3 +++ test/nuts/specialTypes/folderTypes.nut.ts | 9 ++++----- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/utils/deploy.ts b/src/utils/deploy.ts index 6a292380..dcd820c8 100644 --- a/src/utils/deploy.ts +++ b/src/utils/deploy.ts @@ -145,13 +145,12 @@ export async function executeDeploy( await deploy.start(); } } else { - // mdapi format deploys don't require a project, but at this point we need one - project ??= await SfProject.resolve(); // instantiate source tracking // stl will decide, based on the org's properties, what needs to be done const stl = await SourceTracking.create({ org, - project, + // mdapi format deploys don't require a project, but at this point we need one + project: project ?? (await SfProject.resolve()), subscribeSDREvents: true, ignoreConflicts: opts['ignore-conflicts'], }); diff --git a/src/utils/flags.ts b/src/utils/flags.ts index 8734c3a1..668e04c1 100644 --- a/src/utils/flags.ts +++ b/src/utils/flags.ts @@ -52,13 +52,13 @@ async function ensureDirectoryPath(path: string): Promise { return resolvedPath; } -function resolveZipFileName(zipFileName?: string): string { +const resolveZipFileName = (zipFileName?: string): string => { if (!zipFileName) { return DEFAULT_ZIP_FILE_NAME; } // If no file extension was provided append, '.zip' - return !extname(zipFileName) ? (zipFileName += '.zip') : zipFileName; -} + return !extname(zipFileName) ? `${zipFileName}.zip` : zipFileName; +}; export const DEFAULT_ZIP_FILE_NAME = 'unpackaged.zip'; diff --git a/test/nuts/convert/mdapi.nut.ts b/test/nuts/convert/mdapi.nut.ts index 19919e0a..02ef44ff 100644 --- a/test/nuts/convert/mdapi.nut.ts +++ b/test/nuts/convert/mdapi.nut.ts @@ -14,7 +14,7 @@ import { ConvertMdapiJson } from '../../../src/utils/types.js'; let session: TestSession; const writeManifest = (manifestPath: string, contents?: string) => { - contents ??= ` + const defaultContents = ` * @@ -22,7 +22,7 @@ const writeManifest = (manifestPath: string, contents?: string) => { 53.0 `; - fs.writeFileSync(manifestPath, contents); + fs.writeFileSync(manifestPath, contents ?? defaultContents); }; describe('project convert mdapi NUTs', () => { diff --git a/test/nuts/convert/source.nut.ts b/test/nuts/convert/source.nut.ts index 359d8c63..f96fa475 100644 --- a/test/nuts/convert/source.nut.ts +++ b/test/nuts/convert/source.nut.ts @@ -13,7 +13,7 @@ import { ConvertResultJson } from '../../../src/utils/types.js'; let session: TestSession; const writeManifest = (manifestPath: string, contents?: string) => { - contents ??= ` + const defaultContents = ` * @@ -21,7 +21,7 @@ const writeManifest = (manifestPath: string, contents?: string) => { 53.0 `; - fs.writeFileSync(manifestPath, contents); + fs.writeFileSync(manifestPath, contents ?? defaultContents); }; describe('project convert source NUTs', () => { diff --git a/test/nuts/digitalExperienceBundle/helper.ts b/test/nuts/digitalExperienceBundle/helper.ts index e4104371..29fd46b2 100644 --- a/test/nuts/digitalExperienceBundle/helper.ts +++ b/test/nuts/digitalExperienceBundle/helper.ts @@ -4,6 +4,9 @@ * 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 */ +// existing tests do a lot mutation. I decided to leave rather than refactor +/* eslint-disable no-param-reassign */ + import { join, relative } from 'node:path'; import * as fs from 'node:fs'; import { FileResponse } from '@salesforce/source-deploy-retrieve'; diff --git a/test/nuts/specialTypes/folderTypes.nut.ts b/test/nuts/specialTypes/folderTypes.nut.ts index 9706506a..8ace99cf 100644 --- a/test/nuts/specialTypes/folderTypes.nut.ts +++ b/test/nuts/specialTypes/folderTypes.nut.ts @@ -72,11 +72,10 @@ describe('metadata types that go in folders', () => { ]; const getRelativeFileResponses = (resp: FileResponse[]) => - resp.map((s) => { - // grab the last 2 directories with the file only - s.filePath = s.filePath?.split(path.sep).slice(-3).join(path.sep); - return s; - }); + resp.map((fr) => ({ + ...fr, + filePath: fr.filePath?.split(path.sep).slice(-3).join(path.sep), + })); it('can generate manifest for just the emailTemplates', () => { const pathToEmails = path.join('force-app', 'main', 'default', 'email');