Skip to content

Coding Standards (js, ts)

sharon wang edited this page Mar 2, 2023 · 5 revisions

JavaScript / TypeScript

Note: you can set up the pre-commit git hook to automatically run linting and formatting. Refer to the git hook setup instructions here: git_hooks/README.md

General

  • indent with 2 spaces
  • no line break before opening braces (types, functions, lambdas, etc)
  • don't omit optional semicolons at end of statements
  • source file names must be all lowercase and may include dashes
  • maximum line width of 120

Our .prettierrc: https://github.com/rstudio/rstudio/blob/main/src/node/desktop/.prettierrc

Naming

  • Use PascalCase for type names
  • Use PascalCase for enum values
  • Use camelCase for function and method names
  • Use camelCase for property names and local variables