SKY-U007 · Dead code
Unused TypeScript enum member
A member has no literal read in a module-local enum, or in an exported enum of an internal module whose direct named imports are fully known. Public and opaque enum surfaces remain live.
- Languages
- TypeScript
- Turned on by
skylos .- Quality gate
- counted toward the gate limits (full and diff scans). Reported in unused_variables with its own SKY-U007 ID; counts toward max_dead_code, which is unlimited by default.
- Finding type
- review
Why it matters
An obsolete enum member can keep a removed state or workflow looking supported. Removing numeric members can change later implicit values, so the finding requires review.
What Skylos flags
export {};enum Status { Ready = "ready", Spare = "spare",}console.log(Status.Ready);What Skylos leaves alone
export {};enum Status { Ready = "ready", Spare = "spare",}console.log(Object.values(Status));Why Skylos leaves it alone
Reflection consumes the enum object without proving which members a downstream consumer needs, so all members remain live.
More languages
TypeScript
Flagged
{"name":"app","private":true,"type":"module","main":"app.ts"}export enum Status { Ready = "ready", Spare = "spare"}import { Status as Mode } from "./status";console.log(Mode.Ready);Not flagged
import { Status as Mode } from "./status";console.log(Object.values(Mode));Why Skylos leaves it alone
The source inventory is known, but reflection makes the member demand opaque. The enum is retained rather than narrowed.
How Skylos decides
- Reads implementation enums in explicit TypeScript modules. Local enums can be narrowed inside their module; an exported enum requires an internal module (not a package.json entry, tool or framework entry, file named by path or module no file imports, the SKY-E004 notion) and a complete source inventory. The package need not be private.
- For an exported enum, resolves direct named imports and aliases to their provider before combining literal member reads across files. Namespace imports, re-exports and dynamic loaders prevent this proof. A Vue, Svelte or Astro component, HTML module script or MDX document that imports the enum's module is read as an opaque consumer of that module's enums (a template can read members its script never names); other modules keep exact narrowing. An unresolved import holds back only the module its last segment names, or the workspace package a bare specifier names; a relative import that matches no file cannot load an existing enum.
@public,@alphaand@betaJSDoc tags on an enum or member keep it live.- Resolves literal member reads and constant aliases. Dynamic indexing, reflection, mutation, escapes, declaration merging and effectful initializers decline member narrowing.
- Retains members referenced by other initializers. If no member is read, leaves the entire enum to the existing unused-owner finding instead of listing every member.
- Reports LOW at the member declaration. analysis_summary.enum_member_analysis identifies scope local_and_internal_module_enums and records checked enums, abstentions, unresolved imports and incomplete source graph reads.
How to fix it
Remove a genuinely obsolete member after checking that remaining enum values and external contracts stay correct. This string-valued example preserves the retained member value.
export {};enum Status { Ready = "ready",Removed: Spare = "spare",}console.log(Status.Ready);When it can be wrong
- Code loaded outside the selected project may impose a contract the module does not expose statically.
- An unread numeric member can still influence later automatically assigned values; the rule does not authorize automatic removal.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Set
[tool.skylos] ignore = ["SKY-U007"]to disable this rule project-wide.