noEnum
此内容尚不支持你的语言。
Diagnostic Category: lint/nursery/noEnum
Since: v1.9.0
Disallow TypeScript enum.
TypeScript enums are not a type-level extension to JavaScript like type annotations or definitions. Users may wish to disable non-type-level extensions to use bundlers or compilers that only strip types.
Const enums are not covered by this rule since noConstEnum
already handles them.
Enums within the ambient context, including declaration files, are ignores as well.
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-block.ts:1:1 lint/nursery/noEnum ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Don’t use enum
> 1 │ enum Foo {
│ ^^^^^^^^^^
> 2 │ BAR = ‘bar’,
> 3 │ BAZ = ‘baz’,
> 4 │ }
│ ^
5 │
ℹ TypeScript enums are not a type-level extension to JavaScript like type annotations or definitions. Users may wish to disable non-type-level extensions to use bundlers or compilers that only strip types.
ℹ Use JavaScript objects or TypeScript unions instead.