You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat(eslint-plugin): create a new rule to disallow duplicate enum values
* fix(eslint-plugin): remove unused imported variable from no-duplicate-enum-values.test.ts
* fix(eslint-plugin): test falsy values and fix some metadata
* fix(eslint-plugin): make Enums in the falsy test valid
Co-authored-by: Josh Goldberg <[email protected]>
Copy file name to clipboardExpand all lines: packages/eslint-plugin/README.md
+1
Original file line number
Diff line number
Diff line change
@@ -119,6 +119,7 @@ Pro Tip: For larger codebases you may want to consider splitting our linting int
119
119
|[`@typescript-eslint/no-base-to-string`](./docs/rules/no-base-to-string.md)| Requires that `.toString()` is only called on objects which provide useful information when stringified |||:thought_balloon:|
120
120
|[`@typescript-eslint/no-confusing-non-null-assertion`](./docs/rules/no-confusing-non-null-assertion.md)| Disallow non-null assertion in locations that may be confusing ||:wrench:||
121
121
|[`@typescript-eslint/no-confusing-void-expression`](./docs/rules/no-confusing-void-expression.md)| Requires expressions of type void to appear in statement position ||:wrench:|:thought_balloon:|
122
+
|[`@typescript-eslint/no-duplicate-enum-values`](./docs/rules/no-duplicate-enum-values.md)| Disallow duplicate enum member values ||||
122
123
|[`@typescript-eslint/no-dynamic-delete`](./docs/rules/no-dynamic-delete.md)| Disallow the delete operator with computed key expressions ||:wrench:||
123
124
|[`@typescript-eslint/no-empty-interface`](./docs/rules/no-empty-interface.md)| Disallow the declaration of empty interfaces |:white_check_mark:|:wrench:||
124
125
|[`@typescript-eslint/no-explicit-any`](./docs/rules/no-explicit-any.md)| Disallow usage of the `any` type |:white_check_mark:|:wrench:||
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.
6
+
7
+
## Rule Details
8
+
9
+
This rule disallows defining an enum with multiple members initialized to the same value. Now it only enforces on enum members initialized with String or Number literals. Members without initializer or initialized with an expression are not checked by this rule.
0 commit comments