Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Open
Description
Do not allow number literals to be used instead of enums. I could think of three places that this can happen:
- Function arguments
- Binary expressions
- Assignment expressions
enumFoo{ONE,TWO}functiongetFoo(f:Foo){if(f===Foo.ONE){// Good}if(f===1){// Bad}letff:Foo;ff=Foo.TWO// Goodff=1// Bad}getFoo(Foo.ONE)// GoodgetFoo(1)// Bad
Rule name
I need help with naming it according to conventions
Options
I don't think this rule needs any options. I don't see why anyone wants to use number literals for enums.