diff --git a/.cursor/rules/global/base-rules.mdc b/.cursor/rules/global/base-rules.mdc new file mode 100644 index 000000000..39ba0852f --- /dev/null +++ b/.cursor/rules/global/base-rules.mdc @@ -0,0 +1,39 @@ +--- +description: +globs: +alwaysApply: true +--- +# Global Base Rules + +## Code Style +- Use concise, technical TypeScript code. +- Prefer functional and declarative programming; avoid classes. +- Use descriptive variable names (e.g., isLoading, hasError). +- Modularize code, avoid duplication. + +## Naming +- Use kebab-case for files and directories. +- Favor named exports. + +## Syntax +- Use "function" keyword for pure functions. +- Avoid unnecessary curly braces in conditionals. + +## Git + +Commit Message Prefixes: + +- "fix:" for bug fixes +- "feat:" for new features +- "perf:" for performance improvements +- "docs:" for documentation changes +- "style:" for formatting changes +- "refactor:" for code refactoring +- "test:" for adding missing tests +- "chore:" for maintenance tasks + +Rules: + +- Use lowercase for commit messages +- Keep the summary line concise with a maximum of 100 characters +- Reference issue numbers when applicable diff --git a/.cursor/rules/project/base-rules.mdc b/.cursor/rules/project/base-rules.mdc new file mode 100644 index 000000000..b1fc2faa4 --- /dev/null +++ b/.cursor/rules/project/base-rules.mdc @@ -0,0 +1,42 @@ +--- +description: Project-specific coding conventions and structure +globs: +alwaysApply: false +--- +# Project Base Rules + +## Structure +- Organize files as: + - src/api (axios, react query) + - src/app (expo router, screens, navigation) + - src/components (shared components, ui) + - src/lib (auth, env, hooks, i18n, utils) + - src/translations + - src/types + +## Imports +- Use absolute imports (@/...) + +## Error Handling +- Log errors for debugging. +- Provide user-friendly error messages. + +## Documentation + +- Maintain clear README with the following sections: + - Setup ( how to install and run the project ) + - Usage ( listing all the commands and how to use them ) + - Stack ( the tech stack used in the project ) + - Folder Structure ( the folder structure of the project only the important ones inside src ) + +## Testing +- Use Jest and React Native Testing Library. +- Write unit tests for utilities and complex components. +- Test files: component-name.test.tsx. +- No tests for simple display-only components. + +## Package Management +- Use `npx expo install ` for new packages. + +## Message Passing +- Use strict TypeScript discriminated unions for message types. diff --git a/.cursor/rules/react-native/base-rules.mdc b/.cursor/rules/react-native/base-rules.mdc new file mode 100644 index 000000000..188745561 --- /dev/null +++ b/.cursor/rules/react-native/base-rules.mdc @@ -0,0 +1,66 @@ +--- +description: React Native, Expo, and Mobile UI specific technical and UI rules +globs: *.tsx,*.ts,*.jsx,*.js +alwaysApply: false +--- +# React Native Base Rules + +## Tech Stack +- Use Expo, React Native, TypeScript, Nativewind, Expo Router, React Query, Zustand, MMKV, SVG. + +## Components +- Use functional components. +- Keep components modular, reusable, and <120 lines. +- Use declarative JSX. +- Memoize components to avoid unnecessary re-renders. + +## UI & Styling +- Use Nativewind for styling. +- Avoid one sided margins and paddings when possible. Instead, prefer adding container views when needed with gap, vertical padding or horizontal padding. +- Use built-in ui components such as Button, Input from `@components/ui` +- Avoid unnecessary re-renders by memoizing components and using useMemo and useCallback hooks appropriately. +- Ensure accessibility (a11y) with ARIA/native props. +- Use defined colors/fonts from tailwind config. + +## State Management +- Use Zustand for global state. +- Clean up in useEffect hooks. + +## Animations +- Use react-native-reanimated and react-native-gesture-handler for animations/gestures. + +## Testing +- Use Jest and React Native Testing Library. +- Write unit tests for utilities and complex components. +- Test files: component-name.test.tsx. +- No tests for simple display-only components. + +## Code Examples + +- Follow patterns similar to: + +```tsx +import { Text, View, Image, SavaAreaView } from '@/components/ui'; + +// Props should be defined in the top of the component +type TitleProps = { + text: string; +}; + +const Title = ({ text }: TitleProps) => { + return ( + + {text} + + + + + ); +} + +export default Title +``` diff --git a/.cursor/rules/react-native/typescript.mdc b/.cursor/rules/react-native/typescript.mdc new file mode 100644 index 000000000..68c8af6ba --- /dev/null +++ b/.cursor/rules/react-native/typescript.mdc @@ -0,0 +1,17 @@ +--- +description: +globs: +alwaysApply: true +--- +# Typescript rules + +## TypeScript +- Prefer types over interfaces. +- Avoid enums; use const objects with 'as const'. +- Use explicit return types for all functions. +- Avoid type assertions with 'as' or '!' operators unless absolutely necessary +- Use mapped and conditional types for advanced type transformations +- If a type is being reused within different files extract it for reuse +- Use strict mode in TypeScript for better type safety +- Avoid using `any`; strive for precise types. +