For the complete documentation index, see llms.txt. This page is also available as Markdown.

Code Style

This guide defines coding standards and best practices for the vCon MCP Server project.

Table of Contents


TypeScript Style

General Principles

  1. Type Safety First - No any types except where absolutely necessary

  2. Explicit Over Implicit - Be clear about types and intentions

  3. Functional When Possible - Prefer pure functions

  4. DRY Principle - Don't Repeat Yourself

Type Annotations

Interfaces vs Types

Use interface for object shapes that may be extended:

Use type for unions, intersections, and non-object types:

Optional Properties

Enums vs Union Types

Prefer union types over enums:

Async/Await

Always use async/await over promises:

Arrow Functions

Use arrow functions for callbacks and short functions:

Use regular functions for methods and top-level functions:

Destructuring

Use destructuring when accessing multiple properties:

Template Literals

Use template literals over string concatenation:


Naming Conventions

General Rules

  • Use camelCase for variables, functions, and properties

  • Use PascalCase for classes, interfaces, and types

  • Use UPPER_SNAKE_CASE for constants

  • Use kebab-case for file names

Files

Variables and Functions

Classes and Interfaces

Constants

Boolean Variables

Prefix with is, has, should, or can:

Function Names

Use verbs for function names:


File Organization

Project Structure

File Structure

Each file should follow this order:

Imports

Exports


Comments and Documentation

JSDoc Comments

All public APIs must have JSDoc comments:

Inline Comments

Use sparingly for complex logic:

TODO Comments

Always include context and assignee:

Section Comments

Use for major sections:


Error Handling

Try-Catch Blocks

Custom Errors


Testing Style

Test Structure

Test Naming

Assertions


Git Practices

Commit Messages

Follow Conventional Commits:

Commit Size

Keep commits focused and atomic:

Branch Names


Linting and Formatting

ESLint Configuration

The project uses ESLint with TypeScript support. Key rules:

Running Linters

Pre-commit Hooks

We use Husky for git hooks:


Review Checklist

Before submitting code for review:


Additional Resources


Questions about code style? Ask in GitHub Discussions or check existing code for examples.

Last updated