---
title: "@typescript-eslint/prefer-enum-initializers"
description: "Require every enum member to have an explicit value"
# Generated by src/codegen/lint-rule-docs.ts. Do not edit below this line.
plugin: "typescript"
aliases: ["typescript-eslint/prefer-enum-initializers","typescript/prefer-enum-initializers"]
kind: "suggestion"
category: "pedantic"
default: "off"
fixable: "suggestion"
typeAware: false
deprecated: false
---

An enum member without a value gets a number from its position. The first is `0`, and each one after that is one more than the member before it. If you add a member in the middle or sort the list, every member after it gets a new number. Values that were saved in a database or sent to another service now mean something else.

Each member without a value is reported.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"@typescript-eslint/prefer-enum-initializers" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 3} */}
```ts
enum Status {
  Draft,
  Published,
  Archived,
}
```

Not reported:

{/* good */}
```ts
enum Status {
  Draft = 0,
  Published = 1,
  Archived = 2,
}

enum Role {
  Admin = "admin",
  Member = "member",
}
```

## When not to use it

If the values never leave the program and you only compare members with each other, the numbers don't matter.
