-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
@typescript-eslint/naming-convention: enumMember should not be in strictCamelCase
#43
Comments
It was an intentional choice. I'm aware the TS docs use pascal-case, but it honestly makes no sense to me. Enum cases are members, and all other kinds of members are camel-case. I think the Swift style enum casing looks the best and makes the most sense: enum CardSuit {
case clubs
case diamonds
case hearts
case spades
} |
That seems like a weird decision to make, we aren't writing Swift, we're writing TypeScript. It's also not accurate to compare enum members to other object members. Enum values are readonly constants which have never had the same naming convention as regular variables/object members. Node.js themselves use Also worth mentioning is that enum members are implicitly types as well as values: enum Color {
R, G, B
}
const value: Color.R = Color.R; Having this rule seems like a mistake and I think most other XO users will agree. I'd recommend simply removing the |
Interestingly I dont seem to use enums in TypeScript ( My other language Rust where I use enums PascalCase is used (or the linter warns about not using it) |
TypeScript makes a ton of mistakes and weird choices by default.
Those are not enum values though. And Node.js is not a good example of well-done APIs.
This would be totally fine too: const value: Color.r = Color.r;
I think most people don't use TS enums as they're weirdly designed and also doesn't fit with JS. Most people use unions. |
That being said, I don't use TS enums, so I agree with just ignoring it in the rule: https://github.com/xojs/eslint-config-xo-typescript/releases/tag/v0.45.2 |
eslint-config-xo-typescript/index.js
Line 286 in 7c1e7d2
enumMember
s should not be instrictCamelCase
.TypeScript documentation doesn't make a specific recommendation of
enum
member naming, although they exclusively useStrictPascalCase
andUPPER_CASE
(both of which are reasonable).The text was updated successfully, but these errors were encountered: