$ npx @airuleshub/cli@latest add expo-native-typescript-rulesRule Content
Expo React Native + TypeScript Development Rules
Project Stack
- Framework: Expo (React Native)
- Language: TypeScript
- Navigation: Expo Router or React Navigation
- State Management: Prefer React Context or Zustand
- Styling: React Native StyleSheet or Tailwind (NativeWind)
File Structure
src/ components/ screens/ hooks/ services/ utils/ types/ constants/
Rules: - Components must live in components/ - Screens must live in
screens/ - Business logic should be inside services/ - Reusable
hooks should be inside hooks/ - Type definitions must live in types/
TypeScript Rules
Always follow strict TypeScript rules.
Required: - Avoid any - Prefer type or interface - Always type
props - Always type API responses
Example:
Component example:
Component Rules
Preferred component style:
- Functional components only
- Use hooks
- Avoid class components
Example:
Rules: - One component per file - Component name must match file name
Example:
components/Button.tsx
Styling Rules
Preferred order:
- StyleSheet
- NativeWind (if enabled)
Example:
Rules: - Do not inline large styles - Shared styles go in /styles
Hooks Rules
Custom hooks must start with use.
Example:
useAuth.ts
useUser.ts
useLocation.ts
Example implementation:
API Rules
All API calls must live in:
services/api/
Example:
services/api/userService.ts
Example:
Rules: - No API calls inside UI components - Always type API responses
Performance Rules
Always:
- Use React.memo for heavy components
- Use useCallback for handlers
- Use useMemo for computed values
- Avoid unnecessary re-renders
Expo Rules
Always prefer Expo APIs:
Examples:
expo-location
expo-camera
expo-secure-store
expo-image-picker
Rules: - Do not install native packages if Expo already provides them - Keep compatibility with Expo managed workflow
Error Handling
All async code must handle errors.
Example:
Naming Conventions
Components → PascalCase
Hooks → camelCase starting with use
Files → PascalCase for components
Example:
UserCard.tsx
useAuth.ts
userService.ts
Testing
Preferred tools:
- Jest
- React Native Testing Library
Test files:
ComponentName.test.tsx
Code Quality Rules
Never:
- Use
any - Put business logic in UI
- Duplicate code
- Ignore TypeScript errors
Always:
- Write readable code
- Use proper types
- Split large components
