|
| 1 | +You are an expert in TypeScript, React Native, Expo, and Mobile App Development. |
| 2 | + |
| 3 | +Code Style and Structure: |
| 4 | + |
| 5 | +- Write concise, type-safe TypeScript code. |
| 6 | +- Use functional components and hooks over class components. |
| 7 | +- Ensure components are modular, reusable, and maintainable. |
| 8 | +- Organize files by feature, grouping related components, hooks, and styles. |
| 9 | +- This is a mobile application, so ensure all components are mobile friendly and responsive and support both iOS and Android platforms and ensure that the app is optimized for both platforms. |
| 10 | + |
| 11 | +Naming Conventions: |
| 12 | + |
| 13 | +- Use camelCase for variable and function names (e.g., `isFetchingData`, `handleUserInput`). |
| 14 | +- Use PascalCase for component names (e.g., `UserProfile`, `ChatScreen`). |
| 15 | +- Directory and File names should be lowercase and hyphenated (e.g., `user-profile`, `chat-screen`). |
| 16 | + |
| 17 | +TypeScript Usage: |
| 18 | + |
| 19 | +- Use TypeScript for all components, favoring interfaces for props and state. |
| 20 | +- Enable strict typing in `tsconfig.json`. |
| 21 | +- Avoid using `any`; strive for precise types. |
| 22 | +- Utilize `React.FC` for defining functional components with props. |
| 23 | + |
| 24 | +Performance Optimization: |
| 25 | + |
| 26 | +- Minimize `useEffect`, `useState`, and heavy computations inside render methods. |
| 27 | +- Use `React.memo()` for components with static props to prevent unnecessary re-renders. |
| 28 | +- Optimize FlatLists with props like `removeClippedSubviews`, `maxToRenderPerBatch`, and `windowSize`. |
| 29 | +- Use `getItemLayout` for FlatLists when items have a consistent size to improve performance. |
| 30 | +- Avoid anonymous functions in `renderItem` or event handlers to prevent re-renders. |
| 31 | + |
| 32 | +UI and Styling: |
| 33 | + |
| 34 | +- Use consistent styling leveraging `gluestack-ui`. If there isn't a Gluestack component in the `components/ui` directory for the component you are trying to use consistently style it either through `StyleSheet.create()` or Styled Components. |
| 35 | +- Ensure responsive design by considering different screen sizes and orientations. |
| 36 | +- Optimize image handling using libraries designed for React Native, like `react-native-fast-image`. |
| 37 | + |
| 38 | +Best Practices: |
| 39 | + |
| 40 | +- Follow React Native's threading model to ensure smooth UI performance. |
| 41 | +- Use React Navigation for handling navigation and deep linking with best practices. |
| 42 | +- Create and use Jest to test to validate all generated components |
| 43 | +- Generate tests for all components, services and logic generated. Ensure tests run without errors and fix any issues. |
| 44 | +- The app is multi-lingual, so ensure all text is wrapped in `t()` from `react-i18next` for translations with the dictonary files stored in `src/translations`. |
| 45 | +- Ensure support for dark mode and light mode. |
| 46 | +- Ensure the app is accessible, following WCAG guidelines for mobile applications. |
| 47 | +- Make sure the app is optimized for performance, especially for low-end devices. |
| 48 | +- Handle errors gracefully and provide user feedback. |
| 49 | +- Implement proper offline support. |
| 50 | +- Ensure the user interface is intuitive and user-friendly and works seamlessly across different devices and screen sizes. |
| 51 | +- This is an expo managed project that uses prebuild, do not make native code changes outside of expo prebuild capabilities. |
| 52 | + |
| 53 | +Additional Rules: |
| 54 | + |
| 55 | +- Use `yarn` as the package manager. |
| 56 | +- Use Expo's secure store for sensitive data |
| 57 | +- Implement proper offline support |
| 58 | +- Use `zustand` for state management |
| 59 | +- Use `react-hook-form` for form handling |
| 60 | +- Use `react-query` for data fetching |
| 61 | +- Use `react-i18next` for internationalization |
| 62 | +- Use `react-native-mmkv` for local storage |
| 63 | +- Use `axios` for API requests |
| 64 | +- Use `@rnmapbox/maps` for maps, mapping or vehicle navigation |
| 65 | +- Use `lucide-react-native` for icons and use those components directly in the markup and don't use the gluestack-ui icon component |
| 66 | +- Use ? : for conditional rendering and not && |
0 commit comments