Skip to content

Styleguides

This section provides general formatting and stylistic guidelines for the gaslamp project.

These conventions ensure consistent and clean code across all modules and help developers collaborate more effectively.

Code Style

This project uses:

  • Biome for code formatting and linting
  • TypeScript with strict mode
  • Conventional Commits for commit messages
  • TypeDoc for documentation generation

Contents

This section includes:

  • Naming Guidelines — Conventions for variables, functions, classes, and commit messages
  • Code Style — Formatting, syntax, and markdown preferences (this page)
  • Docstring Standards — TypeDoc documentation format and best practices
  • Design Patterns — Recurring architectural patterns and API consistency rules

Related resources:

JavaScript / TypeScript Style

  • Use camelCase for variables and functions
  • Use PascalCase for classes
  • Prefer const and let over var
  • Always use trailing commas in multi-line objects and arrays
  • Use === and !== instead of == and !=
  • Prefer arrow functions for inline callbacks
  • Indent using 2 spaces
  • Prefer for...of over forEach for better readability and control flow (e.g., to allow break, continue, and return)
  • Use import type for type-only imports in TypeScript
  • Group and sort imports: external → internal → relative
  • Prefer shorthand object properties ({ x } over { x: x })
  • Use semicolons consistently
  • Prefer template literals over + string concatenation

TypeScript-Specific Style

  • Prefer explicit return types for exported functions
  • Use interface for public API shapes; type for internal utility types
  • Avoid using any; prefer unknown with refinement
  • Prefer readonly where applicable (especially for arrays or objects)
  • Always use public, private, or protected explicitly on class methods and properties. Even though public is the default in TypeScript, explicit declaration improves readability and maintainability.

GAS-Specific Style Notes

  • Do not shadow built-in objects like SpreadsheetApp, Logger, etc.
  • Use short, clear names for GAS objects:
  • sheet, range, book for Spreadsheet
  • doc, form, calendar for other services

Markdown / Docs Style

  • Use sentence case for headings
  • Use code blocks (```) for inline examples
  • Avoid personal pronouns in reference docs
Markdown
**Good**

This method returns the number of rows.

**Bad**

You can use this method to get your rows.