@cspell/cspell-json-reporter
带有 JSON 输出的 CSpell 记者
安装
将其安装为将使用它的数据库中的开发软件包 .
npm install -SD @cspell/cspell-json-reporter
使用量
使用命令行
cspell . --reporter @cspell/cspell-json-reporter
使用 CSpell 配置
将此添加到 cspell.yaml数字 :
reporters: [['@cspell/cspell-json-reporter', { outFile: 'out.json' }]]
或者说 cspell.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 输出定义
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(默认: 假) - 允许保存文件进度日志
记者设置
/**
* 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;
};