Indentation with Tabs
-
Rule: Code MUST be indented using tabs (as defined in Global Standards).
-
Reason: Tabs allow each developer to configure their preferred visual width while maintaining consistent indentation characters across the codebase.
Example (Correct):
if (true) {
console.log('Hello, world!');
}
Example (Incorrect):
if (true) {
console.log('Hello, world!'); // spaces instead of tabs
}
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).