# @cspell/cspell-json-reporter 中文文档

规范地址：https://npmcn.com/package/%40cspell/cspell-json-reporter/

版本：10\.4\.1
npm 元数据更新时间：2026-11-06T17:19:37.807Z
中文译文更新时间：2026-11-11T03:12:04.853Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40cspell/cspell-json-reporter
原文对照：https://npmcn.com/package/%40cspell/cspell-json-reporter/?lang=original
项目主页：https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-json-reporter#readme
源码仓库：https://github.com/streetsidesoftware/cspell

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：13.4 kB，13 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- Node.js 要求：\>=22\.18\.0
- 运行依赖：1 个
- 首次发布：2021-09-13T09:15:45.186Z
- 最新版本发布：2026-11-06T17:19:37.388Z
- 近 30 天下载量：7047412（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：273（近 12 个月 39 个）

## 中文简介

CSpell 的 JSON 记者

## 安装

```sh
npm install @cspell/cspell-json-reporter
```

也可以使用：`pnpm add @cspell/cspell-json-reporter`、`yarn add @cspell/cspell-json-reporter`、`bun add @cspell/cspell-json-reporter`

## README

# `@cspell/cspell-json-reporter`

> 带有 JSON 输出的 CSpell 记者

## 安装

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

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

## 使用量

### 使用命令行

```sh
cspell . --reporter @cspell/cspell-json-reporter
```

### 使用 CSpell 配置

将此添加到 `cspell.yaml`数字 :

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

或者说 `cspell.json`

```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 输出定义

```ts
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` (默认: 假) - 允许保存文件进度日志

记者设置

```ts
/**
 * 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 是什么？

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 和提交记录判断。

