Skip to content

no-enum

Disallow TypeScript enum; use string-literal unions or as const objects instead.

Why

Literal unions keep type-only domains explicit, while constant objects make runtime values deliberate. This policy also avoids compiler-dependent const-enum inlining contracts.

Fix

Use a literal union or an as const object after checking runtime member access, numeric reverse mappings, serialized values, and public consumers.

Examples

Before — flagged A numeric enum emits a mutable runtime object
src/status.ts
enum Status {
Active,
Inactive,
}
After — preferred A string-literal union has no emitted runtime enum
src/status.ts
type Status = "active" | "inactive";

Options

{
"additionalProperties": false,
"properties": {
"ignoreFiles": {
"description": "Additional generated-file globs to ignore; shared generated paths and header markers are always ignored.",
"items": { "type": "string" },
"type": "array"
}
},
"type": "object"
}

References