Skip to content

Commit 58e5177

Browse files
committed
revise current state description
1 parent d3e7d47 commit 58e5177

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

docs/architecture/adr/0025-ts-deprecate-enums.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ worst cases, their limitations may be unknown, and thus unguarded.
2626
### Detection
2727

2828
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.
3131

3232
### The Enum-like Pattern
3333

@@ -77,12 +77,12 @@ const m = new Map([[CipherType.Login, ""]]); // `m` is a `Map<CipherType, string
7777

7878
## Considered Options
7979

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".
8282
- **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
8686
lint.
8787

8888
## Decision Outcome
@@ -107,13 +107,6 @@ Chosen option: **Deprecate enum use**
107107
- Update contributing docs with patterns and best practices for enum replacement.
108108
- Update the reporting level of the lint to "warning".
109109

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-
117110
## Appendix A: Mapped Types and Enum-likes
118111

119112
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)) {
194187
// ...
195188
}
196189
```
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

Comments
 (0)