no-mixed-enums
Disallow enum members that mix numeric and string representations.
Targeted pattern scopeโ
This rule targets TypeScript enum declarations.
What this rule reportsโ
This rule reports enums that mix member value kinds (for example, both string and numeric members).
Why this rule existsโ
Mixed enum value kinds make comparisons and serialization rules harder to understand.
โ Incorrectโ
enum State {
open = "open",
closed = 2,
}
โ Correctโ
enum State {
open = 1,
closed = 2,
}
Behavior and migration notesโ
This rule forwards options and behavior to
@typescript-eslint/no-mixed-enums.
- Lifecycle: Deprecated and frozen.
- Deprecated since:
v1.0.0 - Available until:
v2.0.0 - Use instead:
@typescript-eslint/no-mixed-enums
Additional examplesโ
enum NumericStatus {
Open = 1,
Closed = 2,
}
// โ
valid
enum MixedStatus {
Open = "open",
Closed = 2,
}
// โ reported
ESLint flat config exampleโ
import etcMisc from "eslint-plugin-etc-misc";
export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/no-mixed-enums": "error",
},
},
];
When not to use itโ
Disable this rule if mixed enums are required for compatibility with external wire formats.
Package documentationโ
Rule catalog ID: R032
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.