Skip to content
Peter Strömberg edited this page Nov 24, 2019 · 6 revisions

These style conventions are inspired by the VS Code Development Guidlines, as well as the TypeScript Team's Guidelines.

PRs with fixes of the code to adhere to these guidelines are welcome.

Indentation

Use four spaces, not tabs.

Names

  • Use PascalCase for type names
  • Use PascalCase for enum values
  • Use camelCase for function and method names
  • Use ALL_CAPS for static property names
  • Use camelCase for property names and local variables
  • Use whole words in names when possible
  • Do not use "I" as a prefix for interface names.
  • When grouping a bunch of lets and consts together, place them on separate lines

Variables

  • If a variable is not going to be changed, make it immutable with const

Comments

  • Use JSDoc style comments for functions, interfaces, enums, and classes

Strings

  • Prefer 'single quotes' over "double quotes", except when "double quotes" give less backslash escaping.
  • Prefer interpolation of ${expressions} over string concatenation.
    • Do not use this interpolation syntax when it is not used for interpolating something.

Anonymous functions

  • Use arrow functions => syntax
  • Only surround arrow function parameters when necessary. For example, instead of: (x) => { x + x } use: x => { x + x }.

Curlies

  • Always surround loop and conditional bodies with curly braces
  • Open curly braces always go on the same line as whatever necessitates them
  • Parenthesized constructs
    • Should have no surrounding whitespace.
    • A single space follows commas, colons, and semicolons

Files

  • Use kebab-case for file names.