TypeScript code quality patterns for writing and reviewing code. Covers type safety, clean code, functional patterns, Zod usage, and error handling...
Project-specific code quality checklist for the Saleor Configurator codebase. Covers type safety conventions, error handling patterns, and architectural standards unique to this project.
| Convention | Rule |
|---|---|
No any |
Production code only; allowed in test mocks |
| Branded types | Use EntitySlug, EntityName for domain values |
| Error classes | Extend BaseError with error code |
| GraphQL errors | Wrap with GraphQLError.fromCombinedError() |
| Zod errors | Wrap with ZodValidationError.fromZodError() |
| Functions | 10-50 lines ideal, ~100 max |
| Style | Functional (map/filter/flatMap) over loops |
any types in production codeas unknown as T)!) without justificationEntitySlug, EntityName)satisfies for type validation with literal preservationreadonly for immutable datais/has/should/can prefixmap/filter/flatMap over for/forEach loopsreduce (use Map)BaseError with error codeGraphQLError.fromCombinedError()ZodValidationError.fromZodError()Structure findings as:
Items that must be fixed before merge.
Items that should be addressed but are not blocking.
Nice-to-have improvements for future consideration.
Well-implemented patterns worth highlighting.
vi.fn() mocks with schema-generated test dataz.infer<> for types| Mistake | Fix |
|---|---|
Using any in production code |
Use unknown + type guards |
| Exposing GraphQL types to services | Map to domain types in repository |
| Missing error context in GraphQL calls | Include operation name in error |
Long if-else chains |
Refactor to registry/strategy pattern |
Accumulating spreads in reduce |
Use Map or Object.fromEntries |
Mutation in loops (push) |
Use map/filter/flatMap |
docs/CODE_QUALITY.md - Complete coding standardsdocs/ARCHITECTURE.md - Service patternsbiome.json - Linting rulesadding-entity-types for architectural patternsdesigning-zod-schemas for schema review criteriavalidating-pre-commit for quality gate commandsFor a condensed quick reference, see .claude/rules/code-quality.md (automatically loaded when editing src/**/*.ts files).