Skip to main content

consistent-enum-members

Enforce consistent enum member naming/value casing.

Targeted pattern scopeโ€‹

This rule analyzes TypeScript TSEnumMember nodes and validates naming for:

  • enum member identifiers (for example ACTIVE_USER), and
  • string literal member values when provided.

It enforces SCREAMING_SNAKE_CASE in both places.

What this rule reportsโ€‹

This rule reports enum members when neither of these matches SCREAMING_SNAKE_CASE:

  • the member identifier name, or
  • the string literal initializer value.

In other words, the current implementation accepts a member if either side is already SCREAMING_SNAKE_CASE.

Why this rule existsโ€‹

Enums often feed API payloads, persistence layers, and feature flags. Mixed casing (camelCase, PascalCase, kebab-case) creates drift between modules. Standardizing enum casing lowers conversion glue and helps grepability.

โŒ Incorrectโ€‹

enum Status {
pendingApproval = "PENDING_APPROVAL",
ACTIVE_USER = "active_user",
}

โœ… Correctโ€‹

enum Status {
PENDING_APPROVAL = "PENDING_APPROVAL",
ACTIVE_USER = "ACTIVE_USER",
}

Behavior and migration notesโ€‹

This rule reports only and does not provide an autofix.

Optionsโ€‹

This rule has no options.

Additional examplesโ€‹

enum EventType {
USER_CREATED,
USER_DELETED,
}
enum Permission {
READ_ONLY = "READ_ONLY",
READ_WRITE = "READ_WRITE",
}



enum Partial { USER_CREATED = "user_created",}
// โœ… currently accepted (name matches SCREAMING_SNAKE_CASE)

## ESLint flat config example

```ts
import etcMisc from "eslint-plugin-etc-misc";

export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/consistent-enum-members": "error",
},
},
];

When not to use itโ€‹

Disable this rule if your project intentionally uses enum names/values that must mirror external schemas with different casing requirements.

Package documentationโ€‹

Rule catalog ID: R005

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.