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

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

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

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

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

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

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

## 中文简介

CSpell 的 CUnit XML 记者

## 安装

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

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

## README

# `@cspell/cspell-junit-reporter`

> 带有 JUnit XML 输出的 CSpell 通讯员

提供a [J单位](https://github.com/testmoapp/junitxml) 兼容的 Cspell 运行的 XML 报告,适合 理解 JUnit 测试的 CI 系统(GitHub Actions, GitLab, Jenkins, CircleCI等)的消费 结果格式.

## 安装

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

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

## 使用量

### 使用命令行

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

### 使用 CSpell 配置

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

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

或者说 `cspell.json`

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

## 输出格式

`@cspell/cspell-junit-reporter` 将 cspell 运行到 JUnit XML 的地图如下 :

-   一个 `<testsuites>` 整个运行的根元素
-   一个 `<testsuite>` 每个文件检查, 以文件命名
-   一个 `<testcase>` 每个在文件中找到的拼写问题,包含一个 `<failure>` 用拼错的字, 地点和消息
-   没有问题的文件只能通过 `<testcase>` 这样套房就不会空了
-   跳过的文件获得一个单 `<testcase>` 包含一个 `<skipped>` 元素
-   处理不与特定拼写问题相绑定的错误( 例如, 错误的配置文件) 是 专门报告 `cspell-errors` 使用测试软件 `<error>` 改为 `<failure>`

所有文件路径、单词和信件都会被逃脱,所以输出即使包含 XML 也是合法的 `& < > " '` 字符键.

单个文件的示例输出, 包含一个问题:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="cspell" tests="1" failures="1" errors="0" time="0.001">
  <testsuite name="src/example.ts" tests="1" failures="1" errors="0" time="0.001">
    <testcase name="teh (3:5)" classname="src/example.ts">
      <failure type="spelling" message="Unknown word: &quot;teh&quot;">Unknown word: "teh"</failure>
    </testcase>
  </testsuite>
</testsuites>
```

## 设置

可能的设置 :

-   `outFile` (默认: stdout) - XML 文件发出路径
-   `suiteName` (默认 : `cspell`) - 根所使用的名称 `<testsuites>` 元素

记者设置

```ts
/**
 * cspell-junit-reporter settings type definition
 */
export type CSpellJUnitReporterSettings = {
  /**
   * Path to the output JUnit XML file.
   *
   * Relative paths are relative to the current working directory.
   *
   * Special values:
   * - `stdout` - write the XML to `stdout`.
   * - `stderr` - write the XML to `stderr`.
   *
   * @default stdout
   */
  outFile?: string;
  /**
   * Name to use for the root `<testsuites>` element.
   *
   * @default cspell
   */
  suiteName?: string;
};
```

## 常见问题

### @cspell/cspell-junit-reporter 是什么？

CSpell 的 CUnit XML 记者

### 如何安装 @cspell/cspell-junit-reporter？

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

### @cspell/cspell-junit-reporter 支持 TypeScript 吗？

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

### @cspell/cspell-junit-reporter 支持 ESM 还是 CommonJS？

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

### @cspell/cspell-junit-reporter 需要什么版本的 Node\.js？

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

### @cspell/cspell-junit-reporter 可以商用吗？

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

### @cspell/cspell-junit-reporter 的下载量有多少？

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

### @cspell/cspell-junit-reporter 还在维护吗？

最新版本 10\.4\.1 发布于 2026/11/07（4 天前）；至今共发布 26 个版本，其中过去 12 个月发布了 26 个；首次发布于 2026/08/22。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

