@cspell/cspell-json-reporter

中文文档
10.4.1发布于 2026/11/07MITTypeScriptES Module构建来源已验证近 30 天下载 704.7万

CSpell 的 JSON 记者

中文使用文档
文档目录6 节
  1. 安装
  2. 使用量
  3. 使用命令行
  4. 使用 CSpell 配置
  5. 输出文件格式
  6. 设置

@cspell/cspell-json-reporter

带有 JSON 输出的 CSpell 记者

安装

将其安装为将使用它的数据库中的开发软件包 .

npm install -SD @cspell/cspell-json-reporter

使用量

使用命令行

cspell . --reporter @cspell/cspell-json-reporter

使用 CSpell 配置

将此添加到 cspell.yaml数字 :

reporters: [['@cspell/cspell-json-reporter', { outFile: 'out.json' }]]

或者说 cspell.json

{
  "reporters": [["@cspell/cspell-json-reporter", { "outFile": "out.json" }]]
}

输出文件格式

@cspell/cspell-json-reporter 发布 JSON 文件, 包含以下字段 :

  • issues - 发现拼写问题
  • result - CSpell 滴入结果
  • error - CSpell 错误消息
  • progress - 文件林入进度消息,如果 settings.progress 已启用
  • info - 如果 settings.verbose 已启用
  • debug - CSpell 调试日志,如果 settings.debug 已启用
JSON 输出定义
import type {
  ErrorLike,
  Issue,
  MessageType,
  ProgressFileComplete,
  ProgressItem,
  RunResult
} from '@cspell/cspell-types';

export type CSpellJSONReporterOutput = {
  /**
   * Found spelling issues
   */
  issues: Array<Issue>;
  /**
   * CSpell execution logs
   */
  info?: Array<{ message: string; msgType: MessageType }>;
  /**
   * CSpell debug logs
   */
  debug?: Array<{ message: string }>;
  /**
   * CSpell error logs
   */
  error?: Array<{ message: string; error: ErrorLike }>;
  /**
   * CSpell file progress logs
   */
  progress?: Array<ProgressItem | ProgressFileComplete>;
  /**
   * Execution result
   */
  result: RunResult;
};

设置

可能的设置 :

  • outFile (默认: stdout) - JSON 文件的发出路径
  • verbose (默认: 假) - 允许保存执行日志
  • verboseLevel - 动词水平(高数字=更动词)
  • debug (默认: 假) - 允许保存调试日志
  • progress (默认: 假) - 允许保存文件进度日志
记者设置
/**
 * CSpell-json-reporter settings type definition
 */
export type CSpellJSONReporterSettings = {
  /**
   * Path to the output file.
   *
   * Relative paths are relative to the current working directory.
   *
   * Special values:
   * - `stdout` - write the JSON to `stdout`.
   * - `stderr` - write the JSON to `stderr`.
   *
   * @default stdout
   */
  outFile?: string;
  /**
   * Add more information about the files being checked and the configuration
   */
  verbose?: boolean;
  /**
   * Level of verbosity (higher number = more verbose).
   */
  verboseLevel?: number;
  /**
   * Add information useful for debugging cspell.json files
   * @default false
   */
  debug?: boolean;
  /**
   * Add progress messages
   * @default false
   */
  progress?: boolean;
};

版本与发布记录

@cspell/cspell-json-reporter 共发布 273 个版本,首次发布于 2021/09/13;过去 12 个月发布了 39 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
10.4.1latest2026/11/074 天前
10.4.02026/10/1427 天前
10.4.0-alpha.1next2026/10/011 个月前
10.3.62026/09/291 个月前
10.3.52026/09/281 个月前
10.3.42026/09/251 个月前

其他发布通道:cspell5-next → 5.21.2-alpha.0,cspell5 → 5.21.2,next → 10.4.0-alpha.1。

关于 @cspell/cspell-json-reporter 的常见问题

@cspell/cspell-json-reporter 是什么?

CSpell 的 JSON 记者

如何安装 @cspell/cspell-json-reporter?

在项目目录运行 npm install @cspell/cspell-json-reporter,或使用 pnpm add / yarn add / bun add。

@cspell/cspell-json-reporter 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cspell/cspell-json-reporter 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cspell/cspell-json-reporter 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.18.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@cspell/cspell-json-reporter 可以商用吗?

@cspell/cspell-json-reporter 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cspell/cspell-json-reporter 的下载量有多少?

根据 npm 官方下载统计,@cspell/cspell-json-reporter 在 2026/10/11 – 2026/11/09 这 30 天内被下载 7,047,412 次,日均约 234,914 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cspell/cspell-json-reporter 还在维护吗?

最新版本 10.4.1 发布于 2026/11/07(4 天前);至今共发布 273 个版本,其中过去 12 个月发布了 39 个;首次发布于 2021/09/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。