Disallow the use of all enums (no-enum)

November 6, 2021 ยท View on GitHub

This rule disallows the use of all types of TypeScript enums.

Rule Details

Examples of incorrect code for this rule:

enum Foo {
  Bar,
  Baz,
}

const enum Foo {
  Bar = "Bar",
  Baz = "Baz",
}

enum Foo {
  Bar = "BAR",
  Baz = "BAZ",
}

Examples of correct code for this rule:

const Foo = {
  Bar: 0,
  Baz: 1,
} as const;

type Foo = "Bar" | "Baz";

const Foo = {
  Bar: "BAR",
  Baz: "BAZ",
} as const;