Guide

Schema declarations

Every file can declare its own schema. For files that can't (or shouldn't) carry a $schema, config-level associations have you covered.

JSON family

{
  "$schema": "./schema.json",
  "name": "example"
}
{
  // JSONC and JSON5 use the same root property
  "$schema": "./schema.json",
  "name": "example",
}

JSON, JSONC, and JSON5 use the conventional root $schema property. JSON Lines files are validated one non-empty line at a time, so cover .jsonl and .ndjson files with a config association, CLI association, or catalog match.

YAML

# yaml-language-server: $schema=./schema.json
name: example
$schema: ./schema.json
name: example

The comment directive follows the YAML Language Server convention. DollarLint scans the first 25 lines for it before looking for a root $schema key.

TOML

#:schema ./schema.json
name = "example"
"$schema" = "./schema.json"
name = "example"

The comment directive follows the Taplo and Even Better TOML convention. A root $schema key also works, but it must be quoted because $ is not a bare TOML key character.

Config associations

When you can't — or don't want to — add a declaration to each file, associations let you cover them from your config instead.

[[schemas.associations]]
file = "*.jsonl"
schema = "./schemas/event.schema.json"

Association globs are matched against each discovered file's path relative to the validation root. Like discovery globs, a pattern without a slash can match a basename at any depth.

Precedence order: in-file declaration first, then config association, then DollarLint's built-in .dollarlint.toml association, then catalog match. If none of those hit, the file gets skipped unless schemas.requireCoverage = true.