Naming conventions

Verze:

18. 06. 2025

Zodpovědná osoba:

Dominik Šlechta

camelCase for Variable Names and Function Names

  • Rule: camelCase MUST be used for variable names and function names.

  • Reason: camelCase is the standard for variable and function names in JavaScript. It improves consistency and readability within the codebase.

Example (Correct):

let userName = 'John'; 
function calculateTotal() {}

Example (Incorrect):

let UserName = 'John';
function CalculateTotal() {} 

PascalCase for Types and Classes

  • Rule: PascalCase MUST be used for types and classes.

  • Reason: PascalCase is the convention for class and type names. It helps distinguish them from variables and functions, and aligns with standard JavaScript practices for object-oriented programming.

Example (Correct):

class UserAccount {  
    constructor(name) {
        this.name = name;
    }
}

Example (Incorrect):

class userAccount {  
    constructor(name) {
        this.name = name;
    }
}

 UPPER_CASE for Constants

  • Rule: UPPER_CASE MUST be used for constants.

  • Reason: Constants are typically written in uppercase letters with underscores to separate words. This provides a clear distinction from variables and functions.

Example (Correct):

const MAX_USERS = 100;

Example (Incorrect):

const maxUsers = 100;

Summary:

  • Naming conventions: camelCase for variables/functions, PascalCase for classes/types, UPPER_CASE for constants.