src/content/docs/linter/rules/no-duplicate-enum-values.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> :::caution This rule is part of the [nursery](/linter/#nursery) group. This means that it is experimental and the behavior can change at any time. ::: ## Summary - Rule available since: `v2.3.12` - Diagnostic Category: [`lint/nursery/noDuplicateEnumValues`](/reference/diagnostics#diagnostic-category) - This rule doesn't have a fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - Sources: - Same as [`@typescript-eslint/no-duplicate-enum-values`](https://typescript-eslint.io/rules/no-duplicate-enum-values){
"linter": {
"rules": {
"nursery": {
"noDuplicateEnumValues": "error"
}
}
}
}
Disallow duplicate enum member values.
Although TypeScript supports duplicate enum member values, people usually expect members to have unique values within the same enum. Duplicate values can lead to bugs that are hard to track down.
enum E {
A = 0,
B = 0,
}
enum E {
A = "A",
B = 'A',
C = `A`,
}
enum E {
A = 0,
B = 1,
}
enum E {
A = "A",
B = 'B',
C = `C`,
}