Conventions
This section is the single source of truth for all coding conventions in RNCopilot. Every contributor, AI agent, and tool must follow these rules exactly. When in doubt, look at an existing file in the codebase and match its patterns.
These conventions are also available in the repository as CONVENTIONS.md. The docs here mirror that file and provide additional examples.
Why Conventions Matter
RNCopilot is designed to be maintained by both humans and AI agents. Consistent conventions mean:
- AI agents produce correct code on the first try — they follow the same patterns every time.
- Code reviews are faster — reviewers check logic, not formatting.
- Onboarding is instant — new contributors read one page and know how to write code that fits.
Convention Areas
| Page | What It Covers |
|---|---|
| Naming Conventions | File names, component names, hooks, stores, constants, and type imports |
| File Organization | Path aliases, import order, barrel files, and directory structure |
| Styling Rules | The three laws of styling, variants API, responsive helpers, and theme tokens |
| State Management Rules | React Query for server state, Zustand for client state, selectors, and auth |
| i18n Rules | Translation requirements, locale files, dot notation keys, and RTL |
| Testing | Test location, patterns, tooling, and coverage targets |
| Git Workflow | Commit format, branch naming, and pre-commit checks |
The Non-Negotiables
These rules apply everywhere in the codebase without exception:
- No
anytypes. Useunknownand narrow, or define a proper type. - No inline styles. All styles go in
StyleSheet.create. - No color literals. All colors come from
theme.colors.*. - No hardcoded UI text. Every user-facing string goes through
useTranslation(). - No default exports in
src/. Named exports only. (Exception: screen files inapp/must use default exports for expo-router.) - Always use path aliases. Never use relative paths that climb more than one level.
- Always use selectors with Zustand. Never subscribe to the whole store.
Last updated on