Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum naming convention? #22

Open
krukru opened this issue Mar 13, 2018 · 4 comments
Open

Enum naming convention? #22

krukru opened this issue Mar 13, 2018 · 4 comments

Comments

@krukru
Copy link
Contributor

krukru commented Mar 13, 2018

How do you write enums and on what should we all agree?

@jakagacic
Copy link

I use pascal case to name the enum itself and upper case to define its constants, an example would be:

export enum CandleSize {
    ONE_MINUTE = 1,
    FIVE_MINUTES = 5,
}

@vilimco
Copy link
Contributor

vilimco commented Mar 13, 2018

like @jakagacic wrote, PascalCase for name without Enum in its naming, values in uppercase snail case.

@renatoruk
Copy link
Contributor

renatoruk commented Mar 13, 2018

What about vanilla JS, non TS? Is this the equivalent?

export const CandleSize = {
    ONE_MINUTE = 1,
    FIVE_MINUTES = 5,
}

@krukru
Copy link
Contributor Author

krukru commented Mar 13, 2018

My preference is to go with PascalCase like suggested in the docs

enum Direction {
    Up = "UP",
    Down = "DOWN",
    Left = "LEFT",
    Right = "RIGHT",
}

but seeing that the majority likes uppercase SNAKE_CASE, why not. Linter doesnt support checking for this (without a plugin), so lets just write it in the docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants