KScript 文档
ZH

编码代理

JSON 诊断信息

kscript check --output json 输出一个 JSON 文档,因此代理无需解析文本即可修复问题:

JSON
{
  "files": 1,
  "errors": 0,
  "warnings": 1,
  "problems": [
    {
      "file": "main.kscript",
      "line": 2, "column": 8, "end_line": 2, "end_column": 15,
      "severity": "warning",
      "code": "KS6005",
      "message": "slugify is imported but never used.",
      "fixes": [
        { "title": "Remove the import", "edits": [ { "line": 2, "column": 1, "end_line": 2, "end_column": 43, "new_text": "" } ] }
      ]
    }
  ]
}

行号和列号从 1 开始,每个范围的结束位置恰好位于其最后一个字符之后。修复(fix)与编辑器提供的快速修复相同:从最后一条编辑到第一条依次应用,这样较前面的位置保持正确。涉及其他文件的修复(例如将类型移动到 types/)还带有 files:每项都是 { "action": "create", "path": ..., "contents": ... }、{ "action": "edit", "path": ..., "edits": [...] } 或 { "action": "rename", "path": ..., "new_path": ... },需在其自身的编辑之前应用。退出码与文本输出一致:没有错误时为 0,有错误(或使用 --warnings-as-errors 时有警告)时为 1,用法错误时为 2,此时 JSON 为 { "error": "..." }。

Edit this page on GitHub