Skip to content

Extract hardcoded magic numbers to named constants in watch.js and resolver.js #95

Description

@sametcelikbicak

Summary

Replace hardcoded magic numbers with named constants for better readability and maintainability.

Current Magic Numbers

  1. Watch debounce delaysrc/commands/watch.js line 79: hardcoded 300
  2. Scanner max depthsrc/utils/resolver.js line 92: hardcoded 3
  3. Lockfile versionsrc/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions