vfile-reporter: Report Generator

8.1.1 · active · verified Sun Apr 19

vfile-reporter is a utility package within the vfile ecosystem, designed to generate human-readable textual reports from one or more vfile instances. These reports summarize messages (warnings, errors, and info) that occurred during file processing, mimicking the output of tools like ESLint or esbuild. The current stable version is 8.1.1. The package maintains an active release cadence, with minor updates addressing fixes and features, and major versions typically aligning with Node.js LTS updates or breaking changes in its core dependency, `vfile`. Key differentiators include its tight integration with the vfile specification, extensive configuration options for output customization (e.g., color, verbosity, quiet/silent modes), and its role as a standard reporting mechanism for unified (remark, rehype, etc.) processors.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates creating multiple VFiles, adding messages to them, and then generating a formatted, human-readable report using `vfile-reporter` with verbose options.

import { VFile } from 'vfile';
import { reporter } from 'vfile-reporter';

// Create some VFile instances
const fileOne = new VFile({
  path: 'src/module-a.js',
  value: 'console.log(\"Hello\")'
});
const fileTwo = new VFile({
  path: 'src/module-b.js',
  value: 'const x = 1;'
});

// Add messages to fileOne
fileOne.message('This is a warning!', { line: 1, column: 9 }, 'linter:warning-id');
fileOne.message('Another issue at line 2.', 2);

// Use the reporter to generate a report for both files
// console.error is often used for reports to stderr
const report = reporter([fileOne, fileTwo], { verbose: true });
console.error(report);

/* Expected output (may vary slightly based on environment):
src/module-a.js
  1:9  warning  This is a warning!  linter:warning-id
  2:1  warning  Another issue at line 2.

src/module-b.js: no issues found

⚠ 2 warnings
*/

view raw JSON →