Skip to content

1. General formatting guidelines

All code must be encoded in UTF-8.

Make sure your editor uses UTF-8 as character encoding, without a byte order mark.

All code must be indented using 2 spaces.

Don’t use tabs or mix tabs and spaces for indentation.

Included blocks of code should be indented with the same amount of spaces as the surrounding code.

All code must be less than 120 characters per line.

All code must use LF line endings.

Separate meaningful code blocks with a blank line.

Avoid unnecessary blank lines.

Text files should ends with a newline character, except for JSON files.

Remove trailing white spaces.

Trailing white spaces are unnecessary and can complicate diffs.

Explain code as needed, where possible.

Use comments to explain code: what does it cover, what purpose does it serve, why is respective solution used or preferred?

Mark todos and action items with @todo or @fixme keywords.

Append action items or descriptions after a colon as in @todo: action item because of reason.

Recommended
// @todo: add a new column to the table to display the new data
/* @fixme: fix a position of the element in the layout to not overlap with the header */
Not recommended
// do something
/* will fix this later */

Avoid aligning code horizontally.

Recommended
const a = {
email: 'john.doe@example.com',
firstName: 'John',
lastName: 'Doe',
age: 20,
};
Not recommended
const a = {
email: 'john.doe@example.com',
firstName: 'John',
lastName: 'Doe',
age: 20,
};