From 3fd4882e31fd7ed5e70560ec2370f4e5c162b8ae Mon Sep 17 00:00:00 2001 From: Cody Kaup Date: Fri, 13 Sep 2024 15:19:40 -0500 Subject: [PATCH] Fix lint errors from unicorn/prefer-spread --- node-src/git/getParentCommits.ts | 2 +- node-src/lib/getDependentStoryFiles.ts | 7 +++-- node-src/tasks/index.ts | 2 +- .../ui/messages/info/tracedAffectedFiles.ts | 28 +++++++++---------- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/node-src/git/getParentCommits.ts b/node-src/git/getParentCommits.ts index 66451f616..0d10520ec 100644 --- a/node-src/git/getParentCommits.ts +++ b/node-src/git/getParentCommits.ts @@ -296,6 +296,6 @@ export async function getParentCommits( // For any pair A,B of builds, there is no point in using B if it is an ancestor of A. const descendentCommits = await maximallyDescendentCommits({ log }, commitsWithBuilds); - const ancestorCommits = extraParentCommits.concat(descendentCommits); + const ancestorCommits = [...extraParentCommits, ...descendentCommits]; return ancestorCommits; } diff --git a/node-src/lib/getDependentStoryFiles.ts b/node-src/lib/getDependentStoryFiles.ts index aa87831c9..3f29d05f7 100644 --- a/node-src/lib/getDependentStoryFiles.ts +++ b/node-src/lib/getDependentStoryFiles.ts @@ -217,9 +217,10 @@ export async function getDependentStoryFiles( // If we didn't find any node_modules in the stats file, it's probably incomplete and we can't // trace changed dependencies, so we bail just in case. ctx.turboSnap.bailReason = { - changedPackageFiles: ctx.git.changedFiles - .filter((file) => isPackageManifestFile(file)) - .concat(changedPackageLockFiles), + changedPackageFiles: [ + ...ctx.git.changedFiles.filter((file) => isPackageManifestFile(file)), + ...changedPackageLockFiles, + ], }; } diff --git a/node-src/tasks/index.ts b/node-src/tasks/index.ts index 5b94ae2f8..28619c4a5 100644 --- a/node-src/tasks/index.ts +++ b/node-src/tasks/index.ts @@ -29,5 +29,5 @@ export const runPatchBuild = [prepareWorkspace, ...runUploadBuild, restoreWorksp export default function index(options: Context['options']): Listr.ListrTask[] { const tasks = options.patchHeadRef && options.patchBaseRef ? runUploadBuild : runUploadBuild; - return options.junitReport ? tasks.concat(report) : tasks; + return options.junitReport ? [...tasks, report] : tasks; } diff --git a/node-src/ui/messages/info/tracedAffectedFiles.ts b/node-src/ui/messages/info/tracedAffectedFiles.ts index 544260909..4ba0c2a66 100644 --- a/node-src/ui/messages/info/tracedAffectedFiles.ts +++ b/node-src/ui/messages/info/tracedAffectedFiles.ts @@ -97,20 +97,20 @@ export default ( const seen = new Set(); const traces = [...ctx.turboSnap.tracedPaths].map((p) => { const parts = p.split('\n'); - return parts - .reduce((acc, part, index) => { - if (index === 0) return chalk`— ${printPath(part)} {cyan [changed]}${printModules(part)}`; - const indent = ' '.repeat(index); - let note = ''; - if (index === parts.length - 1) { - if (seen.has(part)) note = chalk` {yellow [duplicate]}`; - else seen.add(part); - } - return chalk`${ - expanded ? `File Path: ${part}\n\nBase Directory: ${basedir}\n\n` : '' - }${acc}\n${indent}∟ ${printPath(part)}${note}${printModules(part, indent)}`; - }, '') - .concat(chalk`\n${' '.repeat(parts.length)}∟ {cyan [story index]}`); + const traceParts = parts.reduce((acc, part, index) => { + if (index === 0) return chalk`— ${printPath(part)} {cyan [changed]}${printModules(part)}`; + const indent = ' '.repeat(index); + let note = ''; + if (index === parts.length - 1) { + if (seen.has(part)) note = chalk` {yellow [duplicate]}`; + else seen.add(part); + } + return chalk`${ + expanded ? `File Path: ${part}\n\nBase Directory: ${basedir}\n\n` : '' + }${acc}\n${indent}∟ ${printPath(part)}${note}${printModules(part, indent)}`; + }, ''); + + return traceParts + chalk`\n${' '.repeat(parts.length)}∟ {cyan [story index]}`; }); const note = chalk`\n\nSet {bold ${flag}} to {bold 'expanded'} to reveal underlying modules.`;