Schema

The JSON Schema for the configuration file.

linecop v0.9.1 Manual

Manual contents

linecop schema prints the JSON Schema for .linecop.yaml. linecop generates the schema from the same types the binary parses, so it tracks the config model in that release.

The repository keeps the generated file at linecop-schema.json. Use it as the schema a YAML language server reads, or vendor a copy next to your config.

A starter file

linecop init writes a config with the default limit and a schema comment:

linecop init

# yaml-language-server: $schema=https://raw.githubusercontent.com/mlavrinenko/linecop/refs/tags/v0.9.1/linecop-schema.json
version: 1
default: 500

The comment points at the schema for the matching release tag. A YAML language server reads it and offers completion and validation for the file.

linecop init --no-schema writes the file without the comment. linecop init --schema URL embeds a custom URL instead.

A representative excerpt

linecop schema (excerpt)

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Config",
"description": "The linecop configuration, format version 1.",
"type": "object",
"properties": {
"version": {
"description": "The config format version; defaults to `1`.",
"type": "integer",
"format": "uint8",
"const": 1,
"default": 1,
"maximum": 255,
"minimum": 0
},
"count": {
"description": "What the file gauge counts: `total` (default), `code` or `code-comments`.",
"$ref": "#/$defs/Count",
"default": "total"
},
"root": {
"description": "The directory this config describes, relative to the config file.",
"type": [
"string",
"null"
],
"default": null
}
},
"$defs": {
"Count": {
"description": "What lines to count when checking caps.",
"oneOf": [
{
"description": "Count all lines (code + comments + blanks).",
"type": "string",
"const": "total"
},
{
"description": "Count only code lines.",
"type": "string",
"const": "code"
},
{
"description": "Count code + comment lines (exclude blanks).",
"type": "string",
"const": "code-comments"
}
]
}
}
}

The full file describes every measure, cap, group, rule, and scope. The version property pins the value to 1, and the count property refers to a shared definition with the three allowed values.

Use it in an editor

Point the language server at a local copy:

linecop schema > linecop-schema.json

Then set the comment at the top of .linecop.yaml:

# yaml-language-server: $schema=./linecop-schema.json
version: 1
default: 500

The generated file is an ordinary JSON Schema document. It works with any editor or validator that reads JSON Schema draft 2020-12.

After an upgrade

The schema is part of the release, so a new config key arrives with the release that reads it. Regenerate a vendored copy after an upgrade with the new binary, not with an older one.

The configuration page explains what each property does. The usage page covers the commands that read the file.