Skip to content

Commit aac08b2

Browse files
committed
refactor(scripts): prefer undefined over null for absent values
1 parent 891010e commit aac08b2

7 files changed

Lines changed: 25 additions & 25 deletions

File tree

scripts/build-externals/esbuild-config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ function createForceNodeModulesPlugin() {
108108
}
109109
} catch {
110110
// Package not found, let esbuild handle the error
111-
return null
111+
return undefined
112112
}
113113
}
114-
return null
114+
return undefined
115115
})
116116
}
117117
},

scripts/build-externals/local-packages.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export async function getLocalPackagePath(packageName, rootDir) {
5151
}
5252
}
5353

54-
return null
54+
return undefined
5555
}
5656

5757
/**

scripts/claude.mjs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ class ProgressTracker {
352352
s.phases.some(p => p.name === phaseName),
353353
)
354354
if (similar.length === 0) {
355-
return null
355+
return undefined
356356
}
357357

358358
// Get median duration for this phase.
@@ -362,7 +362,7 @@ class ProgressTracker {
362362
.sort((a, b) => a - b)
363363

364364
if (durations.length === 0) {
365-
return null
365+
return undefined
366366
}
367367

368368
const median = durations[Math.floor(durations.length / 2)]
@@ -758,14 +758,14 @@ ${similarErrors.length > 0 ? `**Similar Past Errors:**\n${similarErrors.map(e =>
758758

759759
if (result.exitCode !== 0) {
760760
log.warn('Analysis failed, proceeding without root cause info')
761-
return null
761+
return undefined
762762
}
763763

764764
// Parse JSON response.
765765
const jsonMatch = result.stdout.match(/\{[\s\S]*\}/)
766766
if (!jsonMatch) {
767767
log.warn('Could not parse analysis, proceeding without root cause info')
768-
return null
768+
return undefined
769769
}
770770

771771
const analysis = JSON.parse(jsonMatch[0])
@@ -791,7 +791,7 @@ ${similarErrors.length > 0 ? `**Similar Past Errors:**\n${similarErrors.map(e =>
791791
return analysis
792792
} catch (e) {
793793
log.warn(`Analysis error: ${e.message}`)
794-
return null
794+
return undefined
795795
}
796796
}
797797

@@ -2568,7 +2568,7 @@ Provide ONLY the JSON array, nothing else.`
25682568

25692569
if (result.exitCode !== 0) {
25702570
log.failed(`Failed to scan ${name}`)
2571-
return null
2571+
return undefined
25722572
}
25732573

25742574
log.done(`Scanned ${name}`)
@@ -2577,7 +2577,7 @@ Provide ONLY the JSON array, nothing else.`
25772577
return JSON.parse(result.stdout.trim())
25782578
} catch {
25792579
log.warn(`Failed to parse scan results for ${name}`)
2580-
return null
2580+
return undefined
25812581
}
25822582
}
25832583

@@ -2846,7 +2846,7 @@ async function runSecurityScan(claudeCmd, options = {}) {
28462846
const tasks = projects.map(project =>
28472847
scanProjectForIssues(claudeCmd, project, options)
28482848
.then(issues => ({ project: project.name, issues }))
2849-
.catch(error => ({ project: project.name, issues: null, error })),
2849+
.catch(error => ({ project: project.name, issues: undefined, error })),
28502850
)
28512851

28522852
const taskNames = projects.map(p => p.name)

scripts/lint.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,20 +330,20 @@ async function getFilesToLint(options) {
330330
mode = 'staged'
331331
changedFiles = getStagedFilesSync({ absolute: false })
332332
if (!changedFiles.length) {
333-
return { files: null, reason: 'no staged files', mode }
333+
return { files: undefined, reason: 'no staged files', mode }
334334
}
335335
} else if (changed) {
336336
mode = 'changed'
337337
changedFiles = getChangedFilesSync({ absolute: false })
338338
if (!changedFiles.length) {
339-
return { files: null, reason: 'no changed files', mode }
339+
return { files: undefined, reason: 'no changed files', mode }
340340
}
341341
} else {
342342
// Default to changed files if no specific flag
343343
mode = 'changed'
344344
changedFiles = getChangedFilesSync({ absolute: false })
345345
if (!changedFiles.length) {
346-
return { files: null, reason: 'no changed files', mode }
346+
return { files: undefined, reason: 'no changed files', mode }
347347
}
348348
}
349349

@@ -356,10 +356,10 @@ async function getFilesToLint(options) {
356356
// Filter to lintable files
357357
const lintableFiles = filterLintableFiles(changedFiles)
358358
if (!lintableFiles.length) {
359-
return { files: null, reason: 'no lintable files changed', mode }
359+
return { files: undefined, reason: 'no lintable files changed', mode }
360360
}
361361

362-
return { files: lintableFiles, reason: null, mode }
362+
return { files: lintableFiles, reason: undefined, mode }
363363
}
364364

365365
async function main() {
@@ -444,7 +444,7 @@ async function main() {
444444
// Get files to lint based on flags
445445
const { files, mode, reason } = await getFilesToLint(values)
446446

447-
if (files === null) {
447+
if (files === undefined) {
448448
if (!quiet) {
449449
logger.step('Skipping lint')
450450
logger.substep(reason)

scripts/utils/changed-test-mapper.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export function getTestsToRun(options = {}) {
103103

104104
if (changedFiles.length === 0) {
105105
// No changes, skip tests
106-
return { tests: null, mode }
106+
return { tests: undefined, mode }
107107
}
108108

109109
const testFiles = new Set()
@@ -169,7 +169,7 @@ export function getTestsToRun(options = {}) {
169169
}
170170

171171
if (testFiles.size === 0) {
172-
return { tests: null, mode }
172+
return { tests: undefined, mode }
173173
}
174174

175175
return { tests: Array.from(testFiles), mode }

scripts/validate/file-count.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ async function validateStagedFileCount() {
3838

3939
// Not a git repository
4040
if (!gitRoot.trim()) {
41-
return null
41+
return undefined
4242
}
4343

4444
// Get list of staged files
@@ -59,10 +59,10 @@ async function validateStagedFileCount() {
5959
}
6060
}
6161

62-
return null
62+
return undefined
6363
} catch {
6464
// Not a git repo or git not available
65-
return null
65+
return undefined
6666
}
6767
}
6868

scripts/validate/markdown-filenames.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ function validateFilename(filePath) {
168168
// README.md and LICENSE are special - allowed anywhere
169169
// Valid - allowed in any location
170170
if (nameWithoutExt === 'README' || nameWithoutExt === 'LICENSE') {
171-
return null
171+
return undefined
172172
}
173173

174174
// Check if it's an allowed SCREAMING_CASE file
@@ -183,7 +183,7 @@ function validateFilename(filePath) {
183183
}
184184
}
185185
// Valid
186-
return null
186+
return undefined
187187
}
188188

189189
// Check if it's in SCREAMING_CASE but not allowed
@@ -234,7 +234,7 @@ function validateFilename(filePath) {
234234
}
235235

236236
// Valid
237-
return null
237+
return undefined
238238
}
239239

240240
/**

0 commit comments

Comments
 (0)