--- name: app-coding-standards description: Provides coding standards for the Expensify App's React Native code, including performance patterns, consistency rules, and clean React architecture. Use when writing, modifying, or reviewing App code. --- # Expensify App Coding Standards Coding standards for the Expensify App. Each standard is a standalone file in `rules/` with reasoning, examples, and applicability conditions. ## How to Use This index lists rule titles only. Before writing or editing code, read the full rule file for every category that applies to the files you touch: each file holds the rule's conditions, exceptions, and the fix it expects. Before committing, stage everything with `git add -A`. Then start a general-purpose subagent that follows `.claude/agents/code-inline-reviewer.md` and reviews `git diff --cached $(git merge-base origin/main HEAD)`. CI runs the same check. ## Categories | Category | Prefix | Focus | |----------|--------|-------| | Performance | `PERF-*` | Render optimization, memo patterns, useEffect hygiene, data selection | | Consistency | `CONSISTENCY-*` | Platform checks, magic values, unused props, lint discipline, localization, file naming, JSDoc | | Clean React Patterns | `CLEAN-REACT-PATTERNS-*` | Composition, component ownership, state structure, prop typing, function components | | UI | `UI-*` | Loading indicators, scrollable pages, styling conventions | | Privacy | `PRIVACY-*` | FullStory masking of sensitive data | ## Quick Reference ### Performance - [PERF-1](rules/perf-1-no-spread-in-renderitem.md) — No spread in renderItem - [PERF-2](rules/perf-2-early-return.md) — Return early before expensive work - [PERF-3](rules/perf-3-onyx-list-item-provider.md) — Shared data in list rows comes from OnyxListItemProvider - [PERF-5](rules/perf-5-shallow-comparison.md) — Shallow over deep comparisons - [PERF-6](rules/perf-6-derive-state-from-props.md) — Derive state from props - [PERF-7](rules/perf-7-reset-via-key-prop.md) — Reset via key prop - [PERF-8](rules/perf-8-events-in-handlers.md) — Handle events in handlers - [PERF-9](rules/perf-9-no-useeffect-chains.md) — No useEffect chains - [PERF-10](rules/perf-10-no-useeffect-parent-comm.md) — No useEffect parent communication - [PERF-11](rules/perf-11-optimize-data-selection.md) — Optimize data selection - [PERF-12](rules/perf-12-prevent-memory-leaks.md) — Prevent memory leaks - [PERF-13](rules/perf-13-hoist-iterator-calls.md) — Hoist iterator-independent calls - [PERF-14](rules/perf-14-use-sync-external-store.md) — Use useSyncExternalStore - [PERF-15](rules/perf-15-cleanup-async-effects.md) — Clean up async Effects - [PERF-16](rules/perf-16-guard-double-init.md) — Guard double initialization - [PERF-17](rules/perf-17-pass-raw-index-on-demand.md) — Pass raw source, index on demand (no pre-built digest) - [PERF-18](rules/perf-18-use-pre-mount-destination.md) — Use usePreMountDestination for RHP pre-mounting - [PERF-19](rules/perf-19-scalar-collection-selectors.md) — Collection selectors return only what the consumer uses - [PERF-20](rules/perf-20-no-ad-hoc-deferral.md) — Defer heavy work to happen after visual transitions - [PERF-21](rules/perf-21-rows-read-own-data.md) — List rows read their own Onyx data - [PERF-22](rules/perf-22-row-single-member-subscriptions.md) — List rows subscribe to single collection members ### Consistency - [CONSISTENCY-1](rules/consistency-1-no-platform-checks.md) — No platform-specific checks in components - [CONSISTENCY-2](rules/consistency-2-no-magic-values.md) — No magic numbers/strings - [CONSISTENCY-3](rules/consistency-3-no-code-duplication.md) — No code duplication - [CONSISTENCY-4](rules/consistency-4-no-unused-props.md) — No unused props - [CONSISTENCY-5](rules/consistency-5-justify-eslint-disable.md) — Justify ESLint disables - [CONSISTENCY-6](rules/consistency-6-proper-error-handling.md) — Proper error handling - [CONSISTENCY-7](rules/consistency-7-localize-copy.md) — Localize all user-visible copy - [CONSISTENCY-8](rules/consistency-8-localize-numbers-dates.md) — Localize numbers, amounts, dates and phone numbers - [CONSISTENCY-9](rules/consistency-9-file-naming.md) — Name files after what they export - [CONSISTENCY-10](rules/consistency-10-jsdoc.md) — Follow the JSDoc style guidelines and document props only where there is something to say - [CONSISTENCY-11](rules/consistency-11-no-todo-comments.md) — Track future work in an issue, not a TODO comment - [CONSISTENCY-12](rules/consistency-12-callback-named-for-action.md) — Name callbacks for what they do, not the event they handle - [CONSISTENCY-13](rules/consistency-13-new-file-header.md) — Non-trivial new files start with a header description - [CONSISTENCY-14](rules/consistency-14-comment-why.md) — Comments explain why the code exists, not what it does - [CONSISTENCY-15](rules/consistency-15-plain-comment-style.md) — Write comments as plain, natural sentences - [CONSISTENCY-16](rules/consistency-16-no-ai-jargon.md) — No AI-generated jargon in code or comments - [CONSISTENCY-17](rules/consistency-17-plural-form.md) — Pluralize with PluralForm, not ternaries on a count - [CONSISTENCY-18](rules/consistency-18-comment-non-obvious-code.md) — Comment code that is not self-explanatory - [CONSISTENCY-19](rules/consistency-19-copy-grammar-and-case.md) — User-facing copy is grammatical and sentence case - [CONSISTENCY-20](rules/consistency-20-function-names.md) — Name functions with a verb that says what they do - [CONSISTENCY-21](rules/consistency-21-sentry-label-type.md) — Type a forwarded sentryLabel with the SentryLabel helpers ### Clean React Patterns - [CLEAN-REACT-PATTERNS-1](rules/clean-react-1-composition-over-config.md) — Composition over configuration - [CLEAN-REACT-PATTERNS-2](rules/clean-react-2-own-behavior.md) — Components own their behavior - [CLEAN-REACT-PATTERNS-3](rules/clean-react-3-context-free-contracts.md) — Context-free component contracts - [CLEAN-REACT-PATTERNS-4](rules/clean-react-4-no-side-effect-spaghetti.md) — No side-effect spaghetti - [CLEAN-REACT-PATTERNS-5](rules/clean-react-5-narrow-state.md) — Keep state narrow - [CLEAN-REACT-PATTERNS-6](rules/clean-react-6-no-componentprops.md) — Import the exported prop type instead of ComponentProps - [CLEAN-REACT-PATTERNS-7](rules/clean-react-7-no-inline-prop-types.md) — Do not inline prop types on exported components - [CLEAN-REACT-PATTERNS-8](rules/clean-react-8-no-class-components.md) — Use function components, not class components - [CLEAN-REACT-PATTERNS-9](rules/clean-react-9-no-proptypes.md) — Use TypeScript types, not propTypes or defaultProps ### UI - [UI-1](rules/ui-1-correct-loading-indicator.md) — Use the correct loading indicator based on navigation context - [UI-2](rules/ui-2-new-page-scrollview.md) — New pages must be scrollable - [UI-3](rules/ui-3-no-inline-styles.md) — Do not use inline style objects - [UI-4](rules/ui-4-layout-spacing-tokens.md) — Type and responsive insets come from tokens - [UI-5](rules/ui-5-reuse-existing-styles.md) — Reuse an existing style or StyleUtils helper instead of adding a new one ### Privacy - [PRIVACY-1](rules/privacy-1-mask-sensitive-data.md) — Mask sensitive data in FullStory ### Onyx - [ONYX-1](rules/onyx-1-no-render-reachable-onyx-read.md) — Keep Onyx reads off the render path and out of a written tick