deslop/unused-enum-member

Flag an enum member that is declared but never referenced anywhere in the project (e.g. `enum Color { Red, Green, Blue }` where `Color.Blue` is never used).

  • Category: Dead Code
  • 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 finds no static Enum.Member property reference for a member, emitting reason "Enum.Member is declared but never referenced" with a trace line "no static Enum.Member reference found in the project"; the detector first skips the ENTIRE enum if it sees any element access (Enum[expr]) or any whole-object use (the enum identifier referenced as anything other than a direct property access, qualified name, element access, or type/typeof reference — including being passed into a helper), then for surviving enums sets confidence by kind (low for const enum, high for pure string enums, medium for numeric). False positive: the member's VALUE — not its Enum.Member identifier — is what is load-bearing, so it is serialized/persisted by value or matched over an external wire/API contract, and the value is reconstructed from a runtime string/number the detector cannot resolve back to a static Enum.Member access, meaning no such reference exists even though removing the member would silently break the encoding.

Fix prompt

Use this once validation confirms the diagnostic is real.

Delete the dead member: remove Blue from enum Color { Red, Green, Blue }, leaving enum Color { Red, Green }, and for a non-const numeric enum check that removing a middle member does not shift the auto-assigned numeric values of later members that are persisted or compared by value (pin them with explicit initializers, e.g. Green = 1, before deleting). If the member is genuinely referenced only by its value over a wire or in storage, keep it and instead add a real use of Color.Blue (or suppress) rather than deleting. See https://github.com/millionco/deslop-js