Skip to main content

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.

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.