> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# prefer-enum-initializers

[Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0)
## Configuration


```ts title=rslint.config.ts
import { defineConfig, ts } from '@rslint/core';

export default defineConfig([
  ts.configs.recommended,
  {
    rules: {
      '@typescript-eslint/prefer-enum-initializers': 'error',
    },
  },
]);
```

## Rule Details

Require each enum member to have an explicitly initialized value.

TypeScript enum members default to a sequential numeric value when no initializer is provided. Relying on that implicit numbering makes the enum fragile — inserting, deleting, or reordering members silently shifts the numeric value of every later member, which can break code that persisted those numbers (in storage, in a network protocol, in serialized output). Explicit initializers make the value of each member a documented, stable choice. For each uninitialized member, this rule reports a diagnostic and offers three suggestions: initialize to the member's current index, to the index plus one, or to a string matching the member's name.

Examples of **incorrect** code for this rule:

```typescript
enum Direction {
  Up,
  Down,
}

enum Status {
  Open = 1,
  Close,
}
```

Examples of **correct** code for this rule:

```typescript
enum Direction {
  Up = 1,
  Down = 2,
}

enum Status {
  Open = 'Open',
  Close = 'Close',
}

enum Empty {}
```

## Original Documentation

- [typescript-eslint: prefer-enum-initializers](https://typescript-eslint.io/rules/prefer-enum-initializers)
- [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/prefer-enum-initializers.ts)
