Classes
- Selector:
class - Required:
PascalCase
Why This Rule
PascalCase for classes is a universal convention across almost all programming languages (Java, C#, Python, Ruby, etc.). This convention:
- Instantly distinguishes types from values at a glance
- Matches constructor usage:
new UserService()reads naturally - Aligns with community standards: 99% of TypeScript codebases follow this
Benefits:
- When you see
UserService, you immediately know it's aclassor type. - When you see
userService, you know it's aninstanceorvariable.
This visual distinction reduces cognitive load and prevents naming conflicts.
References:
✅ Good
ts
class UserService {} // WHY: PascalCase - clearly a class/type
class HTTPClient {} // WHY: PascalCase with acronym – keeps class semantics clear❌ Bad
ts
class userService {} // WHY: camelCase for a class confuses instances with types
class user_service {} // WHY: snake_case is not appropriate for class names
class HTTPclient {} // WHY: Incorrect casing – should be PascalCase