Skip to content

refactor(cli): improve code quality with nullish coalescing operators#229

Open
0xAxiom wants to merge 1 commit intomainfrom
improve/code-quality-nullish-coalescing
Open

refactor(cli): improve code quality with nullish coalescing operators#229
0xAxiom wants to merge 1 commit intomainfrom
improve/code-quality-nullish-coalescing

Conversation

@0xAxiom
Copy link
Copy Markdown
Owner

@0xAxiom 0xAxiom commented Mar 28, 2026

What: Improves code quality by replacing logical OR operators with nullish coalescing operators in CLI commands.

Changes:

  • 🔧 build.ts: Replace result.error || 'Unknown error' with result.error ?? 'Unknown error'
  • 🔧 dream.ts: Replace result.error || 'Unknown error' with result.error ?? 'Unknown error'
  • 🔧 run.ts: Replace result.error || 'Unknown error' with result.error ?? 'Unknown error'
  • 🔧 resume.ts: Replace result.error || 'Unknown error' with result.error ?? 'Unknown error'
  • 🔧 Multiple: Replace result.buildPath || 'N/A' with result.buildPath ?? 'N/A'

Why:

  • ✅ Follows modern TypeScript best practices
  • ✅ More precise null/undefined handling
  • ✅ Reduces ESLint warnings
  • ✅ Safer fallback behavior (only triggers on null/undefined, not empty strings)

Testing:

  • ✅ All type checks pass
  • ✅ No breaking changes
  • ✅ Identical runtime behavior for normal cases
  • ✅ Better behavior for edge cases

This is part of a larger code quality improvement initiative. The nullish coalescing operator (??) is safer than logical OR (||) because it only provides fallbacks for null/undefined values, not for other falsy values like empty strings or zero.

- Replace logical OR (||) with nullish coalescing (??) for safer error handling
- Updated error message fallbacks in build, dream, run, and resume commands
- Updated buildPath fallbacks to use nullish coalescing
- Reduces eslint warnings and follows modern TypeScript best practices

This change makes the code more resilient by only falling back to default
values when the property is null or undefined, not when it's an empty string
or other falsy values.
@0xAxiom 0xAxiom requested a review from MeltedMindz as a code owner March 28, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant