# `deslop/duplicate-constant`

Unify the same literal value duplicated as constants across 3+ files into one shared constant.

- **Category:** Architecture
- **Severity:** warn
- **Source:** deslop-js
- **Framework:** global
- **Enabled when:** react-doctor deadCode analysis enabled (default true); whole-project scan only — skipped in --diff/--staged modes
- **Documentation:** <https://github.com/millionco/deslop-js>

## Validation prompt

Use this to decide whether a fired diagnostic is real or a false positive.

Fires when deslop's detectDuplicateConstants finds the same literalHash bound to const declarations in 3+ distinct files: either "N copies of `const NAME = preview` across F files — extract to a shared module" (high confidence, every occurrence shares one name) or "N constants across F files share the same literal value PREVIEW under different names (a, b) — consider extracting" (medium confidence). It only considers meaningful literals (strings of 8+ chars, numbers with absolute value 1000+, single-part template literals, or literal arrays) and already skips differently-named constants that carry distinct unit suffixes like _MS vs _SEC. False positive to SUPPRESS: the values are equal only by coincidence and name two genuinely unrelated concepts (e.g. an HTTP timeout of 30000 and a cache TTL that happens to also be 30000, or two unrelated magic strings) — merging them would couple things that should be free to diverge, so leave them separate.

## Fix prompt

Use this once validation confirms the diagnostic is real.

Define the value once in a shared module and import it everywhere: export const REQUEST_TIMEOUT_MS = 30000 in a constants file, then replace each local const with that import so a future change happens in one place. When the duplicates have different names, pick the clearest single name before consolidating; when they truly mean different things, keep them separate (and ideally rename so the coincidence is obvious) rather than forcing a shared constant. See https://github.com/millionco/deslop-js
