@croacroa/react-native-template 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +187 -184
- package/.github/workflows/eas-build.yml +55 -55
- package/.github/workflows/eas-update.yml +50 -50
- package/CHANGELOG.md +106 -106
- package/CONTRIBUTING.md +377 -377
- package/README.md +399 -399
- package/__tests__/components/snapshots.test.tsx +131 -0
- package/__tests__/integration/auth-api.test.tsx +227 -0
- package/__tests__/performance/VirtualizedList.perf.test.tsx +362 -0
- package/app/(public)/onboarding.tsx +5 -5
- package/app.config.ts +45 -2
- package/assets/images/.gitkeep +7 -7
- package/components/onboarding/OnboardingScreen.tsx +370 -370
- package/components/onboarding/index.ts +2 -2
- package/components/providers/SuspenseBoundary.tsx +357 -0
- package/components/providers/index.ts +13 -0
- package/components/ui/Avatar.tsx +316 -316
- package/components/ui/Badge.tsx +416 -416
- package/components/ui/BottomSheet.tsx +307 -307
- package/components/ui/Checkbox.tsx +261 -261
- package/components/ui/OptimizedImage.tsx +369 -369
- package/components/ui/Select.tsx +240 -240
- package/components/ui/VirtualizedList.tsx +285 -0
- package/components/ui/index.ts +23 -18
- package/constants/config.ts +97 -54
- package/docs/adr/001-state-management.md +79 -79
- package/docs/adr/002-styling-approach.md +130 -130
- package/docs/adr/003-data-fetching.md +155 -155
- package/docs/adr/004-auth-adapter-pattern.md +144 -144
- package/docs/adr/README.md +78 -78
- package/hooks/index.ts +27 -25
- package/hooks/useApi.ts +102 -5
- package/hooks/useAuth.tsx +82 -0
- package/hooks/useBiometrics.ts +295 -295
- package/hooks/useDeepLinking.ts +256 -256
- package/hooks/useMFA.ts +499 -0
- package/hooks/useNotifications.ts +39 -0
- package/hooks/useOffline.ts +32 -2
- package/hooks/usePerformance.ts +434 -434
- package/hooks/useTheme.tsx +76 -0
- package/hooks/useUpdates.ts +358 -358
- package/i18n/index.ts +194 -77
- package/i18n/locales/ar.json +101 -0
- package/i18n/locales/de.json +101 -0
- package/i18n/locales/en.json +101 -101
- package/i18n/locales/es.json +101 -0
- package/i18n/locales/fr.json +101 -101
- package/jest.config.js +4 -4
- package/maestro/README.md +113 -113
- package/maestro/config.yaml +35 -35
- package/maestro/flows/login.yaml +62 -62
- package/maestro/flows/mfa-login.yaml +92 -0
- package/maestro/flows/mfa-setup.yaml +86 -0
- package/maestro/flows/navigation.yaml +68 -68
- package/maestro/flows/offline-conflict.yaml +101 -0
- package/maestro/flows/offline-sync.yaml +128 -0
- package/maestro/flows/offline.yaml +60 -60
- package/maestro/flows/register.yaml +94 -94
- package/package.json +175 -170
- package/services/analytics.ts +428 -428
- package/services/api.ts +340 -340
- package/services/authAdapter.ts +333 -333
- package/services/backgroundSync.ts +626 -0
- package/services/index.ts +54 -22
- package/services/security.ts +229 -0
- package/tailwind.config.js +47 -47
- package/utils/accessibility.ts +446 -446
- package/utils/index.ts +52 -43
- package/utils/withAccessibility.tsx +272 -0
package/CONTRIBUTING.md
CHANGED
|
@@ -1,377 +1,377 @@
|
|
|
1
|
-
# Contributing to React Native Template
|
|
2
|
-
|
|
3
|
-
Thank you for your interest in contributing! This document provides guidelines and instructions for contributing to this project.
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
- [Code of Conduct](#code-of-conduct)
|
|
8
|
-
- [Getting Started](#getting-started)
|
|
9
|
-
- [Development Workflow](#development-workflow)
|
|
10
|
-
- [Code Style](#code-style)
|
|
11
|
-
- [Commit Messages](#commit-messages)
|
|
12
|
-
- [Pull Requests](#pull-requests)
|
|
13
|
-
- [Testing](#testing)
|
|
14
|
-
- [Documentation](#documentation)
|
|
15
|
-
|
|
16
|
-
## Code of Conduct
|
|
17
|
-
|
|
18
|
-
Please be respectful and constructive in all interactions. We're building something together.
|
|
19
|
-
|
|
20
|
-
## Getting Started
|
|
21
|
-
|
|
22
|
-
### Prerequisites
|
|
23
|
-
|
|
24
|
-
- Node.js 18+
|
|
25
|
-
- npm or yarn
|
|
26
|
-
- Expo CLI (`npm install -g expo-cli`)
|
|
27
|
-
- iOS Simulator (macOS) or Android Emulator
|
|
28
|
-
- Git
|
|
29
|
-
|
|
30
|
-
### Setup
|
|
31
|
-
|
|
32
|
-
1. **Fork the repository**
|
|
33
|
-
|
|
34
|
-
2. **Clone your fork**
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
git clone https://github.com/YOUR_USERNAME/template-react-native.git
|
|
38
|
-
cd template-react-native
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
3. **Install dependencies**
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
npm install
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
4. **Start the development server**
|
|
48
|
-
```bash
|
|
49
|
-
npm start
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Development Workflow
|
|
53
|
-
|
|
54
|
-
### Branch Naming
|
|
55
|
-
|
|
56
|
-
Use descriptive branch names:
|
|
57
|
-
|
|
58
|
-
- `feature/add-user-profile` - New features
|
|
59
|
-
- `fix/login-validation` - Bug fixes
|
|
60
|
-
- `docs/update-readme` - Documentation
|
|
61
|
-
- `refactor/auth-service` - Code refactoring
|
|
62
|
-
- `chore/update-deps` - Maintenance tasks
|
|
63
|
-
|
|
64
|
-
### Creating a Feature
|
|
65
|
-
|
|
66
|
-
1. Create a new branch from `main`:
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
git checkout main
|
|
70
|
-
git pull origin main
|
|
71
|
-
git checkout -b feature/your-feature-name
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
2. Make your changes
|
|
75
|
-
|
|
76
|
-
3. Run linting and tests:
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
npm run lint
|
|
80
|
-
npm run typecheck
|
|
81
|
-
npm test
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
4. Commit your changes (see [Commit Messages](#commit-messages))
|
|
85
|
-
|
|
86
|
-
5. Push to your fork:
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
git push origin feature/your-feature-name
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
6. Create a Pull Request
|
|
93
|
-
|
|
94
|
-
## Code Style
|
|
95
|
-
|
|
96
|
-
### TypeScript
|
|
97
|
-
|
|
98
|
-
- Use TypeScript for all new code
|
|
99
|
-
- Define proper types (avoid `any`)
|
|
100
|
-
- Use interfaces for object shapes
|
|
101
|
-
- Export types from dedicated files in `/types`
|
|
102
|
-
|
|
103
|
-
```typescript
|
|
104
|
-
// Good
|
|
105
|
-
interface UserProps {
|
|
106
|
-
id: string;
|
|
107
|
-
name: string;
|
|
108
|
-
email: string;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Avoid
|
|
112
|
-
const user: any = { ... };
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### React Components
|
|
116
|
-
|
|
117
|
-
- Use functional components with hooks
|
|
118
|
-
- Use NativeWind for styling
|
|
119
|
-
- Keep components small and focused
|
|
120
|
-
- Extract reusable logic into hooks
|
|
121
|
-
|
|
122
|
-
```tsx
|
|
123
|
-
// Good
|
|
124
|
-
export function UserCard({ user }: UserCardProps) {
|
|
125
|
-
return (
|
|
126
|
-
<View className="p-4 bg-white rounded-xl">
|
|
127
|
-
<Text className="text-lg font-semibold">{user.name}</Text>
|
|
128
|
-
</View>
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Avoid inline styles
|
|
133
|
-
<View style={{ padding: 16, backgroundColor: 'white' }}>
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### File Organization
|
|
137
|
-
|
|
138
|
-
```
|
|
139
|
-
components/
|
|
140
|
-
├── ui/ # Reusable UI components
|
|
141
|
-
│ ├── Button.tsx
|
|
142
|
-
│ └── index.ts # Barrel exports
|
|
143
|
-
├── forms/ # Form-specific components
|
|
144
|
-
└── [feature]/ # Feature-specific components
|
|
145
|
-
|
|
146
|
-
hooks/
|
|
147
|
-
├── useAuth.tsx # Context hooks
|
|
148
|
-
├── useApi.ts # Data fetching hooks
|
|
149
|
-
└── index.ts # Barrel exports
|
|
150
|
-
|
|
151
|
-
services/
|
|
152
|
-
├── api.ts # API client
|
|
153
|
-
└── index.ts # Barrel exports
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### Naming Conventions
|
|
157
|
-
|
|
158
|
-
- **Files**: `PascalCase.tsx` for components, `camelCase.ts` for utilities
|
|
159
|
-
- **Components**: `PascalCase`
|
|
160
|
-
- **Hooks**: `useCamelCase`
|
|
161
|
-
- **Constants**: `SCREAMING_SNAKE_CASE`
|
|
162
|
-
- **Functions/Variables**: `camelCase`
|
|
163
|
-
|
|
164
|
-
## Commit Messages
|
|
165
|
-
|
|
166
|
-
Follow [Conventional Commits](https://www.conventionalcommits.org/):
|
|
167
|
-
|
|
168
|
-
```
|
|
169
|
-
type(scope): description
|
|
170
|
-
|
|
171
|
-
[optional body]
|
|
172
|
-
|
|
173
|
-
[optional footer]
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
### Types
|
|
177
|
-
|
|
178
|
-
- `feat`: New feature
|
|
179
|
-
- `fix`: Bug fix
|
|
180
|
-
- `docs`: Documentation changes
|
|
181
|
-
- `style`: Code style changes (formatting, etc.)
|
|
182
|
-
- `refactor`: Code refactoring
|
|
183
|
-
- `test`: Adding or updating tests
|
|
184
|
-
- `chore`: Maintenance tasks
|
|
185
|
-
|
|
186
|
-
### Examples
|
|
187
|
-
|
|
188
|
-
```
|
|
189
|
-
feat(auth): add biometric authentication
|
|
190
|
-
|
|
191
|
-
- Add useBiometrics hook
|
|
192
|
-
- Integrate with expo-local-authentication
|
|
193
|
-
- Add settings toggle for biometric login
|
|
194
|
-
|
|
195
|
-
Closes #123
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
```
|
|
199
|
-
fix(api): handle rate limiting gracefully
|
|
200
|
-
|
|
201
|
-
Add Bottleneck for client-side rate limiting
|
|
202
|
-
to prevent 429 errors.
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
## Pull Requests
|
|
206
|
-
|
|
207
|
-
### Before Submitting
|
|
208
|
-
|
|
209
|
-
1. **Update your branch** with the latest `main`:
|
|
210
|
-
|
|
211
|
-
```bash
|
|
212
|
-
git checkout main
|
|
213
|
-
git pull origin main
|
|
214
|
-
git checkout your-branch
|
|
215
|
-
git rebase main
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
2. **Run all checks**:
|
|
219
|
-
|
|
220
|
-
```bash
|
|
221
|
-
npm run lint:fix
|
|
222
|
-
npm run typecheck
|
|
223
|
-
npm test
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
3. **Test on both platforms** (iOS and Android)
|
|
227
|
-
|
|
228
|
-
### PR Template
|
|
229
|
-
|
|
230
|
-
```markdown
|
|
231
|
-
## Description
|
|
232
|
-
|
|
233
|
-
[Describe what this PR does]
|
|
234
|
-
|
|
235
|
-
## Type of Change
|
|
236
|
-
|
|
237
|
-
- [ ] Bug fix
|
|
238
|
-
- [ ] New feature
|
|
239
|
-
- [ ] Breaking change
|
|
240
|
-
- [ ] Documentation update
|
|
241
|
-
|
|
242
|
-
## Testing
|
|
243
|
-
|
|
244
|
-
- [ ] Unit tests pass
|
|
245
|
-
- [ ] Tested on iOS
|
|
246
|
-
- [ ] Tested on Android
|
|
247
|
-
|
|
248
|
-
## Screenshots (if applicable)
|
|
249
|
-
|
|
250
|
-
[Add screenshots for UI changes]
|
|
251
|
-
|
|
252
|
-
## Checklist
|
|
253
|
-
|
|
254
|
-
- [ ] Code follows project style guidelines
|
|
255
|
-
- [ ] Self-reviewed the code
|
|
256
|
-
- [ ] Added/updated documentation
|
|
257
|
-
- [ ] No new warnings
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
### Review Process
|
|
261
|
-
|
|
262
|
-
1. PRs require at least one approval
|
|
263
|
-
2. All CI checks must pass
|
|
264
|
-
3. Address reviewer feedback
|
|
265
|
-
4. Squash commits when merging
|
|
266
|
-
|
|
267
|
-
## Testing
|
|
268
|
-
|
|
269
|
-
### Unit Tests
|
|
270
|
-
|
|
271
|
-
```bash
|
|
272
|
-
# Run all tests
|
|
273
|
-
npm test
|
|
274
|
-
|
|
275
|
-
# Run with coverage
|
|
276
|
-
npm run test:coverage
|
|
277
|
-
|
|
278
|
-
# Run in watch mode
|
|
279
|
-
npm run test:watch
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### Writing Tests
|
|
283
|
-
|
|
284
|
-
```typescript
|
|
285
|
-
import { render, fireEvent } from '@testing-library/react-native';
|
|
286
|
-
import { Button } from '@/components/ui/Button';
|
|
287
|
-
|
|
288
|
-
describe('Button', () => {
|
|
289
|
-
it('renders correctly', () => {
|
|
290
|
-
const { getByText } = render(<Button>Click me</Button>);
|
|
291
|
-
expect(getByText('Click me')).toBeTruthy();
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
it('calls onPress when pressed', () => {
|
|
295
|
-
const onPress = jest.fn();
|
|
296
|
-
const { getByText } = render(
|
|
297
|
-
<Button onPress={onPress}>Click me</Button>
|
|
298
|
-
);
|
|
299
|
-
fireEvent.press(getByText('Click me'));
|
|
300
|
-
expect(onPress).toHaveBeenCalled();
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
### E2E Tests (Maestro)
|
|
306
|
-
|
|
307
|
-
```bash
|
|
308
|
-
# Run all E2E tests
|
|
309
|
-
maestro test maestro/flows/
|
|
310
|
-
|
|
311
|
-
# Run specific test
|
|
312
|
-
maestro test maestro/flows/login.yaml
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
## Documentation
|
|
316
|
-
|
|
317
|
-
### Code Comments
|
|
318
|
-
|
|
319
|
-
- Add JSDoc comments for public APIs
|
|
320
|
-
- Explain "why", not "what"
|
|
321
|
-
- Keep comments up to date
|
|
322
|
-
|
|
323
|
-
````typescript
|
|
324
|
-
/**
|
|
325
|
-
* Authenticate using biometrics
|
|
326
|
-
*
|
|
327
|
-
* @param options - Authentication options
|
|
328
|
-
* @returns true if authentication succeeded
|
|
329
|
-
*
|
|
330
|
-
* @example
|
|
331
|
-
* ```ts
|
|
332
|
-
* const success = await authenticate({
|
|
333
|
-
* promptMessage: 'Verify your identity',
|
|
334
|
-
* });
|
|
335
|
-
* ```
|
|
336
|
-
*/
|
|
337
|
-
async function authenticate(options?: AuthOptions): Promise<boolean> {
|
|
338
|
-
// ...
|
|
339
|
-
}
|
|
340
|
-
````
|
|
341
|
-
|
|
342
|
-
### README Updates
|
|
343
|
-
|
|
344
|
-
Update the README when:
|
|
345
|
-
|
|
346
|
-
- Adding new features
|
|
347
|
-
- Changing installation steps
|
|
348
|
-
- Modifying environment variables
|
|
349
|
-
- Adding new scripts
|
|
350
|
-
|
|
351
|
-
### Architecture Decision Records (ADRs)
|
|
352
|
-
|
|
353
|
-
For significant architectural decisions, create an ADR in `/docs/adr/`:
|
|
354
|
-
|
|
355
|
-
```markdown
|
|
356
|
-
# ADR-001: Use Zustand for State Management
|
|
357
|
-
|
|
358
|
-
## Status
|
|
359
|
-
|
|
360
|
-
Accepted
|
|
361
|
-
|
|
362
|
-
## Context
|
|
363
|
-
|
|
364
|
-
[Why was this decision needed?]
|
|
365
|
-
|
|
366
|
-
## Decision
|
|
367
|
-
|
|
368
|
-
[What was decided?]
|
|
369
|
-
|
|
370
|
-
## Consequences
|
|
371
|
-
|
|
372
|
-
[What are the implications?]
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
## Questions?
|
|
376
|
-
|
|
377
|
-
Feel free to open an issue for questions or discussions.
|
|
1
|
+
# Contributing to React Native Template
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing! This document provides guidelines and instructions for contributing to this project.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Code of Conduct](#code-of-conduct)
|
|
8
|
+
- [Getting Started](#getting-started)
|
|
9
|
+
- [Development Workflow](#development-workflow)
|
|
10
|
+
- [Code Style](#code-style)
|
|
11
|
+
- [Commit Messages](#commit-messages)
|
|
12
|
+
- [Pull Requests](#pull-requests)
|
|
13
|
+
- [Testing](#testing)
|
|
14
|
+
- [Documentation](#documentation)
|
|
15
|
+
|
|
16
|
+
## Code of Conduct
|
|
17
|
+
|
|
18
|
+
Please be respectful and constructive in all interactions. We're building something together.
|
|
19
|
+
|
|
20
|
+
## Getting Started
|
|
21
|
+
|
|
22
|
+
### Prerequisites
|
|
23
|
+
|
|
24
|
+
- Node.js 18+
|
|
25
|
+
- npm or yarn
|
|
26
|
+
- Expo CLI (`npm install -g expo-cli`)
|
|
27
|
+
- iOS Simulator (macOS) or Android Emulator
|
|
28
|
+
- Git
|
|
29
|
+
|
|
30
|
+
### Setup
|
|
31
|
+
|
|
32
|
+
1. **Fork the repository**
|
|
33
|
+
|
|
34
|
+
2. **Clone your fork**
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
git clone https://github.com/YOUR_USERNAME/template-react-native.git
|
|
38
|
+
cd template-react-native
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
3. **Install dependencies**
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm install
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
4. **Start the development server**
|
|
48
|
+
```bash
|
|
49
|
+
npm start
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Development Workflow
|
|
53
|
+
|
|
54
|
+
### Branch Naming
|
|
55
|
+
|
|
56
|
+
Use descriptive branch names:
|
|
57
|
+
|
|
58
|
+
- `feature/add-user-profile` - New features
|
|
59
|
+
- `fix/login-validation` - Bug fixes
|
|
60
|
+
- `docs/update-readme` - Documentation
|
|
61
|
+
- `refactor/auth-service` - Code refactoring
|
|
62
|
+
- `chore/update-deps` - Maintenance tasks
|
|
63
|
+
|
|
64
|
+
### Creating a Feature
|
|
65
|
+
|
|
66
|
+
1. Create a new branch from `main`:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
git checkout main
|
|
70
|
+
git pull origin main
|
|
71
|
+
git checkout -b feature/your-feature-name
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
2. Make your changes
|
|
75
|
+
|
|
76
|
+
3. Run linting and tests:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npm run lint
|
|
80
|
+
npm run typecheck
|
|
81
|
+
npm test
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
4. Commit your changes (see [Commit Messages](#commit-messages))
|
|
85
|
+
|
|
86
|
+
5. Push to your fork:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
git push origin feature/your-feature-name
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
6. Create a Pull Request
|
|
93
|
+
|
|
94
|
+
## Code Style
|
|
95
|
+
|
|
96
|
+
### TypeScript
|
|
97
|
+
|
|
98
|
+
- Use TypeScript for all new code
|
|
99
|
+
- Define proper types (avoid `any`)
|
|
100
|
+
- Use interfaces for object shapes
|
|
101
|
+
- Export types from dedicated files in `/types`
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
// Good
|
|
105
|
+
interface UserProps {
|
|
106
|
+
id: string;
|
|
107
|
+
name: string;
|
|
108
|
+
email: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Avoid
|
|
112
|
+
const user: any = { ... };
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### React Components
|
|
116
|
+
|
|
117
|
+
- Use functional components with hooks
|
|
118
|
+
- Use NativeWind for styling
|
|
119
|
+
- Keep components small and focused
|
|
120
|
+
- Extract reusable logic into hooks
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
// Good
|
|
124
|
+
export function UserCard({ user }: UserCardProps) {
|
|
125
|
+
return (
|
|
126
|
+
<View className="p-4 bg-white rounded-xl">
|
|
127
|
+
<Text className="text-lg font-semibold">{user.name}</Text>
|
|
128
|
+
</View>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Avoid inline styles
|
|
133
|
+
<View style={{ padding: 16, backgroundColor: 'white' }}>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### File Organization
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
components/
|
|
140
|
+
├── ui/ # Reusable UI components
|
|
141
|
+
│ ├── Button.tsx
|
|
142
|
+
│ └── index.ts # Barrel exports
|
|
143
|
+
├── forms/ # Form-specific components
|
|
144
|
+
└── [feature]/ # Feature-specific components
|
|
145
|
+
|
|
146
|
+
hooks/
|
|
147
|
+
├── useAuth.tsx # Context hooks
|
|
148
|
+
├── useApi.ts # Data fetching hooks
|
|
149
|
+
└── index.ts # Barrel exports
|
|
150
|
+
|
|
151
|
+
services/
|
|
152
|
+
├── api.ts # API client
|
|
153
|
+
└── index.ts # Barrel exports
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Naming Conventions
|
|
157
|
+
|
|
158
|
+
- **Files**: `PascalCase.tsx` for components, `camelCase.ts` for utilities
|
|
159
|
+
- **Components**: `PascalCase`
|
|
160
|
+
- **Hooks**: `useCamelCase`
|
|
161
|
+
- **Constants**: `SCREAMING_SNAKE_CASE`
|
|
162
|
+
- **Functions/Variables**: `camelCase`
|
|
163
|
+
|
|
164
|
+
## Commit Messages
|
|
165
|
+
|
|
166
|
+
Follow [Conventional Commits](https://www.conventionalcommits.org/):
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
type(scope): description
|
|
170
|
+
|
|
171
|
+
[optional body]
|
|
172
|
+
|
|
173
|
+
[optional footer]
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Types
|
|
177
|
+
|
|
178
|
+
- `feat`: New feature
|
|
179
|
+
- `fix`: Bug fix
|
|
180
|
+
- `docs`: Documentation changes
|
|
181
|
+
- `style`: Code style changes (formatting, etc.)
|
|
182
|
+
- `refactor`: Code refactoring
|
|
183
|
+
- `test`: Adding or updating tests
|
|
184
|
+
- `chore`: Maintenance tasks
|
|
185
|
+
|
|
186
|
+
### Examples
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
feat(auth): add biometric authentication
|
|
190
|
+
|
|
191
|
+
- Add useBiometrics hook
|
|
192
|
+
- Integrate with expo-local-authentication
|
|
193
|
+
- Add settings toggle for biometric login
|
|
194
|
+
|
|
195
|
+
Closes #123
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
fix(api): handle rate limiting gracefully
|
|
200
|
+
|
|
201
|
+
Add Bottleneck for client-side rate limiting
|
|
202
|
+
to prevent 429 errors.
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Pull Requests
|
|
206
|
+
|
|
207
|
+
### Before Submitting
|
|
208
|
+
|
|
209
|
+
1. **Update your branch** with the latest `main`:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
git checkout main
|
|
213
|
+
git pull origin main
|
|
214
|
+
git checkout your-branch
|
|
215
|
+
git rebase main
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
2. **Run all checks**:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
npm run lint:fix
|
|
222
|
+
npm run typecheck
|
|
223
|
+
npm test
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
3. **Test on both platforms** (iOS and Android)
|
|
227
|
+
|
|
228
|
+
### PR Template
|
|
229
|
+
|
|
230
|
+
```markdown
|
|
231
|
+
## Description
|
|
232
|
+
|
|
233
|
+
[Describe what this PR does]
|
|
234
|
+
|
|
235
|
+
## Type of Change
|
|
236
|
+
|
|
237
|
+
- [ ] Bug fix
|
|
238
|
+
- [ ] New feature
|
|
239
|
+
- [ ] Breaking change
|
|
240
|
+
- [ ] Documentation update
|
|
241
|
+
|
|
242
|
+
## Testing
|
|
243
|
+
|
|
244
|
+
- [ ] Unit tests pass
|
|
245
|
+
- [ ] Tested on iOS
|
|
246
|
+
- [ ] Tested on Android
|
|
247
|
+
|
|
248
|
+
## Screenshots (if applicable)
|
|
249
|
+
|
|
250
|
+
[Add screenshots for UI changes]
|
|
251
|
+
|
|
252
|
+
## Checklist
|
|
253
|
+
|
|
254
|
+
- [ ] Code follows project style guidelines
|
|
255
|
+
- [ ] Self-reviewed the code
|
|
256
|
+
- [ ] Added/updated documentation
|
|
257
|
+
- [ ] No new warnings
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Review Process
|
|
261
|
+
|
|
262
|
+
1. PRs require at least one approval
|
|
263
|
+
2. All CI checks must pass
|
|
264
|
+
3. Address reviewer feedback
|
|
265
|
+
4. Squash commits when merging
|
|
266
|
+
|
|
267
|
+
## Testing
|
|
268
|
+
|
|
269
|
+
### Unit Tests
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# Run all tests
|
|
273
|
+
npm test
|
|
274
|
+
|
|
275
|
+
# Run with coverage
|
|
276
|
+
npm run test:coverage
|
|
277
|
+
|
|
278
|
+
# Run in watch mode
|
|
279
|
+
npm run test:watch
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Writing Tests
|
|
283
|
+
|
|
284
|
+
```typescript
|
|
285
|
+
import { render, fireEvent } from '@testing-library/react-native';
|
|
286
|
+
import { Button } from '@/components/ui/Button';
|
|
287
|
+
|
|
288
|
+
describe('Button', () => {
|
|
289
|
+
it('renders correctly', () => {
|
|
290
|
+
const { getByText } = render(<Button>Click me</Button>);
|
|
291
|
+
expect(getByText('Click me')).toBeTruthy();
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
it('calls onPress when pressed', () => {
|
|
295
|
+
const onPress = jest.fn();
|
|
296
|
+
const { getByText } = render(
|
|
297
|
+
<Button onPress={onPress}>Click me</Button>
|
|
298
|
+
);
|
|
299
|
+
fireEvent.press(getByText('Click me'));
|
|
300
|
+
expect(onPress).toHaveBeenCalled();
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### E2E Tests (Maestro)
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
# Run all E2E tests
|
|
309
|
+
maestro test maestro/flows/
|
|
310
|
+
|
|
311
|
+
# Run specific test
|
|
312
|
+
maestro test maestro/flows/login.yaml
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
## Documentation
|
|
316
|
+
|
|
317
|
+
### Code Comments
|
|
318
|
+
|
|
319
|
+
- Add JSDoc comments for public APIs
|
|
320
|
+
- Explain "why", not "what"
|
|
321
|
+
- Keep comments up to date
|
|
322
|
+
|
|
323
|
+
````typescript
|
|
324
|
+
/**
|
|
325
|
+
* Authenticate using biometrics
|
|
326
|
+
*
|
|
327
|
+
* @param options - Authentication options
|
|
328
|
+
* @returns true if authentication succeeded
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```ts
|
|
332
|
+
* const success = await authenticate({
|
|
333
|
+
* promptMessage: 'Verify your identity',
|
|
334
|
+
* });
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
async function authenticate(options?: AuthOptions): Promise<boolean> {
|
|
338
|
+
// ...
|
|
339
|
+
}
|
|
340
|
+
````
|
|
341
|
+
|
|
342
|
+
### README Updates
|
|
343
|
+
|
|
344
|
+
Update the README when:
|
|
345
|
+
|
|
346
|
+
- Adding new features
|
|
347
|
+
- Changing installation steps
|
|
348
|
+
- Modifying environment variables
|
|
349
|
+
- Adding new scripts
|
|
350
|
+
|
|
351
|
+
### Architecture Decision Records (ADRs)
|
|
352
|
+
|
|
353
|
+
For significant architectural decisions, create an ADR in `/docs/adr/`:
|
|
354
|
+
|
|
355
|
+
```markdown
|
|
356
|
+
# ADR-001: Use Zustand for State Management
|
|
357
|
+
|
|
358
|
+
## Status
|
|
359
|
+
|
|
360
|
+
Accepted
|
|
361
|
+
|
|
362
|
+
## Context
|
|
363
|
+
|
|
364
|
+
[Why was this decision needed?]
|
|
365
|
+
|
|
366
|
+
## Decision
|
|
367
|
+
|
|
368
|
+
[What was decided?]
|
|
369
|
+
|
|
370
|
+
## Consequences
|
|
371
|
+
|
|
372
|
+
[What are the implications?]
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
## Questions?
|
|
376
|
+
|
|
377
|
+
Feel free to open an issue for questions or discussions.
|