no-enum
Disallow TypeScript enum declarations.
Targeted pattern scopeโ
This rule reports every TypeScript enum declaration (TSEnumDeclaration).
What this rule reportsโ
This rule reports every enum declaration. Enums emit runtime JavaScript and can complicate tree-shaking and interop. In codebases that prefer structural typing, literal unions and as const objects are easier to reason about and maintain.
Why this rule existsโ
It enforces enum-free TypeScript style where literal unions and as const
objects are preferred over enum runtime constructs.
โ Incorrectโ
enum Status {
Ready,
Running,
}
โ Correctโ
const Status = {
Ready: "Ready",
Running: "Running",
} as const;
type Status = (typeof Status)[keyof typeof Status];
Behavior and migration notesโ
This rule reports only and does not provide an autofix.
Migration is typically to as const object patterns plus derived union types.
Optionsโ
This rule has no options.
Additional examplesโ
enum HttpCode {
Ok = 200,
NotFound = 404,
}
// โ reported
const HttpCode = {
Ok: 200,
NotFound: 404,
} as const;
type HttpCode = (typeof HttpCode)[keyof typeof HttpCode];
// โ
valid
ESLint flat config exampleโ
import etcMisc from "eslint-plugin-etc-misc";
export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/no-enum": "error",
},
},
];
When not to use itโ
Disable this rule if your project intentionally standardizes on TypeScript enums and accepts their emitted runtime output.
Package documentationโ
Rule catalog ID: R023
Further readingโ
Adoption resourcesโ
- Start at warning level in CI, then move to error after cleanup.
- Use focused codemods/autofix batches per package or directory.