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:
- Testing Practices — How to write tests using JestLite
- Build Documentation — TypeDoc and documentation generation
JavaScript / TypeScript Style¶
- Use
camelCasefor variables and functions - Use
PascalCasefor classes - Prefer
constandletovervar - 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...ofoverforEachfor better readability and control flow (e.g., to allowbreak,continue, andreturn) - Use
import typefor 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
interfacefor public API shapes;typefor internal utility types - Avoid using
any; preferunknownwith refinement - Prefer
readonlywhere applicable (especially for arrays or objects) - Always use
public,private, orprotectedexplicitly on class methods and properties. Even thoughpublicis 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,bookfor Spreadsheetdoc,form,calendarfor 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.