| name | comments |
| description | Comment conventions for Trezor Suite — prefer self-documenting code, and how to write and format a comment when one is actually needed. Use when writing or reviewing code comments. |
Comments
Prefer self-documenting code
The best comment is usually no comment. A clear name says more than a line explaining an unclear one, so reach for a comment only when the code genuinely can't speak for itself.
const b = getBalance(account);
const accountBalance = getBalance(account);
Comment the why, not the what
When you do comment, explain intent, edge cases, or non-obvious reasoning — things the code cannot express on its own.
index += 1;
const fee = normalizeFee(rawFee, firmwareVersion);
Start with an uppercase letter and end with a period
Applies to every comment, single- or multi-line.
const someFunction = () => null;
Multiline comments
Stack // lines and wrap at the print width. Capitalize only the first line and end only the last line with a period.
const debouncedSearch = useDebounce(search, 300);
Reserve /** */ JSDoc blocks for documenting exported APIs, where editors surface the description on hover.
export const formatAmount = (amount: string, decimals: number) => {
};
Comments in components (JSX)
Inside JSX, wrap comments in {/* */} and place them above the element they describe. The uppercase-and-period rule still applies.
export const AccountBalance = ({ account, isLoading }: AccountBalanceProps) => (
<Row>
{/* Skeleton keeps the layout stable while the balance loads. */}
{isLoading ? <Skeleton /> : <Balance value={account.balance} />}
</Row>
);
Multiline JSX comments keep the same wrapping rules:
{
}