@@ -26,8 +26,8 @@ worst cases, their limitations may be unknown, and thus unguarded.
26
26
### Detection
27
27
28
28
TypeScript deprecation can be linted using a fairly short ESLint plugin. The code has [ already been
29
- contributed to main] [ no-enum-lint ] as a suggestion. The same PR adds ` FIXME ` comments for each team
30
- to address.
29
+ contributed to main] [ no-enum-lint ] and is configured as [ an error-level
30
+ lint ] [ no-enum-configuration ] . The same PR adds ` FIXME ` comments for each team to address.
31
31
32
32
### The Enum-like Pattern
33
33
@@ -77,12 +77,12 @@ const m = new Map([[CipherType.Login, ""]]); // `m` is a `Map<CipherType, string
77
77
78
78
## Considered Options
79
79
80
- - ** Allow enums, but advise against them** - This is the current state of affairs. With this option,
81
- teams ** must ** address the FIXMEs, but _ may _ address them by disabling the lint.
80
+ - ** Allow enums, but advise against them** - Allow enum use to be decided on a case-by-case basis by
81
+ the team that owns the enum. Reduce the level of the lint to a "suggestion" .
82
82
- ** Deprecate enum use** - Allow enums to exist for historic or technical purposes, but prohibit the
83
- introduction of new ones. Increase the lint to a "warning" and allow the lint to be disabled.
84
- - ** Eliminate enum use** - Prohibit the introduction of any new enum and replace all enums in the
85
- codebase with typescript objects. Increase the lint to an "error" and prohibit disabling of the
83
+ introduction of new ones. Reduce the lint to a "warning" and allow the lint to be disabled.
84
+ - ** Eliminate enum use** - This is the current state of affairs. Prohibit the introduction of any
85
+ new enum and replace all enums in the codebase with typescript objects. Prohibit disabling of the
86
86
lint.
87
87
88
88
## Decision Outcome
@@ -107,13 +107,6 @@ Chosen option: **Deprecate enum use**
107
107
- Update contributing docs with patterns and best practices for enum replacement.
108
108
- Update the reporting level of the lint to "warning".
109
109
110
- [ computed-property-names] :
111
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#computed_property_names
112
- [ literal-type ] : https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types
113
- [ no-enum-lint ] : https://github.com/bitwarden/clients/blob/main/libs/eslint/platform/no-enums.mjs
114
- [ no-member-fields-fixed] :
115
- https://devblogs.microsoft.com/typescript/announcing-typescript-5-8-beta/#preserved-computed-property-names-in-declaration-files
116
-
117
110
## Appendix A: Mapped Types and Enum-likes
118
111
119
112
Mapped types cannot determine that a mapped enum-like object is fully assigned. Code like the
@@ -194,3 +187,12 @@ if (available.includes(CipherType.Login)) {
194
187
// ...
195
188
}
196
189
```
190
+
191
+ [ computed-property-names] :
192
+ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#computed_property_names
193
+ [ literal-type ] : https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types
194
+ [ no-enum-lint ] : https://github.com/bitwarden/clients/blob/main/libs/eslint/platform/no-enums.mjs
195
+ [ no-enum-configuration] :
196
+ https://github.com/bitwarden/clients/blob/032fedf308ec251f17632d7d08c4daf6f41a4b1d/eslint.config.mjs#L77
197
+ [ no-member-fields-fixed] :
198
+ https://devblogs.microsoft.com/typescript/announcing-typescript-5-8-beta/#preserved-computed-property-names-in-declaration-files
0 commit comments