noDuplicateEnumValues
此内容尚不支持你的语言。
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/noDuplicateEnumValues - This rule doesn’t have a fix.
- The default severity of this rule is information.
- Sources:
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noDuplicateEnumValues": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”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`,}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.