@cspell/cspell-junit-reporter

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

JUnit XML reporter for CSpell

原始使用文档
文档目录6 节
  1. Installation
  2. Usage
  3. Using Command Line
  4. Using CSpell Configuration
  5. Output format
  6. Settings

@cspell/cspell-junit-reporter

CSpell reporter with JUnit XML output

Emits a JUnit compatible XML report of a cspell run, suitable for consumption by CI systems (GitHub Actions, GitLab, Jenkins, CircleCI, etc.) that understand the JUnit test result format.

Installation

Install it as a development package in the repository that will use it.

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

Usage

Using Command Line

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

Using CSpell Configuration

Add this to cspell.yaml:

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

or cspell.json

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

Output format

@cspell/cspell-junit-reporter maps a cspell run onto JUnit XML as follows:

  • one <testsuites> root element for the whole run
  • one <testsuite> per file checked, named after the file
  • one <testcase> per spelling issue found in a file, containing a <failure> with the misspelled word, location, and message
  • a file with no issues gets a single passing <testcase> so the suite is never empty
  • a skipped file gets a single <testcase> containing a <skipped> element
  • processing errors that are not tied to a specific spelling issue (for example, a bad config file) are reported in a dedicated cspell-errors testsuite using <error> instead of <failure>

All file paths, words, and messages are escaped so the output is valid XML even when they contain & < > " ' characters.

Example output for a single file with one issue:

<?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>

Settings

Possible settings:

  • outFile (default: stdout) - path for the XML file to emit
  • suiteName (default: cspell) - name used for the root <testsuites> element
Reporter Settings
/**
 * 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 是什么?

JUnit XML reporter for CSpell

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