1. @cspell/cspell-json-reporter
JSON reporter for CSpell
@cspell/cspell-json-reporter
Package: @cspell/cspell-json-reporter
Created by: streetsidesoftware
Last modified: Wed, 10 Apr 2024 13:04:03 GMT
Version: 8.7.0
License: MIT
Downloads: 1,372,282
Repository: https://github.com/streetsidesoftware/cspell

Install

npm install @cspell/cspell-json-reporter
yarn add @cspell/cspell-json-reporter

@cspell/cspell-json-reporter

CSpell reporter with JSON output

Installation

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

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

Usage

Using Command Line

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

Using CSpell Configuration

Add this to cspell.yaml:

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

or cspell.json

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

Output file format

@cspell/cspell-json-reporter emits a JSON file with the following fields:

  • issues - found spelling issues
  • result - CSpell linting results
  • error - CSell error messages
  • progress - file linting progress messages if settings.progress is enabled
  • info - CSpell execution logs if settings.verbose is enabled
  • debug - CSpell debug logs if settings.debug is enabled
JSON Output Definition
 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;
};

Settings

Possible settings:

  • outFile (default: stdout) - path for JSON file to emit
  • verbose (default: false) - enable saving of execution logs
  • debug (default: false) - enable saving of debug logs
  • progress (default: false) - enable saving of file progress logs
Reporter Settings
 /**
 * 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
   * @default false
   */
  verbose?: boolean;
  /**
   * Add information useful for debugging cspell.json files
   * @default false
   */
  debug?: boolean;
  /**
   * Add progress messages
   * @default false
   */
  progress?: boolean;
};

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code