Naming Convention

File Naming Convention

In our project, file names should follow a simple and consistent format: kebab-case, followed by a dot and the file's group or type.

Why?

This helps keep things organized and makes it easy to identify what a file is for at a glance.

Example:

For a file related to user authentication in the controller group, name it: user-auth.controller.ts

Stick to this format, and we’ll have a clean and manageable project structure.

Variable naming

Variables should be:

  • Short and descriptive: Name variables in a way that clearly describes their purpose.

  • CamelCase: Start with a lowercase letter, and capitalize subsequent words.

Example:

let userAge = 25;
let orderTotal = 150.75;

Here’s a friendly and professional guide for coding standards, including variable and function naming, with additional guidelines you can consider: Variable Naming

Variables should be:

Short and descriptive: Name variables in a way that clearly describes their purpose.
CamelCase: Start with a lowercase letter, and capitalize subsequent words.

Examples:

let userAge = 25; let orderTotal = 150.75;

Function Naming

Functions should:

  • Start with a verb: Reflect the action the function performs (e.g., calculate, fetch, validate).

  • Use CamelCase: Follow the same camelCase format as variables.

Examples:

function calculateTotalPrice(items) {
  // Logic here
}

function fetchUserData(userId) {
  // Logic here
}

Constants

  • Use UPPERCASE_SNAKE_CASE for constants.

  • Constants should have descriptive names that indicate their purpose.

Examples:

const MAX_RETRY_COUNT = 3;
const API_BASE_URL = "https://api.example.com";

Last updated