This file describes the various style and design conventions that are used in the Kent dashboard repository.
Our TypeScript style is inspired by the style guidelines of the TypeScript implementation itself.
- Use PascalCase for type names.
- Do not use
Ias a prefix for interface names. - Use PascalCase for
enumvalues. - Use
camelCasefor function names. - Use
camelCasefor property names and local variables. - Use
_as a prefix for private properties. - Use whole words in names when possible.
- Give type parameters names prefixed with
T, for exampleRequest<TBody>.
- Use
undefined. Do not usenull. - Prefer
for..ofover.forEach. - Do not introduce new types/values to the global namespace.
- Keep
main.tsfree from implementation, it should only contain re-exports. - If a file has a single or a main export, name the file after the export.
We use API Extractor to generate our documentation, which in turn uses TSDoc to parse our doc comments.
The doc comments are of the good old /** ... */ format, with tags of the format @<tag> used to mark various things. The TSDoc website has a good index of all available tags.
There are a few things to pay attention to, in order to make the documentation show up in a nice way on the website...
The API reference has an index of exported symbols for each package, which uses a short description, while clicking through to the page for a symbol shows the full description. By default all descriptions are considered "short", and you have to manually add a divider where the description should be cut off using the @remarks tag.
/**
* This function helps you create a thing.
*
* @remarks
*
* Here is a much longer and more elaborate description of how the
* creation of a thing works, which is way too long to fit on the index page.
*/
function createTheThing() {}When using the @param tag to document a parameter it will show up in the Parameters section:
Be sure to include a - after the parameter name as well as required by TSDoc, or you'll get a warning in the API report.
/**
* Generates a PluginCacheManager for consumption by plugins.
*
* @param pluginId - The plugin that the cache manager should be created for. Plugin names should be unique.
*/
forPlugin(pluginId: string): PluginCacheManager {
...
}