Summary
Replace hardcoded magic numbers with named constants for better readability and maintainability.
Current Magic Numbers
- Watch debounce delay —
src/commands/watch.js line 79: hardcoded 300
- Scanner max depth —
src/utils/resolver.js line 92: hardcoded 3
- Lockfile version —
src/utils/lockfile.js line 323: hardcoded 3
How to Fix
For each file, define a constant at the top of the file and use it instead of the magic number:
// in watch.js
const WATCH_DEBOUNCE_MS = 300
// in resolver.js
const SCAN_MAX_DEPTH = 3
// in lockfile.js
const LOCKFILE_VERSION = 3
Then replace the hardcoded values with the constant names.
Why This Matters
Magic numbers make code harder to understand and maintain. Named constants document the meaning of the value and make future changes easier.
Difficulty
Easy — pure refactor, no behavior change.
Files
src/commands/watch.js
src/utils/resolver.js
src/utils/lockfile.js
Summary
Replace hardcoded magic numbers with named constants for better readability and maintainability.
Current Magic Numbers
src/commands/watch.jsline 79: hardcoded300src/utils/resolver.jsline 92: hardcoded3src/utils/lockfile.jsline 323: hardcoded3How to Fix
For each file, define a constant at the top of the file and use it instead of the magic number:
Then replace the hardcoded values with the constant names.
Why This Matters
Magic numbers make code harder to understand and maintain. Named constants document the meaning of the value and make future changes easier.
Difficulty
Easy — pure refactor, no behavior change.
Files
src/commands/watch.jssrc/utils/resolver.jssrc/utils/lockfile.js