-
-
Notifications
You must be signed in to change notification settings - Fork 219
Coding Style
Peter Strömberg edited this page Oct 12, 2020
·
6 revisions
These style conventions are inspired by the VS Code Development Guidelines, as well as the TypeScript Team's Guidelines.
Aside from the below guidelines, for other style concerns, generally following the Airbnb JavaScript style guide is ideal.
PRs with fixes of the code to adhere to these guidelines are welcome.
Use four spaces, not tabs.
End each statement with a semicolon.
- Use PascalCase for
type
names - Use PascalCase for
enum
values - Use camelCase for
function
andmethod
names - Use ALL_CAPS for static
property
names - Use camelCase for
property
names andlocal variables
- Use whole words in names when possible
- Do not use "I" as a prefix for interface names.
- Do not group variable assignments using one const/let. Each variable assignment should have its own const/let and should be on its own line.
- If a variable is not going to be changed, make it immutable with
const
- Declare each variable on a line of it's own and as separate statements (i.e. do not chain declarations using commas).
- Use JSDoc style comments for
functions
,interfaces
,enums
, andclasses
- Prefer 'single quotes' over "double quotes", except when "double quotes" allow less backslash escaping.
- Prefer
interpolation of ${expressions}
over string concatenation.- Do not use this interpolation syntax when it is not used for interpolating something.
- Use arrow functions
=>
syntax - Only surround arrow function parameters when necessary. For example, instead of:
(x) => { x + x }
use:x => { x + x }
.
- 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
- Use
kebab-case
for file names.