{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://raw.githubusercontent.com/kylepantall/kscript/master/editors/vscode/schemas/kscript-standard.schema.json",
  "title": "KScript standard (kscript-standard.json)",
  "description": "A shareable set of lint rules and format settings. A project uses it with \"standard\" in kscript.json, and another standard can build on it with \"extends\". Later layers win: the standards it extends, then this one, then the project's kscript.json.",
  "type": "object",
  "additionalProperties": false,
  "definitions": {
    "standardReference": {
      "type": "string",
      "anyOf": [{ "enum": ["kscript:recommended", "kscript:strict"] }, { "pattern": "^(?!kscript:)" }],
      "description": "kscript:recommended, kscript:strict, or a path (relative to this file) to a standard file or a folder holding kscript-standard.json."
    }
  },
  "properties": {
    "$schema": { "type": "string" },
    "name": { "type": "string", "description": "The standard's name, shown by kscript check --print-config." },
    "description": { "type": "string", "description": "What the standard is for." },
    "extends": {
      "description": "Standards this one builds on. They are applied first, so this one's settings win. Without extends, a standard starts from the built-in defaults, where style rules (KS6xxx) are off: extend kscript:recommended to keep them.",
      "oneOf": [
        { "$ref": "#/definitions/standardReference" },
        { "type": "array", "items": { "$ref": "#/definitions/standardReference" } }
      ],
      "examples": ["kscript:recommended"]
    },
    "lint": {
      "type": "object",
      "description": "Lint rules this standard sets. Which files are checked (include, exclude) belongs in each project's kscript.json.",
      "additionalProperties": false,
      "properties": {
        "rules": {
          "type": "object",
          "description": "Severity per diagnostic code (KS3003) or code prefix (KS3*). The longest match wins.",
          "propertyNames": { "pattern": "^[Kk][Ss][0-9]{0,4}\\*?$" },
          "additionalProperties": { "enum": ["off", "hint", "info", "warning", "error"] },
          "examples": [{ "KS3003": "off", "KS4*": "error" }]
        },
        "warnings_as_errors": { "type": "boolean", "default": false, "description": "Make kscript check fail on warnings too (same as --warnings-as-errors)." }
      }
    },
    "format": {
      "type": "object",
      "description": "Format settings this standard sets. Which files are formatted (include, exclude) belongs in each project's kscript.json.",
      "additionalProperties": false,
      "properties": {
        "enabled": {
          "type": "boolean",
          "default": true,
          "description": "false turns formatting off for the project: kscript fmt skips its files and Format Document makes no changes."
        },
        "rules": {
          "type": "object",
          "description": "Turn individual formatting rules off, e.g. { \"statement_per_line\": false }. Every rule is on unless listed. To leave part of a file alone, use <!-- kscript-fmt: off --> ... <!-- kscript-fmt: on --> or <!-- kscript-fmt-ignore --> before an element.",
          "additionalProperties": false,
          "properties": {
            "indent": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": "Re-indent elements by how deeply they are nested. Off: lines keep their indentation." },
            "statement_per_line": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": "Put each statement and block-level element on its own line. Off: line breaks only change where there was already whitespace." },
            "tidy_tags": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": "One space between attributes, and <x /> for self-closing tags. Off: start tags are kept exactly as written." },
            "wrap_attributes": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": "One attribute per line for long start tags and tags already written that way. Off: tags are never wrapped or joined." },
            "trim_trailing_whitespace": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": "Remove spaces at the ends of lines of text." },
            "collapse_blank_lines": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": "Shrink runs of blank lines to max_blank_lines." },
            "final_newline": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": "End the file with exactly one newline. Off: the file ends as it did." },
            "spacing": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": ".kscript files: one space after commas and colons, around assignments and =>, and before a block's '{'. Off: spacing inside lines is kept." },
            "brace_style": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": ".kscript files: put else, elif, catch and finally on the line of the closing '}'. Off: they stay where they are." },
            "wrap_strings": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": ".kscript files: break a string that runs past print_width at a space, with a \\ at the end of the line (the break isn't part of the string). Off: long strings stay on one line." },
            "wrap_chains": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": ".kscript files: a -> chain or |> pipe that runs past print_width puts each call on its own line, indented under where the chain starts. Off: chains stay on one line." },
            "wrap_bodies": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": ".kscript files: a one-line function (fn name() => body) that runs past print_width moves its body to the next line. Off: it stays on one line." },
            "wrap_comments": { "type": ["boolean", "string"], "enum": [true, false, "on", "off"], "default": true, "description": ".kscript files: a // or /// comment line that runs past print_width is broken between words onto a new comment line. Off: comments stay as written." }
          }
        },
        "indent": {
          "oneOf": [{ "type": "integer", "minimum": 1, "maximum": 16 }, { "const": "tab" }],
          "default": 2,
          "description": "Spaces per indent level, or \"tab\" to indent with tabs."
        },
        "tab_width": {
          "type": "integer",
          "minimum": 1,
          "maximum": 16,
          "default": 2,
          "description": "With \"indent\": \"tab\", how many columns a tab counts as when lining up existing text."
        },
        "print_width": {
          "type": "integer",
          "minimum": 20,
          "default": 80,
          "description": "The longest a line should be (80 by default). Longer lines are wrapped: a start tag gets one attribute per line, and in .kscript files a long call, chain, one-line function, string or comment is broken onto more lines."
        },
        "max_blank_lines": {
          "type": "integer",
          "minimum": 0,
          "default": 1,
          "description": "Blank lines kept in a row; extra ones are removed."
        },
        "end_of_line": {
          "enum": ["auto", "lf", "crlf"],
          "default": "auto",
          "description": "Line endings to write. auto keeps the ones each file already uses."
        },
        "preserve": {
          "type": "array",
          "items": { "type": "string" },
          "default": [],
          "description": "Elements whose content is kept exactly as written, on top of <pre>, <textarea>, <script>, <style> and CDATA sections."
        }
      }
    }
  }
}
