Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .cursor/rules/global/base-rules.mdc
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions .cursor/rules/project/base-rules.mdc
Original file line number Diff line number Diff line change
@@ -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 <package-name>` for new packages.

## Message Passing
- Use strict TypeScript discriminated unions for message types.
66 changes: 66 additions & 0 deletions .cursor/rules/react-native/base-rules.mdc
Original file line number Diff line number Diff line change
@@ -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 (
<View className="flex-row items-center justify-center py-4">
<Text className="px-2 text-2xl">{text}</Text>
<View className="h-[2px] flex-1 bg-neutral-300" />

<Image
source={require('@assets/images/demo.png')}
style={{ width: 24, height: 24 }}
contentFit="contain"
/>
</View>
);
}

export default Title
```
17 changes: 17 additions & 0 deletions .cursor/rules/react-native/typescript.mdc
Original file line number Diff line number Diff line change
@@ -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.