@cspell/cspell-junit-reporter

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

CSpell 的 CUnit XML 记者

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

@cspell/cspell-junit-reporter

带有 JUnit XML 输出的 CSpell 通讯员

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

安装

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

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

使用量

使用命令行

cspell . --reporter @cspell/cspell-junit-reporter

使用 CSpell 配置

将此添加到 cspell.yaml数字 :

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

或者说 cspell.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 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> 元素
记者设置
/**
 * 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 共发布 26 个版本,首次发布于 2026/08/22;过去 12 个月发布了 26 个版本。最新版本附带 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 个月前

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

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