Contributing to Mesh Client
Thank you for your interest in contributing. See docs/development-environment.md for setup.
Where conventions live: AGENTS.md is self-contained for AI assistants (code style, testing, architecture, and security all inlined). This file covers human setup, hooks, and PR flow.
Code style & standards
- Prettier: Semi always, single quotes, trailing commas, print width 100, tab 2, LF.
- TypeScript: Strict; avoid
any; preferunknown+ guards; export types; prefer interfaces over type aliases. - React: Function components only;
exhaustive-depsis errors;?.in JSX; every interactive control needsaria-label. - Colors: Use Tailwind CSS utility classes (e.g.,
text-green-400,bg-slate-700). Custom theme colors via CSS custom properties fromstyles.css(--color-brand-green,--color-deep-black, etc.). Avoid inline hex colors in JSX. - Zustand: Module-level defaults for stable refs; prefer
useStore(s => s.field)over broad subscriptions; avoid subscribing to whole Maps when one id suffices;persistfor localStorage, IPC from an effect for SQLite; extract time constants tosrc/renderer/lib/timeConstants.ts(e.g.MS_PER_SECOND). - Performance: No hot-path O(n); lazy cleanup when collections grow large.
Testing protocols
- Renderer: jsdom (
src/renderer/**/*.test.{ts,tsx}). Main: node (src/main/**/*.test.ts). - Mock console before spying logged errors (e.g.
vi.spyOn(console, 'warn').mockImplementation(() => {}); usebeforeEachwhen shared). - Update
src/main/index.contract.test.tswhen CSP, build config, IPC limits, or log filters change.
Quick Commands
pnpm install
pnpm run dev # Development mode
pnpm run build # Production build
pnpm run lint # ESLint
pnpm run test:run # Run tests
Pre-commit Hook
Before each commit, the hook runs (order matters):
pnpm run format: Prettier writes fixespnpm run lint:md: Markdown fixes- Re-stage staged files
pnpm run lintpnpm run typecheckcheck:log-injection,check:log-service-sinks,check:codeql-extensions,check:db-migrations,check:ipc-contract,check:licenses,check:url-hostname-sanitizationpnpm auditactionlint,yamllintpnpm run test:run
The live hook in .githooks/pre-commit also runs pnpm run i18n:auto-translate (incremental vs HEAD English, not --all) and re-stages src/renderer/locales/ before lint. MyMemory uses info@coloradomesh.org as the default contact for the higher free quota unless MYMEMORY_EMAIL is set — see AGENTS.md (i18n / Localization).
Skip in emergency: git commit --no-verify.
PR Process
- Describe your changes and what you tested
- Update docs if needed
- Run the checks you need before review (at minimum what the pre-commit hook runs, especially
pnpm run lintandpnpm run test:run) - Keep PR scope tight
- A maintainer will review
AI-assisted contributions
Follow AGENTS.md for mesh-specific and security expectations, and this file for code style and testing conventions. Review every line of AI-generated code before merging. Do not accept AI-generated IPC or preload changes without understanding them (Electron IPC is a common weak spot). You may note briefly in the PR if you used an AI tool.
Avoid duplicating always-on Cursor or editor rules with this repo's docs; merge overlaps and prefer requestable rules over always-on where possible to reduce fixed context size.
By contributing, you agree to license under the MIT License.