Instruction file imported from JeffreyZhu0201/MeridianERP (
.cursor/rules/quality.mdc). Copyright stays with the author.
description: MeridianERP TypeScript, naming, imports, errors, and test quality rules globs: /*.{ts,tsx},/*.{spec,test}.{ts,tsx},e2e/** alwaysApply: false
Quality
- TypeScript stays strict; avoid
any; useunknownplus guards when needed. - Files use kebab-case; classes PascalCase; functions camelCase; constants SCREAMING_SNAKE_CASE; API paths kebab-case.
- Import order: external packages,
@meridian/*, then relative imports. - Backend errors must be consistent and must not expose production stack traces.
- Frontend errors use inline validation for forms and toast or alert feedback for transient failures.
- Tests map each P0 acceptance criterion to at least one unit, API integration, or Playwright case.
- Backend unit tests live near API code; API integration tests live in
apps/api/test; Playwright tests live ine2e. - Test names use
describe('<Unit>')andit('should <behavior> when <condition>').
Readability And Simplification
- Prefer small, linear functions with clear domain names over generic clever helpers.
- Split files when one file owns multiple independent responsibilities such as API calls, tables, dialogs, forms, and mappers.
- Extract shared helpers only when at least two call sites become simpler and the helper name matches the domain.
- Delete dead code, unused compatibility shims, stale comments, and generated-style headers when touching a file.
- Comments should explain business intent, invariants, or non-obvious side effects; do not narrate obvious TypeScript.
- Keep React components focused on rendering and local interaction; move formatting, query-string, and API helpers out of JSX-heavy files.
- Keep NestJS controllers thin and services readable; extract mappers, pagination, date-range, and include/select helpers from large services.
- Avoid preserving compatibility for unshipped branch-only behavior; replace it cleanly.