#Regular Comments
Every time you express yourself in code, you should pat yourself on the back. Every time you write a comment, you should grimace and feel the failure of your ability of expression.
In general it is preferable to avoid writing comments, especially if there is a way to cleanly express the logic with the code itself (aka self-documenting code). Otherwise, we adhere to the following rules about comments:
Do NOT write comments that are noisy or state the obvious
Do NOT write
TODO
commentsℹ️ If you find yourself writing
TODO
comments, instead create a new task on GitHub or add to your existing task's requirements list.Do NOT write inline or embedded comments
Bad
Good
They should be preceded by a blank without a following a blank line
Bad
Good
#TSDoc Comments
Because our library is of a considerable size, it is helpful to create and maintain library specifications and documentation so that developers can easily see what is inside a particular module.
As such, it is important that when writing code that is intended to be used elsewhere (e.g. in a component, elsewhere in the library), it is annotated with a TSDoc comment. It is also important to write these comments consistently and in a way that makes it easier to actually read the generated markdown specification pages.
Helpers functions within a module file should NOT be annotated.
#Constants
When writing constants, use the following template:
Example
#Enums
When writing enums, use the following template:
Example
#Functions
#void
/ Promise<void>
When writing functions that returns void
or Promise<void>
, use the following template:
Example
#boolean
When writing functions that return a boolean
, use the following template:
Example
#Non-void
/Promise<void>
and non-boolean
When writing functions that return neither void
nor Promise<void>
nor boolean
s, use the following template:
Example
#Interfaces
When writing interfaces, use the following template:
Example
#Types
When writing types, use the following template:
Example
#Stores
When writing stores, use the following template:
Example
#Comments