# no-unsafe-enum-assignment

Rule `typescript/no-unsafe-enum-assignment`. Disallow assigning non-enum values to enum typed locations

- Source: typescript
- Technologies: TypeScript
- Kind: suspicious
- Needs type information: yes
- Autofix: no
- Reach: 46.6M weekly downloads of presets that enable it
- Trend: +31.9% last quarter
- Rank: #284 by reach, #1110 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `@typescript-eslint/no-unsafe-enum-assignment` | no | no | package `@typescript-eslint/eslint-plugin` | [docs](https://typescript-eslint.io/rules/no-unsafe-enum-assignment) |
| Oxlint | `typescript/no-unsafe-enum-assignment` | no | no | plugin `typescript`, category suspicious | [docs](https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-unsafe-enum-assignment.html) |

## Code examples

### Incorrect: the rule reports this

```ts
enum Fruit {
  Apple,
}

declare const someNumber: number;

// Fruit.Apple is set to 0, so TypeScript allows this literal.
const fruit: Fruit = 0;
```

```ts
enum Vegetable {
  Asparagus = 'asparagus',
}

let mutated: Vegetable = Vegetable.Asparagus;

mutated++;
mutated += 1;
```

### Correct: the rule accepts this

```ts
enum Fruit {
  Apple,
}

const fruit: Fruit = Fruit.Apple;
```

```ts
enum Vegetable {
  Asparagus = 'asparagus',
  Broccoli = 'broccoli',
}

let reassigned: Vegetable = Vegetable.Asparagus;
reassigned = Vegetable.Broccoli;
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import tseslint from "typescript-eslint";

export default [
  {
    plugins: { "@typescript-eslint": tseslint.plugin },
    rules: {
      "@typescript-eslint/no-unsafe-enum-assignment": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "typescript/no-unsafe-enum-assignment": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [typescript-eslint strict type-checked](https://lintradar.dev/presets/typescript-eslint-strict-type-checked.md) | ESLint | `@typescript-eslint/eslint-plugin` | 75 | 175.9M | +29.5% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |
| [eslint-config-love](https://lintradar.dev/presets/love.md) | ESLint | `eslint-config-love` | 258 | 171.7K | +39.3% |

## Related rules

- [typescript/no-confusing-non-null-assertion](https://lintradar.dev/rules/typescript/no-confusing-non-null-assertion.md): Disallow non-null assertion in locations that may be confusing
- [typescript/prefer-return-this-type](https://lintradar.dev/rules/typescript/prefer-return-this-type.md): Enforce that `this` is used when only `this` type is returned
- [typescript/consistent-generic-constructors](https://lintradar.dev/rules/typescript/consistent-generic-constructors.md): Enforce specifying generic type arguments on type annotation or constructor name of a constructor call
- [typescript/related-getter-setter-pairs](https://lintradar.dev/rules/typescript/related-getter-setter-pairs.md): Enforce that `get()` types should be assignable to their equivalent `set()` type
- [typescript/ban-tslint-comment](https://lintradar.dev/rules/typescript/ban-tslint-comment.md): Disallow `// tslint:<rule-flag>` comments
- [typescript/use-unknown-in-catch-callback-variable](https://lintradar.dev/rules/typescript/use-unknown-in-catch-callback-variable.md): Enforce typing arguments in Promise rejection callbacks as `unknown`

---

Web page: https://lintradar.dev/rules/typescript/no-unsafe-enum-assignment. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
