1/23/2025
Comprehensive guide and rules for TypeScript-based mobile development using Expo, Jest, and Detox. Includes best practices for code style, UI/UX, performance, testing, and more.
# TypeScript (Expo, Jest, Detox)
# TypeScript Mobile Development with Expo, Jest, and Detox
## Code Style and Structure
- **Naming Conventions**: Use camelCase for variables and functions, PascalCase for components and types.
- **TypeScript Usage**: Leverage TypeScript's type system for better code safety and maintainability.
- **Syntax and Formatting**: Follow consistent formatting rules using Prettier and ESLint.
## UI and Styling
- **Safe Area Management**: Ensure UI components respect device safe areas using `react-native-safe-area-context`.
- **Performance Optimization**: Optimize UI rendering with `React.memo` and `useMemo`.
## Navigation
- Use `@react-navigation` for seamless navigation between screens.
- Implement deep linking for better user experience.
## State Management
- Use `React Context` or `Redux` for global state management.
- Prefer `useReducer` for complex state logic.
## Error Handling and Validation
- Implement error boundaries to catch runtime errors.
- Use `try/catch` blocks for asynchronous operations.
## Testing
- **Unit Testing**: Write unit tests using Jest.
- **End-to-End Testing**: Use Detox for end-to-end testing of your mobile application.
- **Snapshot Testing**: Utilize Jest's snapshot testing for UI components.
## Security
- Implement secure storage using `expo-secure-store`.
- Validate and sanitize all user inputs.
## Internationalization (i18n)
- Use `i18next` for managing multiple languages.
- Store translations in JSON files for easy maintenance.
## Key Conventions
- Follow Expo's best practices for Views, Blueprints, and Extensions.
- Refer to Expo's official documentation for detailed guidelines.
## API Documentation
- Document all API endpoints using Swagger or OpenAPI.
- Ensure API responses are typed and validated.
For more detailed information, refer to [Expo's documentation](https://docs.expo.dev/).