Good naming is not about style — it’s about clarity, scalability, and long-term maintainability. Senior developers optimize for reading code six months later, not typing speed.
Why: Distinguishes components from HTML elements.
UserProfile.tsxSettingsSidebar.tsxModalConfirm.tsx
✅ Rule
use prefixWhy: React relies on this convention for rules of hooks.
useAuth.tsuseUserSettings.tsuseConnectionsTable.ts
Why: Consistency with JavaScript ecosystem.
const isAuthenticated = true;const fetchUserData = async () => {};
Boolean variables should sound like questions:
isOpenhasPermissioncanEdit
Why: Signals immutability instantly.
const MAX_RETRY_COUNT = 3;export const ROUTES = {HOME: "/",SETTINGS: "/settings",};
No I prefix (modern TypeScript best practice).
interface User {id: string;name: string;}type SortOrder = "asc" | "desc";
ComponentNamePropsWhy: Improves searchability and readability.
interface ModalProps {open: boolean;onClose: () => void;}
handle prefixWhy: Makes intent explicit.
const handleSubmit = () => {};const handleCloseModal = () => {};
JSX:
<button onClick={handleSubmit} />
Why: Works best across OS, Git, and URLs.
features/user-profile/user-profile.page.tsxuser-profile.hook.tsuser-profile.types.ts
home.page.tsxauth.layout.tsxuser-card.component.tsx
Rule:
| Item | Convention |
|---|---|
| Component | PascalCase |
| Hook | use + camelCase |
| Variable | camelCase |
| Boolean | is / has / can |
| Constant | SCREAMING_SNAKE_CASE |
| Type / Interface | PascalCase |
| Files | kebab-case |