1. General formatting guidelines
1.1. Encoding
Section titled “1.1. Encoding”All code must be encoded in UTF-8.
Make sure your editor uses UTF-8 as character encoding, without a byte order mark.
1.2. Indentation
Section titled “1.2. Indentation”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.
1.3. Line Length
Section titled “1.3. Line Length”All code must be less than 120 characters per line.
1.4. Line Endings
Section titled “1.4. Line Endings”All code must use LF line endings.
1.5. Blank Lines
Section titled “1.5. Blank Lines”Separate meaningful code blocks with a blank line.
Avoid unnecessary blank lines.
Text files should ends with a newline character, except for JSON files.
1.6. Trailing Whitespace
Section titled “1.6. Trailing Whitespace”Remove trailing white spaces.
Trailing white spaces are unnecessary and can complicate diffs.
1.7. Comments
Section titled “1.7. Comments”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?
1.8. Action Items
Section titled “1.8. Action Items”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 */1.9. Horizontal Alignment
Section titled “1.9. Horizontal Alignment”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,};