Canonical style and layering rules for MCP4OpenAPI. Prevails over all other style notes.
- Follow TypeScript 5.x and ES2022 conventions.
- Prefer clarity and explicitness over cleverness.
- All validation, business logic, and error handling must reference canonical docs (see AGENTS.md).
- Source code:
src/ - Tests: co-located as
*.test.tsor insrc/testing/for integration,tests/e2e/for E2E. - Types:
src/types/ - Profiles:
profiles/{api-name}/ - Scripts:
scripts/ - Documentation:
docs/
- Use
camelCasefor variables, functions, and methods. - Use
PascalCasefor types, classes, and interfaces. - File names:
kebab-case.tsfor modules,snake_case.jsonfor profiles. - Test files:
{module}.test.tsnext to the source or insrc/testing/.
- 2 spaces for indentation.
- Use single quotes
'for strings, except in JSON. - Always use trailing commas in multiline objects/arrays.
- Prefer
constoverletunless reassignment is required. - No semicolons at end of statements (unless required by parser).
- Use ES module syntax (
import/export). - Group imports: external modules first, then internal, then types.
- No default exports; always use named exports.
- Always type function arguments and return values.
- Prefer interfaces for object shapes, types for unions.
- Use
unknownoveranywhere possible. - Avoid non-null assertions (
!) unless absolutely necessary.
- Only use error types defined in
src/errors.ts. - Never throw ad-hoc strings or objects.
- All errors must be sanitized for secrets/tokens.
- No business logic in route/entry files (
index.ts). - Keep functions ≤ 40 lines; split logic into smaller helpers/services.
- Validation and transformation logic must be in dedicated modules.
- Never duplicate validation or business rules; always reference canonical docs.
- All comments in English.
- Use JSDoc for exported functions, classes, and complex logic.
- Document all public APIs and profile fields in
docs/.
- Each new validator must have both success and failure tests.
- No test skipping (
it.skip/describe.skip) in committed code. - Use fixtures from
src/testing/fixtures.tswhere possible.