Skip to content

Commit 88bc4f7

Browse files
Merge pull request #1069 from 1Psalm/main
[Enhancement] Add an offline-capable error state for the SESSION_EXPIRED request rejection
2 parents 916126b + 1c67fc9 commit 88bc4f7

1 file changed

Lines changed: 128 additions & 0 deletions

File tree

CONTRIBUTING.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,131 @@ Husky hooks enforce a baseline before changes reach CI:
123123

124124
You can bypass the hooks for a one-off push with `git push --no-verify`, but note
125125
that the same checks still run in CI and will block the pull request.
126+
127+
128+
129+
# Contributing to TeachLink Mobile
130+
131+
Thank you for contributing to TeachLink Mobile!
132+
133+
## Pull Request Guidelines
134+
135+
When submitting a Pull Request, you must fill out the provided PR template.
136+
The template ensures that all necessary considerations are accounted for before merge.
137+
138+
Please review the `.github/pull_request_template.md` which includes:
139+
- **Summary & Type of Change**: Describe what the PR does.
140+
- **Testing Done**: List the tests performed.
141+
- **Security Considerations**: Address concerns like secure data storage, token handling, input validation, and deep link handling.
142+
- **Performance Considerations**: Address concerns like hook optimization (`useCallback`, `useMemo`), `FlatList` optimization, and asynchronous patterns.
143+
- **Checklist**: General checks, including checking whether an Architectural Decision Record (ADR) is needed.
144+
145+
## Fast-Fail Syntax Gate
146+
147+
We have a dedicated **Syntax Gate** workflow (`.github/workflows/syntax.yml`) that runs on every pull request `opened` or `synchronize` event.
148+
149+
- Checks TypeScript compiler errors (`tsc --noEmit`) and ESLint (`eslint --max-warnings=0`)
150+
- Optimized to complete in **under 90 seconds** using caching
151+
- Required for branch protection — PRs cannot be merged if it fails
152+
- Run checks locally before pushing to avoid CI failures
153+
154+
## Architecture
155+
156+
The intended module structure, layering and dependency direction are documented
157+
in [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md). The layering is enforced locally
158+
and in CI with dependency-cruiser:
159+
160+
```bash
161+
npm run architecture:check
162+
```
163+
164+
Read the architecture doc before adding a new module — the codebase already has
165+
a single canonical implementation for error handling, logging, location, course
166+
progress, sync conflict resolution, and feature flags, and duplicating one of
167+
these is a review blocker.
168+
169+
## Structured Logging
170+
171+
**Never use `console.*` in `src/`.** The ESLint `no-console` rule is set to `error`, and CI will fail if any `console.*` call is introduced. Use `src/utils/logger` instead.
172+
173+
### Why structured logging?
174+
175+
`console.log` output is unstructured, always-on, and leaks information in production builds. `logger` gives you:
176+
- Log level filtering (only `error` and `warn` in production)
177+
- Consistent metadata (timestamp, component context)
178+
- A single place to redirect logs to remote monitoring (e.g. Sentry, Datadog)
179+
180+
### Log level guide
181+
182+
| Level | Method | When to use |
183+
|---|---|---|
184+
| **error** | `logger.error(msg, err?)` | Unexpected failures that need immediate attention. Always include the `Error` object as the second argument. |
185+
| **warn** | `logger.warn(msg, ctx?)` | Recoverable issues or deprecated code paths that should be investigated. |
186+
| **info** | `logger.info(msg, ctx?)` | Key lifecycle events: component mount/unmount, navigation, background sync. Keep them meaningful, not noisy. |
187+
| **debug** | `logger.debug(msg, ctx?)` | Verbose detail useful during development only. Stripped from production builds. |
188+
| **component** | `logger.component(name, event, ctx?)` | Convenience wrapper for component lifecycle events — equivalent to `info` with a standardised format. |
189+
190+
### Examples
191+
192+
```ts
193+
// ✅ Correct
194+
import { logger } from '../../utils/logger';
195+
196+
logger.component('MyScreen', 'Mounted', { userId });
197+
logger.info('Resuming lesson from position:', position);
198+
logger.warn('Quiz data missing for section:', sectionId);
199+
logger.error('Failed to sync progress:', error);
200+
201+
// ❌ Incorrect — will fail CI
202+
console.log('user mounted', userId);
203+
console.error('sync failed', error);
204+
```
205+
206+
### Audit
207+
208+
CI runs a console violation scan on every push. To run it locally:
209+
210+
```bash
211+
grep -rn "console\." src/ --include='*.ts' --include='*.tsx'
212+
```
213+
214+
Zero matches is the expected output.
215+
216+
## Local Quality Checks
217+
218+
You can run the checks locally:
219+
220+
```bash
221+
# Run ESLint linting
222+
npm run lint
223+
224+
# Check formatting
225+
npm run format:check
226+
227+
# Run TypeScript type check (same check CI runs)
228+
npm run typecheck
229+
230+
# Continuously re-run the type check as you edit
231+
npm run typecheck:watch
232+
```
233+
234+
### Lint warning budget
235+
236+
Lint warnings are capped by a single ratcheting budget in `lint-budget.json`
237+
(`maxWarnings`), enforced by `ci.yml`. There is exactly one lint gate in CI.
238+
239+
- `npm run lint:budget` — fails if the current warning count exceeds the budget,
240+
or if the budget is looser than the measured count (so the ceiling can only
241+
decrease over time).
242+
- `npm run lint:budget:record` — measures the warning count and records it as the
243+
new, lower budget. Run and commit this after removing warnings so the budget
244+
ratchets down instead of silently growing.
245+
### Git hooks
246+
247+
Husky hooks enforce a baseline before changes reach CI:
248+
249+
- **`pre-commit`** — runs `lint-staged` (Prettier + ESLint) on staged files.
250+
- **`pre-push`** — runs `npm run typecheck` so type errors are caught before push.
251+
252+
You can bypass the hooks for a one-off push with `git push --no-verify`, but note
253+
that the same checks still run in CI and will block the pull request.

0 commit comments

Comments
 (0)