Braces

Verze:

18. 06. 2025

Zodpovědná osoba:

Dominik Šlechta

Poslední aktualizace:

05. 01. 2026, dominikslechta.1@gmail.com

Opening braces MUST be placed on the same line as statements (1TBS style).

Braces on the Same Line (1TBS)

  • Rule: Opening braces MUST be placed on the same line as their corresponding statements, using the 1TBS (One True Brace Style).

  • Reason: The 1TBS style improves code compactness and consistency, making it easier to read and follow. This is the standard convention in JavaScript.

Example (Correct):

if (condition) {
	doSomething();
} else {
	doSomethingElse();
}

function calculate() {
	return 42;
}

Example (Incorrect):

if (condition) 
{
	doSomething();
}
else 
{
	doSomethingElse();
}

Summary:

  • Tabs MUST be used for indentation.
  • Opening braces MUST be on the same line as the statement (1TBS style).