Quick Reference Guide

October 16, 2025 ยท View on GitHub

This is a quick reference for common tasks in this TypeScript template.

๐Ÿš€ Common Commands

CommandDescription
yarn installInstall all dependencies
yarn testRun tests with coverage
yarn lintCheck code style and quality
yarn lint:fixAutofix linting issues
yarn packageBuild production bundle
yarn allRun complete pipeline

๐Ÿ“ Key Files to Customize

Must Update

  • package.json - Project name, author, description, URLs
  • README.md - Project documentation
  • LICENSE - Verify license is appropriate
  • .github/CODEOWNERS - Update with your username

Optional Updates

  • eslint.config.mjs - Adjust linter rules
  • .prettierrc.yml - Modify formatting preferences
  • tsconfig.json - Change TypeScript settings
  • jest.config.cjs - Adjust test configuration

๐Ÿ”ง Configuration Quick Reference

TypeScript

// tsconfig.json - Key settings
{
  "compilerOptions": {
    "target": "ES2022", // JavaScript version
    "strict": true, // Strict type checking
    "module": "ES2022", // Module system
    "esModuleInterop": true // CommonJS compatibility
  }
}

ESLint

// eslint.config.mjs - Key settings
{
  rules: {
    'complexity': ['error', { max: 10 }],  // Max complexity
    'sonarjs/cognitive-complexity': ['error', 15]
  }
}

Prettier

# .prettierrc.yml - Key settings
semi: true # Semicolons
singleQuote: true # Quote style
tabWidth: 2 # Indentation
printWidth: 80 # Line length

Jest

// jest.config.cjs - Key settings
{
  collectCoverageFrom: ['src/**/*.ts'],
  coverageThreshold: {
    global: { branches: 80, functions: 80, lines: 80 }
  }
}

๐Ÿ“ Project Structure Templates

Simple Project

src/
โ”œโ”€โ”€ index.ts           # Entry point
โ”œโ”€โ”€ app.ts             # Main application
โ”œโ”€โ”€ utils/             # Utility functions
โ””โ”€โ”€ __tests__/         # Tests

Layered Architecture

src/
โ”œโ”€โ”€ index.ts           # Entry point
โ”œโ”€โ”€ controllers/       # Request handlers
โ”œโ”€โ”€ services/          # Business logic
โ”œโ”€โ”€ repositories/      # Data access
โ”œโ”€โ”€ models/            # Data models
โ”œโ”€โ”€ utils/             # Utilities
โ””โ”€โ”€ __tests__/         # Tests

Library/Package

src/
โ”œโ”€โ”€ index.ts           # Public API
โ”œโ”€โ”€ core/              # Core functionality
โ”œโ”€โ”€ types/             # Type definitions
โ”œโ”€โ”€ utils/             # Internal utilities
โ””โ”€โ”€ __tests__/         # Tests

๐Ÿงช Testing Patterns

Basic Test

import { describe, it, expect } from '@jest/globals';

describe('MyFunction', () => {
  it('should return expected result', () => {
    expect(myFunction()).toBe(expectedResult);
  });
});

Async Test

it('should handle async operations', async () => {
  const result = await asyncFunction();
  expect(result).toBe(expectedResult);
});

Mock Test

import { jest } from '@jest/globals';

it('should call dependency', () => {
  const mockFn = jest.fn();
  myFunction(mockFn);
  expect(mockFn).toHaveBeenCalled();
});

๐Ÿ”„ Git Workflow

Initial Setup

# After using template
git clone https://github.com/YOUR_USERNAME/YOUR_REPO.git
cd YOUR_REPO
corepack enable
yarn install
yarn all

Daily Workflow

# Create feature branch
git checkout -b feature/my-feature

# Make changes, then test
yarn all

# Commit changes
git add .
git commit -m "feat: add new feature"

# Push to remote
git push origin feature/my-feature

Before Committing

# Run full pipeline
yarn all

# Or run checks individually
yarn lint:fix
yarn test
yarn quality
yarn package

๐Ÿ“Š Quality Gates

The template enforces these quality standards:

CheckThresholdCommand
Test Coverage80%yarn test
Cyclomatic Complexity10yarn lint
Cognitive Complexity15yarn lint
Code Duplication1%yarn duplication
Circular Dependencies0yarn madge

๐Ÿ› Troubleshooting

Tests Failing

# Clear cache and retry
yarn test --clearCache
yarn test

Linting errors

# Auto-fix what's possible
yarn lint:fix

# Check remaining issues
yarn lint

Build Issues

# Check TypeScript errors
yarn typecheck

# Rebuild from scratch
rm -rf dist node_modules .yarn/cache
yarn install
yarn package

Module Resolution Issues

# Clear TypeScript cache
rm -rf dist
rm -f tsconfig.tsbuildinfo

# Rebuild
yarn package

๐Ÿ“š Additional Resources

๐Ÿ’ก Tips

  1. Run yarn all often - Catch issues early
  2. Write tests first - TDD helps design better APIs
  3. Use yarn lint:fix - Save time on formatting
  4. Check the logs - Error messages are usually helpful
  5. Keep dependencies updated - Run yarn up '*' regularly

๐Ÿ†˜ Getting Help

  • Check Issues
  • Read the Full readme
  • Review example code in src/
  • Check configuration files for examples

Keep this file handy during development!