From c29296cc96328fa81f127d5c336a02759ee9622d Mon Sep 17 00:00:00 2001 From: Cody Kaup Date: Mon, 23 Sep 2024 15:53:27 -0500 Subject: [PATCH] Fix lint errors from unicorn/no-null --- bin-src/init.ts | 4 ++-- bin-src/trim-stats-file.ts | 2 +- .../git/findAncestorBuildWithCommit.test.ts | 6 +++--- node-src/git/findAncestorBuildWithCommit.ts | 4 ++-- node-src/git/getCommitAndBranch.test.ts | 2 +- node-src/git/getParentCommits.test.ts | 2 +- node-src/git/git.test.ts | 2 +- node-src/git/git.ts | 2 +- node-src/index.test.ts | 4 ++-- node-src/lib/compress.ts | 2 +- node-src/lib/findChangedPackageFiles.test.ts | 3 ++- node-src/lib/getDependentStoryFiles.test.ts | 18 +++++++++--------- node-src/lib/getDependentStoryFiles.ts | 2 +- node-src/lib/getFileHashes.ts | 4 ++-- node-src/lib/getPrebuiltStorybookMetadata.ts | 4 ++-- node-src/lib/getStorybookConfiguration.ts | 4 ++-- node-src/lib/getStorybookInfo.test.ts | 7 +------ node-src/lib/getStorybookInfo.ts | 2 +- node-src/lib/getStorybookMetadata.ts | 1 - node-src/lib/uploadMetadataFiles.ts | 4 ++-- node-src/tasks/build.ts | 6 +++--- node-src/tasks/gitInfo.test.ts | 2 +- node-src/tasks/gitInfo.ts | 12 ++++++------ node-src/tasks/initialize.ts | 2 +- node-src/tasks/report.test.ts | 4 ++-- node-src/tasks/verify.test.ts | 16 ++++++++++------ node-src/ui/messages/errors/buildFailed.ts | 2 +- node-src/ui/messages/errors/fatalError.ts | 2 +- node-src/ui/messages/errors/uploadFailed.ts | 2 +- .../ui/messages/info/tracedAffectedFiles.ts | 2 +- node-src/ui/tasks/verify.stories.ts | 3 +-- test-stories/Tests.stories.js | 2 +- 32 files changed, 66 insertions(+), 68 deletions(-) diff --git a/bin-src/init.ts b/bin-src/init.ts index d3a7a2e48..a8571b597 100644 --- a/bin-src/init.ts +++ b/bin-src/init.ts @@ -35,7 +35,7 @@ export const addChromaticScriptToPackageJson = async ({ packageJson, packagePath } }; -export const createChromaticConfigFile = async ({ configFile, buildScriptName = null }) => { +export const createChromaticConfigFile = async ({ configFile, buildScriptName = undefined }) => { await writeFile(configFile, { ...(buildScriptName && { buildScriptName, @@ -148,7 +148,7 @@ export async function main(argv: string[]) { const { path: packagePath, packageJson } = pkgInfo; const { testFramework } = await prompts([ { - type: flags.framework ? null : 'select', + type: flags.framework ? undefined : 'select', name: 'testFramework', message: 'What testing framework are you using?', choices: [ diff --git a/bin-src/trim-stats-file.ts b/bin-src/trim-stats-file.ts index caa82cac7..24863b941 100644 --- a/bin-src/trim-stats-file.ts +++ b/bin-src/trim-stats-file.ts @@ -42,7 +42,7 @@ export async function main([statsFile = './storybook-static/preview-stats.json'] const targetFile = statsFile.replace('.json', '.trimmed.json'); await outputFile( targetFile, - JSON.stringify({ modules: trimmedModules }, null, 2) + JSON.stringify({ modules: trimmedModules }, undefined, 2) .replaceAll(/{\n {10}/g, '{ ') .replaceAll(/\n {8}}/g, ' }') ); diff --git a/node-src/git/findAncestorBuildWithCommit.test.ts b/node-src/git/findAncestorBuildWithCommit.test.ts index f75610a3a..02981ad46 100644 --- a/node-src/git/findAncestorBuildWithCommit.test.ts +++ b/node-src/git/findAncestorBuildWithCommit.test.ts @@ -42,7 +42,7 @@ describe('findAncestorBuildWithCommit', () => { makeResult([makeBuild({ commit: 'exists', uncommittedHash: 'abc123', isLocalBuild: true })]) ); - expect(await findAncestorBuildWithCommit({ client }, 1, { page: 1, limit: 1 })).toBeNull(); + expect(await findAncestorBuildWithCommit({ client }, 1, { page: 1, limit: 1 })).toBeUndefined(); }); it('DOES return a CI build with uncommitted changes', async () => { @@ -74,7 +74,7 @@ describe('findAncestorBuildWithCommit', () => { .mockReturnValueOnce(makeResult([makeBuild(), makeBuild()])) .mockReturnValueOnce(makeResult([makeBuild(), makeBuild()])); - expect(await findAncestorBuildWithCommit({ client }, 1, { page: 2, limit: 3 })).toBeNull(); + expect(await findAncestorBuildWithCommit({ client }, 1, { page: 2, limit: 3 })).toBeUndefined(); expect(client.runQuery).toHaveBeenCalledTimes(2); expect(client.runQuery.mock.calls[0][1]).toMatchObject({ buildNumber: 1, skip: 0, limit: 2 }); expect(client.runQuery.mock.calls[1][1]).toMatchObject({ buildNumber: 1, skip: 2, limit: 1 }); @@ -83,7 +83,7 @@ describe('findAncestorBuildWithCommit', () => { it('stops querying when the results run out', async () => { client.runQuery.mockReturnValueOnce(makeResult([makeBuild()])); - expect(await findAncestorBuildWithCommit({ client }, 1, { page: 2, limit: 3 })).toBeNull(); + expect(await findAncestorBuildWithCommit({ client }, 1, { page: 2, limit: 3 })).toBeUndefined(); expect(client.runQuery).toHaveBeenCalledTimes(1); }); }); diff --git a/node-src/git/findAncestorBuildWithCommit.ts b/node-src/git/findAncestorBuildWithCommit.ts index c51670050..f92687bbf 100644 --- a/node-src/git/findAncestorBuildWithCommit.ts +++ b/node-src/git/findAncestorBuildWithCommit.ts @@ -76,9 +76,9 @@ export async function findAncestorBuildWithCommit( if (result) return result[0]; - if (results.length < page) return null; + if (results.length < page) return; skip += page; } - return null; + return; } diff --git a/node-src/git/getCommitAndBranch.test.ts b/node-src/git/getCommitAndBranch.test.ts index 4ab2f43dd..50c5b7be1 100644 --- a/node-src/git/getCommitAndBranch.test.ts +++ b/node-src/git/getCommitAndBranch.test.ts @@ -29,7 +29,7 @@ beforeEach(() => { committerEmail: 'noreply@github.com', }); hasPreviousCommit.mockResolvedValue(true); - mergeQueueBranchMatch.mockResolvedValue(null); + mergeQueueBranchMatch.mockResolvedValue(undefined); }); afterEach(() => { diff --git a/node-src/git/getParentCommits.test.ts b/node-src/git/getParentCommits.test.ts index 3c35c5823..fa2889271 100644 --- a/node-src/git/getParentCommits.test.ts +++ b/node-src/git/getParentCommits.test.ts @@ -397,7 +397,7 @@ describe('getParentCommits', () => { const mockIndex = createMockIndex(repository, [['A', 'main']]); const mockIndexWithNullFirstBuildCommittedAt = (queryName, variables) => { if (queryName === 'FirstCommittedAtQuery') { - return { app: { firstBuild: { committedAt: null } } }; + return { app: { firstBuild: {} } }; } return mockIndex(queryName, variables); }; diff --git a/node-src/git/git.test.ts b/node-src/git/git.test.ts index 22a7f022d..31ea11d8c 100644 --- a/node-src/git/git.test.ts +++ b/node-src/git/git.test.ts @@ -111,7 +111,7 @@ describe('mergeQueueBranchMatch', () => { it('returns null if it is not a merge queue branch', async () => { const branch = 'develop'; - expect(await mergeQueueBranchMatch(branch)).toEqual(null); + expect(await mergeQueueBranchMatch(branch)).toBeUndefined(); }); }); diff --git a/node-src/git/git.ts b/node-src/git/git.ts index df6054046..06a0313e4 100644 --- a/node-src/git/git.ts +++ b/node-src/git/git.ts @@ -302,5 +302,5 @@ export async function mergeQueueBranchMatch(branch) { const mergeQueuePattern = new RegExp(/gh-readonly-queue\/.*\/pr-(\d+)-[\da-f]{30}/); const match = branch.match(mergeQueuePattern); - return match ? Number(match[1]) : null; + return match ? Number(match[1]) : undefined; } diff --git a/node-src/index.test.ts b/node-src/index.test.ts index 7bae5bdb1..cfd671700 100644 --- a/node-src/index.test.ts +++ b/node-src/index.test.ts @@ -180,7 +180,7 @@ vi.mock('node-fetch', () => ({ } if (query?.match('FirstCommittedAtQuery')) { - return { data: { app: { firstBuild: { committedAt: null } } } }; + return { data: { app: { firstBuild: {} } } }; } if (query?.match('HasBuildsWithCommitsQuery')) { @@ -308,7 +308,7 @@ vi.mock('./git/git', () => ({ getRepositoryRoot: () => Promise.resolve(process.cwd()), getUncommittedHash: () => Promise.resolve('abc123'), getUserEmail: () => Promise.resolve('test@test.com'), - mergeQueueBranchMatch: () => Promise.resolve(null), + mergeQueueBranchMatch: () => Promise.resolve(undefined), })); vi.mock('./git/getParentCommits', () => ({ diff --git a/node-src/lib/compress.ts b/node-src/lib/compress.ts index df80f7f2a..8b7b889a5 100644 --- a/node-src/lib/compress.ts +++ b/node-src/lib/compress.ts @@ -7,7 +7,7 @@ import { Context, FileDesc } from '../types'; export default async function makeZipFile(ctx: Context, files: FileDesc[]) { const archive = archiver('zip', { zlib: { level: 9 } }); const tmp = await tempFile({ postfix: '.zip' }); - const sink = createWriteStream(null, { fd: tmp.fd }); + const sink = createWriteStream(undefined, { fd: tmp.fd }); return new Promise<{ path: string; size: number }>((resolve, reject) => { sink.on('close', () => { diff --git a/node-src/lib/findChangedPackageFiles.test.ts b/node-src/lib/findChangedPackageFiles.test.ts index 744cbaa3d..4c05a09a7 100644 --- a/node-src/lib/findChangedPackageFiles.test.ts +++ b/node-src/lib/findChangedPackageFiles.test.ts @@ -141,7 +141,7 @@ describe('findChangedPackageFiles', () => { it('considers the file changed if it fails to parse', async () => { mockFileContents({ 'package.json': { - A: null, + A: '', HEAD: { dependencies: { a: '2' } }, }, }); @@ -445,6 +445,7 @@ describe('arePackageDependenciesEqual', () => { }); it('returns true if dependencies are null', () => { + // eslint-disable-next-line unicorn/no-null expect(arePackageDependenciesEqual({ dependencies: null }, { dependencies: null })).toBe(true); }); }); diff --git a/node-src/lib/getDependentStoryFiles.test.ts b/node-src/lib/getDependentStoryFiles.test.ts index a10209b43..62e5bd17e 100644 --- a/node-src/lib/getDependentStoryFiles.test.ts +++ b/node-src/lib/getDependentStoryFiles.test.ts @@ -221,7 +221,7 @@ describe('getDependentStoryFiles', () => { const changedFiles = ['src/foo.css']; const modules = [ { - id: null, + id: '', name: './src/foo.css?ngResource ', reasons: [{ moduleName: './src/foo.component.ts' }], }, @@ -503,7 +503,7 @@ describe('getDependentStoryFiles', () => { ]; const ctx = getContext({ configDir: 'path/to/storybook-config' }); const res = await getDependentStoryFiles(ctx, { modules }, statsPath, changedFiles); - expect(res).toEqual(null); + expect(res).toBeUndefined(); expect(ctx.turboSnap.bailReason).toEqual({ changedStorybookFiles: ['path/to/storybook-config/file.js'], }); @@ -530,7 +530,7 @@ describe('getDependentStoryFiles', () => { ]; const ctx = getContext({ configDir: 'path/to/storybook-config' }); const res = await getDependentStoryFiles(ctx, { modules }, statsPath, changedFiles); - expect(res).toEqual(null); + expect(res).toBeUndefined(); expect(ctx.turboSnap.bailReason).toEqual({ changedStorybookFiles: ['path/to/storybook-config/file.js'], }); @@ -558,7 +558,7 @@ describe('getDependentStoryFiles', () => { ]; const ctx = getContext({ configDir: 'path/to/storybook-config' }); const res = await getDependentStoryFiles(ctx, { modules }, statsPath, changedFiles); - expect(res).toEqual(null); + expect(res).toBeUndefined(); expect(ctx.turboSnap.bailReason).toEqual({ changedStorybookFiles: ['path/to/storybook-config/file.js', 'src/styles.js'], }); @@ -585,7 +585,7 @@ describe('getDependentStoryFiles', () => { ]; const ctx = getContext({ staticDir: ['path/to/statics'] }); const res = await getDependentStoryFiles(ctx, { modules }, statsPath, changedFiles); - expect(res).toEqual(null); + expect(res).toBeUndefined(); expect(ctx.turboSnap.bailReason).toEqual({ changedStaticFiles: ['path/to/statics/image.png'], }); @@ -614,22 +614,22 @@ describe('getDependentStoryFiles', () => { ], }, { - id: null, + id: '', name: './src/stories/Page.jsx', // changed reasons: [{ moduleName: './src/stories/Page.stories.jsx' }], }, { - id: null, + id: '', name: './src/stories/button.css', reasons: [{ moduleName: './src/stories/Button.jsx' }], }, { - id: null, + id: '', name: './src/stories/header.css', reasons: [{ moduleName: './src/stories/Header.jsx' }], }, { - id: null, + id: '', name: './src/stories/page.css', reasons: [{ moduleName: './src/stories/Page.jsx' }], }, diff --git a/node-src/lib/getDependentStoryFiles.ts b/node-src/lib/getDependentStoryFiles.ts index 3f29d05f7..1b984b2cb 100644 --- a/node-src/lib/getDependentStoryFiles.ts +++ b/node-src/lib/getDependentStoryFiles.ts @@ -295,7 +295,7 @@ export async function getDependentStoryFiles( if (ctx.turboSnap.bailReason) { ctx.log.warn(bailFile({ turboSnap: ctx.turboSnap })); - return null; + return; } return affectedModules; diff --git a/node-src/lib/getFileHashes.ts b/node-src/lib/getFileHashes.ts index 706e89cb8..d025cd911 100644 --- a/node-src/lib/getFileHashes.ts +++ b/node-src/lib/getFileHashes.ts @@ -18,7 +18,7 @@ const hashFile = (buffer: Buffer, path: string, xxhash: XXHashAPI): Promise) => { - read(fd, buffer, null, BUFFER_SIZE, -1, (readErr, bytesRead) => { + read(fd, buffer, undefined, BUFFER_SIZE, -1, (readErr, bytesRead) => { if (readErr) { return close(fd, () => reject(readErr)); } @@ -36,7 +36,7 @@ const hashFile = (buffer: Buffer, path: string, xxhash: XXHashAPI): Promise { + read(fd, buffer, undefined, BUFFER_SIZE, -1, (readErr, bytesRead) => { if (readErr) { return close(fd, () => reject(readErr)); } diff --git a/node-src/lib/getPrebuiltStorybookMetadata.ts b/node-src/lib/getPrebuiltStorybookMetadata.ts index a6455aaeb..2c43135d6 100644 --- a/node-src/lib/getPrebuiltStorybookMetadata.ts +++ b/node-src/lib/getPrebuiltStorybookMetadata.ts @@ -39,8 +39,8 @@ export const getStorybookMetadataFromProjectJson = async ( const builder = getBuilder(sbProjectJson); return { - viewLayer: sbProjectJson.framework.name ?? null, - version: sbProjectJson.storybookPackages[viewLayerPackage].version ?? null, + viewLayer: sbProjectJson.framework.name, + version: sbProjectJson.storybookPackages[viewLayerPackage].version, builder, addons: Object.entries(sbProjectJson.addons) .filter(([packageName]) => supportedAddons[packageName]) diff --git a/node-src/lib/getStorybookConfiguration.ts b/node-src/lib/getStorybookConfiguration.ts index cb2dee814..d101afd29 100644 --- a/node-src/lib/getStorybookConfiguration.ts +++ b/node-src/lib/getStorybookConfiguration.ts @@ -6,14 +6,14 @@ export default function getStorybookConfiguration( shortName: string, longName?: string ) { - if (!storybookScript) return null; + if (!storybookScript) return; const parts = storybookScript.split(/[\s"'=]+/); let index = parts.indexOf(longName); if (index === -1) { index = parts.indexOf(shortName); } if (index === -1) { - return null; + return; } return parts[index + 1]; } diff --git a/node-src/lib/getStorybookInfo.test.ts b/node-src/lib/getStorybookInfo.test.ts index 3317f1603..3392b1429 100644 --- a/node-src/lib/getStorybookInfo.test.ts +++ b/node-src/lib/getStorybookInfo.test.ts @@ -203,12 +203,7 @@ describe('getStorybookInfo', () => { options: { storybookBuildDir: 'bin-src/__mocks__/malformedProjectJson' }, packageJson: { dependencies: REACT }, }); - expect(await getStorybookInfo(ctx)).toEqual({ - addons: [], - version: null, - viewLayer: null, - builder: null, - }); + expect(await getStorybookInfo(ctx)).toEqual({}); }); it('does not return unsupported addons in metadata', async () => { diff --git a/node-src/lib/getStorybookInfo.ts b/node-src/lib/getStorybookInfo.ts index 161a58960..81fdcc89e 100644 --- a/node-src/lib/getStorybookInfo.ts +++ b/node-src/lib/getStorybookInfo.ts @@ -24,6 +24,6 @@ export default async function getStorybookInfo( return await getStorybookMetadata(ctx); } catch (err) { ctx.log.debug(err); - return { viewLayer: null, version: null, addons: [], builder: null }; + return {}; } } diff --git a/node-src/lib/getStorybookMetadata.ts b/node-src/lib/getStorybookMetadata.ts index 2a6105995..928450cf0 100644 --- a/node-src/lib/getStorybookMetadata.ts +++ b/node-src/lib/getStorybookMetadata.ts @@ -224,7 +224,6 @@ export const getStorybookMetadata = async (ctx: Context) => { v7 = true; } catch (err) { ctx.log.debug({ storybookV7error: err }); - mainConfig = null; } } diff --git a/node-src/lib/uploadMetadataFiles.ts b/node-src/lib/uploadMetadataFiles.ts index b2fefb0c9..f80c40c83 100644 --- a/node-src/lib/uploadMetadataFiles.ts +++ b/node-src/lib/uploadMetadataFiles.ts @@ -22,8 +22,8 @@ export async function uploadMetadataFiles(ctx: Context) { ctx.options.logFile, ctx.options.diagnosticsFile, ctx.options.storybookLogFile, - await findStorybookConfigFile(ctx, /^main\.[jt]sx?$/).catch(() => null), - await findStorybookConfigFile(ctx, /^preview\.[jt]sx?$/).catch(() => null), + await findStorybookConfigFile(ctx, /^main\.[jt]sx?$/).catch(() => undefined), + await findStorybookConfigFile(ctx, /^preview\.[jt]sx?$/).catch(() => undefined), ctx.fileInfo?.statsPath && (await trimStatsFile([ctx.fileInfo.statsPath])), ].filter(Boolean); diff --git a/node-src/tasks/build.ts b/node-src/tasks/build.ts index 11ae6dc59..5e4e72f45 100644 --- a/node-src/tasks/build.ts +++ b/node-src/tasks/build.ts @@ -99,7 +99,7 @@ function e2eBuildErrorMessage( } export const buildStorybook = async (ctx: Context) => { - let logFile = null; + let logFile; if (ctx.options.storybookLogFile) { ctx.buildLogFile = path.resolve(ctx.options.storybookLogFile); logFile = createWriteStream(ctx.buildLogFile); @@ -112,10 +112,10 @@ export const buildStorybook = async (ctx: Context) => { const { experimental_abortSignal: signal } = ctx.options; try { ctx.log.debug('Running build command:', ctx.buildCommand); - ctx.log.debug('Runtime metadata:', JSON.stringify(ctx.runtimeMetadata, null, 2)); + ctx.log.debug('Runtime metadata:', JSON.stringify(ctx.runtimeMetadata, undefined, 2)); const subprocess = execaCommand(ctx.buildCommand, { - stdio: [null, logFile, null], + stdio: [undefined, logFile, undefined], // When `true`, this will run in the node version set by the // action (node20), not the version set in the workflow preferLocal: false, diff --git a/node-src/tasks/gitInfo.test.ts b/node-src/tasks/gitInfo.test.ts index ea9c383bf..3fc736347 100644 --- a/node-src/tasks/gitInfo.test.ts +++ b/node-src/tasks/gitInfo.test.ts @@ -128,7 +128,7 @@ describe('setGitInfo', () => { }); const ctx = { log, options: { onlyChanged: true, externals: ['**/*.scss'] }, client } as any; await setGitInfo(ctx, {} as any); - expect(ctx.git.changedFiles).toBeNull(); + expect(ctx.git.changedFiles).toBeUndefined(); }); it('forces rebuild automatically if app is onboarding', async () => { diff --git a/node-src/tasks/gitInfo.ts b/node-src/tasks/gitInfo.ts index 1680c1fc0..b3e1586b0 100644 --- a/node-src/tasks/gitInfo.ts +++ b/node-src/tasks/gitInfo.ts @@ -71,11 +71,11 @@ export const setGitInfo = async (ctx: Context, task: Task) => { version: await getVersion(), gitUserEmail: await getUserEmail().catch((err) => { ctx.log.debug('Failed to retrieve Git user email', err); - return null; + return undefined; }), uncommittedHash: await getUncommittedHash().catch((err) => { ctx.log.warn('Failed to retrieve uncommitted files hash', err); - return null; + return undefined; }), ...commitAndBranchInfo, }; @@ -225,8 +225,8 @@ export const setGitInfo = async (ctx: Context, task: Task) => { } } catch (err) { ctx.turboSnap.bailReason = { invalidChangedFiles: true }; - ctx.git.changedFiles = null; - ctx.git.replacementBuildIds = null; + delete ctx.git.changedFiles; + delete ctx.git.replacementBuildIds; ctx.log.warn(invalidChangedFiles()); ctx.log.debug(err); } @@ -237,8 +237,8 @@ export const setGitInfo = async (ctx: Context, task: Task) => { if (matches.length > 0) { ctx.turboSnap.bailReason = { changedExternalFiles: matches }; ctx.log.warn(externalsChanged(matches)); - ctx.git.changedFiles = null; - ctx.git.replacementBuildIds = null; + delete ctx.git.changedFiles; + delete ctx.git.replacementBuildIds; break; } } diff --git a/node-src/tasks/initialize.ts b/node-src/tasks/initialize.ts index b176f7cb5..a2a9cb697 100644 --- a/node-src/tasks/initialize.ts +++ b/node-src/tasks/initialize.ts @@ -40,7 +40,7 @@ export const setEnvironment = async (ctx: Context) => { } } - ctx.log.debug(`Got environment:\n${JSON.stringify(ctx.environment, null, 2)}`); + ctx.log.debug(`Got environment:\n${JSON.stringify(ctx.environment, undefined, 2)}`); }; export const setRuntimeMetadata = async (ctx: Context) => { diff --git a/node-src/tasks/report.test.ts b/node-src/tasks/report.test.ts index 9cb5342a8..49ae9148a 100644 --- a/node-src/tasks/report.test.ts +++ b/node-src/tasks/report.test.ts @@ -32,14 +32,14 @@ const mockTests = [ result: '', spec: { name: '', component: { name: '' } }, parameters: { viewportIsDefault: true, viewport: 1080 }, - mode: { name: null }, + mode: { name: '' }, }, { status: 'FAILED', result: '', spec: { name: '', component: { name: '' } }, parameters: { viewportIsDefault: false, viewport: 1080 }, - mode: { name: null }, + mode: { name: '' }, }, ]; diff --git a/node-src/tasks/verify.test.ts b/node-src/tasks/verify.test.ts index 9cbe66cee..4fe52ccca 100644 --- a/node-src/tasks/verify.test.ts +++ b/node-src/tasks/verify.test.ts @@ -60,7 +60,12 @@ describe('verifyBuild', () => { app: {}, startedAt: Date.now(), }; - const publishedBuild = { ...build, status: 'PUBLISHED', startedAt: null, upgradeBuilds: [] }; + const publishedBuild = { + ...build, + status: 'PUBLISHED', + startedAt: undefined, + upgradeBuilds: [], + }; const client = { runQuery: vi.fn() }; client.runQuery // We can safely poll three times without hitting the timeout @@ -106,7 +111,6 @@ describe('verifyBuild', () => { status: 'PUBLISHED', features: { uiTests: true, uiReview: false }, app: {}, - startedAt: null, upgradeBuilds: [], }; const client = { runQuery: vi.fn() }; @@ -125,9 +129,9 @@ describe('verifyBuild', () => { app: {}, startedAt: Date.now(), }; - const upgradeBuilds = [{ completedAt: null }]; + const upgradeBuilds = [{}]; const completed = [{ completedAt: Date.now() }]; - const publishedBuild = { ...build, status: 'PUBLISHED', startedAt: null, upgradeBuilds }; + const publishedBuild = { ...build, status: 'PUBLISHED', startedAt: undefined, upgradeBuilds }; const client = { runQuery: vi.fn() }; client.runQuery // Polling while upgrade builds are in progress is irrelevant @@ -155,8 +159,8 @@ describe('verifyBuild', () => { app: {}, startedAt: Date.now(), }; - const upgradeBuilds = [{ completedAt: null }]; - const publishedBuild = { ...build, status: 'PUBLISHED', startedAt: null, upgradeBuilds }; + const upgradeBuilds = [{}]; + const publishedBuild = { ...build, status: 'PUBLISHED', startedAt: undefined, upgradeBuilds }; const client = { runQuery: vi.fn() }; client.runQuery.mockReturnValue({ app: { build: publishedBuild } }); diff --git a/node-src/ui/messages/errors/buildFailed.ts b/node-src/ui/messages/errors/buildFailed.ts index 8deaa1b13..bfda9f574 100644 --- a/node-src/ui/messages/errors/buildFailed.ts +++ b/node-src/ui/messages/errors/buildFailed.ts @@ -26,7 +26,7 @@ export default ( `), message, chalk`${info} Build command:\n{dim ${buildCommand}}`, - chalk`${info} Runtime metadata:\n{dim ${JSON.stringify(runtimeMetadata, null, 2)}}`, + chalk`${info} Runtime metadata:\n{dim ${JSON.stringify(runtimeMetadata, undefined, 2)}}`, chalk`${info} Storybook build output:\n{dim ${buildLogFile}}`, lines.join(`\n`), ].join('\n\n'); diff --git a/node-src/ui/messages/errors/fatalError.ts b/node-src/ui/messages/errors/fatalError.ts index 393e8c9f0..210b6bb56 100644 --- a/node-src/ui/messages/errors/fatalError.ts +++ b/node-src/ui/messages/errors/fatalError.ts @@ -86,7 +86,7 @@ export default function fatalError( Please provide us with the above CLI output and the following info: `), - chalk`{bold ${JSON.stringify(debugInfo, null, 2)}}`, + chalk`{bold ${JSON.stringify(debugInfo, undefined, 2)}}`, stacktraces.length > 0 ? chalk`\n{dim ${stacktraces.join('\n\n')}}` : '', ].join('\n'); } diff --git a/node-src/ui/messages/errors/uploadFailed.ts b/node-src/ui/messages/errors/uploadFailed.ts index 3db9889aa..18c5f9bca 100644 --- a/node-src/ui/messages/errors/uploadFailed.ts +++ b/node-src/ui/messages/errors/uploadFailed.ts @@ -20,5 +20,5 @@ export function uploadFailed({ target }: { target: FileDesc & TargetInfo }, debu ${diagnosis} ${debug ? '' : chalk`Enable the {bold debug} option to get more information.`} `); - return debug ? message + JSON.stringify(target, null, 2) : message; + return debug ? message + JSON.stringify(target, undefined, 2) : message; } diff --git a/node-src/ui/messages/info/tracedAffectedFiles.ts b/node-src/ui/messages/info/tracedAffectedFiles.ts index da24b2659..32001ee36 100644 --- a/node-src/ui/messages/info/tracedAffectedFiles.ts +++ b/node-src/ui/messages/info/tracedAffectedFiles.ts @@ -51,7 +51,7 @@ export default ( const changed = pluralize('changed files', changedFiles.length, true); const affected = pluralize('affected story files', Object.keys(affectedModules).length, true); - let directoryDebug = null; + let directoryDebug; if (expanded) { const bailReason = ctx.turboSnap?.bailReason ? `${ctx.turboSnap.bailReason}\n\n` : ''; diff --git a/node-src/ui/tasks/verify.stories.ts b/node-src/ui/tasks/verify.stories.ts index 3450120f7..6b007f6b5 100644 --- a/node-src/ui/tasks/verify.stories.ts +++ b/node-src/ui/tasks/verify.stories.ts @@ -46,8 +46,7 @@ export const RunOnlyNames = () => options: { onlyStoryNames: ['MyComponent/**'] }, } as any); -export const AwaitingUpgrades = () => - awaitingUpgrades({} as any, [{ completedAt: 123 }, { completedAt: null }]); +export const AwaitingUpgrades = () => awaitingUpgrades({} as any, [{ completedAt: 123 }, {}]); export const Started = () => success({ build } as any); diff --git a/test-stories/Tests.stories.js b/test-stories/Tests.stories.js index 9395fc920..1cf9a9c98 100644 --- a/test-stories/Tests.stories.js +++ b/test-stories/Tests.stories.js @@ -11,7 +11,7 @@ export default { }; export const WithViewports = () => { - let bg = null; + let bg; if (window.matchMedia('(max-width: 400px)').matches) { bg = 'cyan'; } else if (window.matchMedia('(max-width: 800px)').matches) {