Code style and contribution conventions for @interop/ezcap. Coding agents
receive this file via the include in AGENTS.md.
- Preserve existing comments and formatting
- Avoid using the character
→in the code, usetoinstead. - Avoid mdashes, use
--instead. - Avoid the character
…, use...instead.
- Use
camelCasefor variables, functions, and properties;PascalCasefor classes - Avoid single-letter variable names — use descriptive names (e.g.
errnote,chunknotc)
- Prefer named
async functiondeclarations over arrow functions at module level - Export functions and classes inline (
export async function ...,export class ...)
- Use
node:prefix for Node.js built-in imports (e.g.import fs from 'node:fs') - Group imports: Node.js built-ins first, then external packages, then local modules
- Use named imports; avoid default imports where possible
- Pass related arguments as a single options object and destructure in the
signature:
export async function exportKey({ publicKey, secretKey }) { ... }
- If an options/arguments type is only used once (i.e. twice, counting its own definition), inline it at the function/method signature instead of declaring a named interface/type.
- If a type/interface only has a single field, inline it at the usage site rather than declaring a named interface/type.
Use multi-line @param options style, documenting each property on its own
line:
/**
* @param options {object}
* @param options.methodId {string}
* @param [options.contentType] {string} ← square brackets for optional params
*/Do not use the inline @param {{ prop: type }} style. Use @returns {type}
whenever possible.
- Use
err(note) as the catch variable name - Handle specific error codes explicitly (e.g.
err.code === 'ENOENT') before re-throwing - Prefer
new Error(message, { cause })over mutating an error's.cause
-
Use
/** */JSDoc-style block comments for file, class, and function headers (including the one-paragraph "what this file does" header at the top of a module). -
Always use the multi-line form for
/** */blocks, even for a single sentence — never the collapsed/** text */form:/** * Correct: multi-line even when the comment is one line. */ /** Wrong: collapsed single-line form. */
-
Use
//only for short one- or two-line inline comments. -
Do not put "See AGENTS.md ..." cross-references inside code comments; keep pointers to the spec/docs in the README and AGENTS.md.
With TypeScript carrying the types, keep JSDoc focused on describing the public API (it is the API documentation source).