Skip to main content
This page extends Common Rules with TypeScript/JavaScript specific content.Applies to: **/*.ts, **/*.tsx, **/*.js, **/*.jsx

Coding Style

Immutability

Use spread operator for immutable updates:

Error Handling

Use async/await with try-catch:

Input Validation

Use Zod for schema-based validation:

Console.log

  • No console.log statements in production code
  • Use proper logging libraries instead
  • See hooks for automatic detection

Testing

E2E Testing

Use Playwright as the E2E testing framework for critical user flows.

Agent Support

e2e-runner

Playwright E2E testing specialist

Patterns

API Response Format

Custom Hooks Pattern

Repository Pattern

Security

Secret Management

Agent Support

security-reviewer

Use for comprehensive security audits

Hooks

PostToolUse Hooks

Configure in ~/.claude/settings.json:
Automatically runs Prettier on JavaScript and TypeScript files after edits to maintain consistent formatting.
Runs TypeScript compiler in check mode (tsc --noEmit) to catch type errors immediately.
Detects console.log statements in edited files and warns to use proper logging instead.

Stop Hooks

Final check for any console.log statements that may have been added during the session.

Common Rules

Language-agnostic base rules

Hooks Overview

Complete hook system reference