Skip to main content

Quality Gate

All five checks must pass before any commit.
Run these commands before committing:
If any check fails, fix the issues and verify again. Only claim what you actually ran.

Linting

Run ESLint

ESLint checks for:
  • Code style violations
  • Unused imports
  • Common programming errors
  • React/React Native best practices

Configuration

ESLint is configured with:
  • eslint-config-expo - Expo’s recommended config
  • eslint-config-prettier - Disables rules that conflict with Prettier
  • eslint-plugin-prettier - Runs Prettier as an ESLint rule
  • eslint-plugin-unused-imports - Detects and removes unused imports
The linter will auto-fix many issues. Check the output for remaining manual fixes.

Type Checking

Run TypeScript Compiler

This runs tsc --noEmit to check TypeScript types without generating output files.

Common Type Errors

Always import types from coco-cashu-core, never redefine them.
Import from coco, not the underlying @cashu/cashu-ts library.
Check .cursor/rules/zustand-store-scoping.mdc for store type patterns and scoping rules.

Code Formatting

Check Formatting

Auto-Fix Formatting

Prettier formats:
  • JavaScript/TypeScript files (.js, .jsx, .ts, .tsx)
  • JSON files
  • Module formats (.mjs, .cjs)

Configuration

Prettier is configured with:
  • prettier-plugin-tailwindcss - Automatically sorts Tailwind classes
Most editors can auto-format on save. Configure your editor to run Prettier automatically.

Dead Code Detection

Run Knip

Knip finds:
  • Unused exports
  • Unused dependencies in package.json
  • Unreferenced files
  • Duplicate exports

What to do with Knip results

1

Review the output

Knip will list unused exports, files, and dependencies.
2

Verify before deleting

Some exports may be used by external tools or in ways Knip can’t detect. Verify before removing.
3

Remove dead code

Delete genuinely unused code. Keep the codebase lean.

Testing

Run Tests

This runs the Jest test suite.

Test Configuration

Tests use:
  • jest - Testing framework
  • jest-expo - Expo-specific Jest preset
  • @types/jest - TypeScript definitions for Jest

Writing Tests

Styling Standards

Use Semantic Tokens

Prefer semantic tokens over raw hex colors.

Runtime Color Values

Use useThemeColor for dynamic color access:
For multiple colors, use the array form to reduce hooks.

Prefer className Over style

Performance Best Practices

List Performance

Avoid Unnecessary Memoization

Loading States

Use HeroUI Components

Skeletons must not cause layout shift. Match final dimensions and preserve container structure.

Skeleton Best Practices

Comments and JSDoc

No JSDoc that restates TypeScript types.

When to add JSDoc

Add JSDoc only for:
  • Intent (why this exists)
  • Constraints (limits, edge cases)
  • UX rules (user-facing behavior)
  • Async contracts (timing, dependencies)
  • Invariants (must-hold conditions)

Quick Reference

All five must pass before committing: lint, type-check, pretty:check, knip, test.