Skip to content

Commit 170262e

Browse files
committed
refactor(scripts): prefer undefined over null for absent values
1 parent 8769e82 commit 170262e

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

scripts/babel/babel-plugin-strict-mode.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
/**
2323
* Convert legacy octal literal (0123) to decimal number
2424
* @param {string} value - The numeric literal string
25-
* @returns {number|null} Decimal value or null if not octal
25+
* @returns {number|undefined} Decimal value or undefined if not octal
2626
*/
2727
function convertOctalLiteral(value) {
2828
// Match legacy octal: starts with 0, followed by octal digits (0-7)
2929
const octalMatch = /^0([0-7]+)$/.exec(value)
3030
if (!octalMatch) {
31-
return null
31+
return undefined
3232
}
3333

3434
const octalDigits = octalMatch[1]

scripts/build.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ const BUILD_PACKAGES = [
6767
*/
6868
function parseArgs() {
6969
const args = process.argv.slice(2)
70-
let target = null
70+
let target
7171
let targets = []
7272
let platforms = false
7373
let parallel = false
7474
let force = false
7575
let help = false
76-
let platform = null
77-
let arch = null
76+
let platform
77+
let arch
7878
const buildArgs = []
7979

8080
for (let i = 0; i < args.length; i++) {

scripts/lib/patch-validator.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export function analyzePatchContent(patchContent) {
179179
}
180180

181181
const lines = patchContent.split('\n')
182-
let currentFile = null
182+
let currentFile
183183

184184
for (const line of lines) {
185185
// Track which files are modified.

scripts/setup.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ async function getVersion(command, args = ['--version']) {
9898
} catch {
9999
// Ignore.
100100
}
101-
return null
101+
return undefined
102102
}
103103

104104
/**
105105
* Parse version string to compare.
106106
*/
107107
function parseVersion(versionString) {
108108
const match = versionString.match(/(\d+)\.(\d+)\.(\d+)/)
109-
if (!match) {return null}
109+
if (!match) {return undefined}
110110
return {
111111
major: Number.parseInt(match[1], 10),
112112
minor: Number.parseInt(match[2], 10),

scripts/test-monorepo.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ async function main() {
204204
}
205205

206206
// Setup progress bar.
207-
let progressBar = null
207+
let progressBar
208208
if (!quiet && packages.length > 1) {
209209
progressBar = new ProgressBar(packages.length, {
210210
format: ':bar :percent :current/:total :pkg',

scripts/update-socketbin-versions.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async function getLatestVersion(packageName) {
2121
return result.stdout.trim()
2222
} catch (error) {
2323
console.error(`Failed to get version for ${packageName}:`, error.message)
24-
return null
24+
return undefined
2525
}
2626
}
2727

scripts/validate-bundle-deps.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ async function extractBundledPackages(filePath) {
130130
function getPackageName(specifier) {
131131
// Relative imports are not packages
132132
if (specifier.startsWith('.') || specifier.startsWith('/')) {
133-
return null
133+
return undefined
134134
}
135135

136136
// Subpath imports (Node.js internal imports starting with #)
137137
if (specifier.startsWith('#')) {
138-
return null
138+
return undefined
139139
}
140140

141141
// Filter out template strings, boolean strings, and other non-package patterns
@@ -160,7 +160,7 @@ function getPackageName(specifier) {
160160
specifier.includes("'") ||
161161
specifier.includes('\\')
162162
) {
163-
return null
163+
return undefined
164164
}
165165

166166
// Scoped package: @scope/package or @scope/package/subpath
@@ -169,7 +169,7 @@ function getPackageName(specifier) {
169169
if (parts.length >= 2) {
170170
return `${parts[0]}/${parts[1]}`
171171
}
172-
return null
172+
return undefined
173173
}
174174

175175
// Regular package: package or package/subpath

0 commit comments

Comments
 (0)