Przejdź do głównej zawartości

noDuplicateEnumValues

Ta treść nie jest jeszcze dostępna w Twoim języku.

biome.json
{
"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,
}
code-block.ts:3:3 lint/nursery/noDuplicateEnumValues ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Duplicate enum member value.

1 │ enum E {
2 │ A = 0,
> 3 │ B = 0,
^^^^^
4 │ }
5 │

Expected members to have unique values. Duplicate values can lead to bugs that are hard to track down.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

enum E {
A = "A",
B = 'A',
C = `A`,
}
code-block.ts:3:3 lint/nursery/noDuplicateEnumValues ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Duplicate enum member value.

1 │ enum E {
2 │ A = “A”,
> 3 │ B = ‘A’,
^^^^^^^
4 │ C = `A`,
5 │ }

Another duplicate enum member value.

2 │ A = “A”,
3 │ B = ‘A’,
> 4 │ C = `A`,
^^^^^^^
5 │ }
6 │

Expected members to have unique values. Duplicate values can lead to bugs that are hard to track down.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

enum E {
A = 0,
B = 1,
}
enum E {
A = "A",
B = 'B',
C = `C`,
}