Skip to content

Code Quality Standards

This project uses Biome for code formatting, linting, and import organization to ensure consistent code quality across the codebase.

Biome Configuration

Biome has replaced ESLint and Prettier in this project for better performance and a unified tooling experience. The configuration is defined in biome.json at the project root.

Key Settings

  • Semicolons: Always required ("always")
  • Indentation: 4 spaces
  • Quote Style: Double quotes preferred
  • Line Width: 80 characters
  • Parameter Decorators: Enabled for NestJS compatibility (unsafeParameterDecoratorsEnabled: true)

Available Commands

# Format all files
pnpm run format

# Check formatting without making changes
pnpm run format:check

# Run linting checks
pnpm run lint

# Fix linting issues automatically
pnpm run lint:fix

IDE Setup

  1. Install the Biome extension:
Extension ID: biomejs.biome
  1. Workspace settings are pre-configured in .vscode/settings.json:
  2. Format on save enabled
  3. Biome set as default formatter
  4. Auto-organize imports on save
  5. Quick fixes applied automatically

Other Editors

For other editors, refer to the Biome Editor Integration guide.

File Coverage

Biome processes the following file types:

  • TypeScript files: src/**/*.ts, test/**/*.ts, src/**/*.spec.ts
  • JavaScript files: *.js, *.mjs
  • JSON files: *.json, *.jsonc

Pre-commit Hooks

Consider setting up pre-commit hooks to automatically format and lint code:

# Example using husky + lint-staged
pnpm add -D husky lint-staged

# In package.json
"lint-staged": {
  "*.{ts,js,json}": ["pnpm run format", "pnpm run lint:fix"]
}

Code Style Guidelines

TypeScript/JavaScript

  • Use explicit types where beneficial for readability
  • Prefer const over let when variables don't change
  • Use meaningful variable and function names
  • Add JSDoc comments for public APIs
  • Destructure objects when accessing multiple properties

NestJS Specific

  • Use parameter decorators (e.g., @Body(), @Param())
  • Organize imports: external packages, then internal modules
  • Use dependency injection consistently
  • Follow NestJS naming conventions for controllers, services, modules

Example

import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';

/**
 * Service for managing user authentication.
 */
@Injectable()
export class AuthService {
  constructor(private readonly configService: ConfigService) {}

  /**
   * Validates user credentials.
   * @param email User's email address
   * @param password User's password
   * @returns Authentication result
   */
  async validateUser(email: string, password: string): Promise<boolean> {
    const isValid = await this.checkCredentials(email, password);
    return isValid;
  }
}