Skip to main content

Core Coding Standards

Naming Conventions

  • Use plural names for resources: users, companies, roles.
  • Use clear, intention-revealing names.
  • Avoid naming objects like booleans. If it is an object, name it as an object.
  • Avoid long or unclear method and variable names.
  • Use a consistent naming style across the codebase.
  • Avoid ambiguous abbreviations.
  • Keep names concise but descriptive.
  • Avoid reusing names for different meanings in the same scope.
  • Ask for feedback when a name is unclear.

Vocabulary Rules

  • Use fetch for API requests.
  • Use get for selectors or local state retrieval.
  • Use create, edit, delete instead of add/modify/remove.

Example:

fetchUsers(); // API request
getUsers(); // selector or local state

Paths and Imports

  • Never use relative path imports like ../../.
  • Use path aliases (for example, @/) for internal imports.

Example:

import Button from "@/components/Button";
import { AUTH_ROUTES } from "@/shared/routes";

Function Design

  • Prefer object parameters over positional parameters.
  • Provide defaults for optional fields.
  • Validate required fields inside the function.
  • Use early returns to avoid deep nesting.

Example:

const updateUser = ({
id,
data,
}: {
id?: string;
data: Record<string, unknown>;
}) => {
if (!id) return { error: "MISSING_ID" };
// update logic
};

Data Handling

  • Do not mutate input objects directly. If you need to change input, copy it first.
  • Avoid returning raw API responses. Destructure and return only what you need.
  • Use object destructuring to avoid repeated nested access.

Included Example Patterns

const createFullName = ({
firstName,
lastName,
}: {
firstName?: string;
lastName?: string;
}) => {
if (!firstName && !lastName) return "";
return [firstName, lastName].filter(Boolean).join(" ");
};
const { info: participantInfo } = participant;
const { name, email, address, phoneNumber } = participantInfo;

Object vs Boolean Naming

Bad:

const findApplicant = await ApplicantsModel.findOne({ id });
if (!findApplicant) return "error";

Good:

const applicant = await ApplicantsModel.findOne({ id });
if (!applicant) return "error";