Skip to content

Commit c3ae61e

Browse files
authored
Merge pull request #123 from rootstrap/chore/curosr_rules
chore: cursor rules
2 parents 7cb3332 + cd87e70 commit c3ae61e

File tree

4 files changed

+164
-0
lines changed

4 files changed

+164
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
description:
3+
globs:
4+
alwaysApply: true
5+
---
6+
# Global Base Rules
7+
8+
## Code Style
9+
- Use concise, technical TypeScript code.
10+
- Prefer functional and declarative programming; avoid classes.
11+
- Use descriptive variable names (e.g., isLoading, hasError).
12+
- Modularize code, avoid duplication.
13+
14+
## Naming
15+
- Use kebab-case for files and directories.
16+
- Favor named exports.
17+
18+
## Syntax
19+
- Use "function" keyword for pure functions.
20+
- Avoid unnecessary curly braces in conditionals.
21+
22+
## Git
23+
24+
Commit Message Prefixes:
25+
26+
- "fix:" for bug fixes
27+
- "feat:" for new features
28+
- "perf:" for performance improvements
29+
- "docs:" for documentation changes
30+
- "style:" for formatting changes
31+
- "refactor:" for code refactoring
32+
- "test:" for adding missing tests
33+
- "chore:" for maintenance tasks
34+
35+
Rules:
36+
37+
- Use lowercase for commit messages
38+
- Keep the summary line concise with a maximum of 100 characters
39+
- Reference issue numbers when applicable
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
description: Project-specific coding conventions and structure
3+
globs:
4+
alwaysApply: false
5+
---
6+
# Project Base Rules
7+
8+
## Structure
9+
- Organize files as:
10+
- src/api (axios, react query)
11+
- src/app (expo router, screens, navigation)
12+
- src/components (shared components, ui)
13+
- src/lib (auth, env, hooks, i18n, utils)
14+
- src/translations
15+
- src/types
16+
17+
## Imports
18+
- Use absolute imports (@/...)
19+
20+
## Error Handling
21+
- Log errors for debugging.
22+
- Provide user-friendly error messages.
23+
24+
## Documentation
25+
26+
- Maintain clear README with the following sections:
27+
- Setup ( how to install and run the project )
28+
- Usage ( listing all the commands and how to use them )
29+
- Stack ( the tech stack used in the project )
30+
- Folder Structure ( the folder structure of the project only the important ones inside src )
31+
32+
## Testing
33+
- Use Jest and React Native Testing Library.
34+
- Write unit tests for utilities and complex components.
35+
- Test files: component-name.test.tsx.
36+
- No tests for simple display-only components.
37+
38+
## Package Management
39+
- Use `npx expo install <package-name>` for new packages.
40+
41+
## Message Passing
42+
- Use strict TypeScript discriminated unions for message types.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
description: React Native, Expo, and Mobile UI specific technical and UI rules
3+
globs: *.tsx,*.ts,*.jsx,*.js
4+
alwaysApply: false
5+
---
6+
# React Native Base Rules
7+
8+
## Tech Stack
9+
- Use Expo, React Native, TypeScript, Nativewind, Expo Router, React Query, Zustand, MMKV, SVG.
10+
11+
## Components
12+
- Use functional components.
13+
- Keep components modular, reusable, and <120 lines.
14+
- Use declarative JSX.
15+
- Memoize components to avoid unnecessary re-renders.
16+
17+
## UI & Styling
18+
- Use Nativewind for styling.
19+
- Avoid one sided margins and paddings when possible. Instead, prefer adding container views when needed with gap, vertical padding or horizontal padding.
20+
- Use built-in ui components such as Button, Input from `@components/ui`
21+
- Avoid unnecessary re-renders by memoizing components and using useMemo and useCallback hooks appropriately.
22+
- Ensure accessibility (a11y) with ARIA/native props.
23+
- Use defined colors/fonts from tailwind config.
24+
25+
## State Management
26+
- Use Zustand for global state.
27+
- Clean up in useEffect hooks.
28+
29+
## Animations
30+
- Use react-native-reanimated and react-native-gesture-handler for animations/gestures.
31+
32+
## Testing
33+
- Use Jest and React Native Testing Library.
34+
- Write unit tests for utilities and complex components.
35+
- Test files: component-name.test.tsx.
36+
- No tests for simple display-only components.
37+
38+
## Code Examples
39+
40+
- Follow patterns similar to:
41+
42+
```tsx
43+
import { Text, View, Image, SavaAreaView } from '@/components/ui';
44+
45+
// Props should be defined in the top of the component
46+
type TitleProps = {
47+
text: string;
48+
};
49+
50+
const Title = ({ text }: TitleProps) => {
51+
return (
52+
<View className="flex-row items-center justify-center py-4">
53+
<Text className="px-2 text-2xl">{text}</Text>
54+
<View className="h-[2px] flex-1 bg-neutral-300" />
55+
56+
<Image
57+
source={require('@assets/images/demo.png')}
58+
style={{ width: 24, height: 24 }}
59+
contentFit="contain"
60+
/>
61+
</View>
62+
);
63+
}
64+
65+
export default Title
66+
```
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
description:
3+
globs:
4+
alwaysApply: true
5+
---
6+
# Typescript rules
7+
8+
## TypeScript
9+
- Prefer types over interfaces.
10+
- Avoid enums; use const objects with 'as const'.
11+
- Use explicit return types for all functions.
12+
- Avoid type assertions with 'as' or '!' operators unless absolutely necessary
13+
- Use mapped and conditional types for advanced type transformations
14+
- If a type is being reused within different files extract it for reuse
15+
- Use strict mode in TypeScript for better type safety
16+
- Avoid using `any`; strive for precise types.
17+

0 commit comments

Comments
 (0)