Yavio

Code Style

Formatting, linting, and TypeScript conventions

Yavio uses Biome for linting and formatting. A single biome.json at the repo root configures all packages.

Biome Configuration

SettingValue
Indent styleSpaces
Indent width2
Line width100 characters
Import sortingEnabled (alphabetical by module specifier)
Lint rulesRecommended preset
# Check formatting and lint
pnpm lint

# Auto-fix issues
pnpm lint:fix

TypeScript Conventions

  • Strict mode is enabled for all packages
  • No any — use typed alternatives. In tests, use as unknown as Type when needed.
  • No non-null assertions (!) — use as Type or proper null checks instead
  • ES2022 target — use modern JavaScript features
  • NodeNext modules — use .js extensions in imports for library packages

Naming Conventions

ContextConventionExample
Variables / functionscamelCasegetUserById, eventCount
Types / interfaces / componentsPascalCaseEventPayload, DocsLayout
ConstantsSCREAMING_SNAKE_CASEMAX_BATCH_SIZE, DEFAULT_PORT
Fileskebab-caseerror-handler.ts, batch-writer.ts
Test files*.test.tshealth.test.ts

Import Ordering

Biome enforces strict import sorting. Imports must be ordered alphabetically by module specifier, with @-scoped packages before relative imports:

import { createClient } from "@clickhouse/client";
import { sql } from "drizzle-orm";
import { YavioError } from "@yavio/shared/errors";
import { createApp } from "../src/app.js";

Error Handling

All errors use the YavioError class from @yavio/shared/errors. Never throw a bare Error in service code.

import { YavioError, ErrorCode } from "@yavio/shared/errors";

throw new YavioError(
  ErrorCode.INGEST.INVALID_API_KEY,
  "Invalid or revoked API key",
  401,
  { keyPrefix: key.slice(0, 12) },
);

Each service owns a range of error codes:

RangeService
YAVIO-1000–1999SDK
YAVIO-2000–2999Ingestion API
YAVIO-3000–3999Dashboard
YAVIO-4000–4999Intelligence
YAVIO-5000–5999Database
YAVIO-6000–6999CLI
YAVIO-7000–7999Infrastructure

Commit Messages

Use Conventional Commits:

feat(sdk): add .identify() method for user tracking
fix(ingest): handle malformed event payloads gracefully
docs: update self-hosting guide with TLS instructions
test(dashboard): add integration tests for funnel view

Format: type(scope): description — imperative mood, lowercase, no period.

Pull Request Process

  1. Fill out the PR template completely
  2. Ensure all CI checks pass (lint, type check, tests)
  3. Keep PRs focused — one feature or fix per PR
  4. Update documentation if your change affects public APIs
  5. A maintainer will review and may request changes

On this page