Can ESLint be configured to flag the declaration of a string enum
? E.g.:
enum Foo {
Bar = "bar",
Baz = "baz",
}
This is different from the no-mixed-enums
rule. I have looked into no-restricted-syntax
, but that doesn't cover @typescript-eslint
rules as far as I know.
Some context:
- Enums, particularly string enums are often considered anti-patterns, as is succinctly elaborated in this Stack Overflow post.
- For now I would like to allow plain (unassigned integer) enums, so I wouldn't want to lint against the keyword itself.
- Any linter config that flags any assignation of enum values would also work.
Eventually I would want all string enum
declarations to be auto-fixable by a string union type
, i.e.:
type Foo = "bar" | "baz";
Is there perhaps a plugin that can help with any of this?