β¨Style and structure guide
This page describe the preferred code style and folder structures of a module
Code formatting
By default a Multijet project uses Prettier as a code formatter, customizable with the root configuration file:
{
"singleQuote": true,
"trailingComma": "all",
"semi": false,
"tabWidth": 4,
"arrowParens": "avoid"
}
Editor configuration
If you are using VSCode, multijet includes a default configuration (located in the .vscode
folder) that includes recommended extensions, debug configurations and formatting settings.
It is highly recommended to use Conventional Commits as a standard for all Git commits.
Modules file structure
It is suggested to follow a standard file structure when developing shared libs.
The followings are examples of how you can structure your libraries in order to make them more consistent and readable.
my-lib/
βββ src/
βββ core/
β βββ ... core implementation
βββ models/
β βββ ... interfaces and models
βββ common/
β βββ const.ts
β βββ errors.ts
β βββ ... used in the entire lib
βββ helper/
β βββ ... helper functions
βββ index.ts
If your library needs to be divided in submodules you can follow the same structure as follows:
my-lib/
βββ src/
βββ module-1/
β βββ core/
β β βββ module-1.ts
β βββ models/
β β βββ module-1.models.ts
β β βββ module-1.errors.ts
β β βββ module-1.consts.ts
β β βββ ...
β βββ helper
βββ module-2/
β βββ core
β βββ models
β βββ helper
βββ common/
β βββ consts.ts
β βββ types.ts
β βββ ... used between modules
βββ index.ts
The library index.ts
should only contain exports for the modules and interfaces you want to export, nothing more.
The following is a real example of a small lib:
Last updated