Skip to content

no-duplicate-enum-values

Reports an enum member initialised with a string or number that an earlier member of the same enum already has (A = 0, B = 0). Computed values (1 + 1) are not compared.

Two names for one value make a value to name lookup (the reverse mapping of a numeric enum) answer with the later one, and the second member is usually a copy-paste mistake with the value not changed.

To fix, give the member its own value.

Reported
enum E {
A = 0,
B = 0,
C = "c",
}
js:
lint:
rules:
no-duplicate-enum-values: warn # off (default), warn, error

Enabled by the presets: js/typescript-eslint-recommended, js/biome-recommended, js/oxlint.

Suppress one line with sudsy-disable-next-line no-duplicate-enum-values in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
typescript-eslint no-duplicate-enum-values full