← Index
Source: docs/zsub/ProjectStyle.md (auto-generated by scripts/generate-docs-html.mjs — edit the .md, not this file)

Project Style

This document defines the naming rules for files, variables, etc. It also includes the principles related to all aspects of projects.

Coding Style

String Quoting

In our project, we use template literals (backticks ``) when string interpolation (using ${}) or multi-line strings are needed.

Example:

const name = 'John';
const age = 30;
const greeting = `Hello, my name is ${name} and I am ${age} years old.`;  // String interpolation
const message = `
  Hello, ${name}.
  Welcome to our website!
`;  // Multi-line string

For simple, static strings, we prefer single quotes (') as they are cleaner and avoid escaping double quotes.

Example:

const greeting = 'Hello, World!';
const name = 'John';

const quote = "It's a great day!";  // Contains single quotes
const jsonString = "{\"name\": \"John\", \"age\": 30}"; // JSON-style string using double quotes

Double quotes (") are used only when the string contains single quotes (to avoid escaping) or when working with JSON or HTML attributes, which conventionally use double quotes.

Example:

const quote = "It's a great day!";  // Contains single quotes
const jsonString = "{\"name\": \"John\", \"age\": 30}"; // JSON-style string using double quotes

Consistency is key, so we aim to follow these conventions throughout the codebase: use template literals where applicable, prefer single quotes for simple strings, and use double quotes only when necessary.

Solidity lint in VS Code

Column Limit

As of their latest coding standards, OpenZeppelin typically follows a 100-character limit per line for Solidity code. So, we use a 100-character limit per line.

File Name

Project Policy

Folder Structure

We follow the contract development structure used in the Ondo Finance project. Our contracts are organized into separate folders rather than having a single main contract file in the root directory.

Maintaining multiple repositories for different types of contracts can be cumbersome. Instead, we keep all contracts in one repository and categorize them into subfolders as follows:

contracts
├── external
└── lending

Solidity dependencies