eslint-json

raw JSON →
2.0.0 verified Sat Apr 25 auth: no javascript

JSON reporter for ESLint that outputs lint results as a JSON array. Version 2.0.0, stable, low maintenance. Key differentiator: simplifies piping ESLint output to other tools (e.g., CI, custom scripts) by using standard JSON format. No breaking changes since initial release. Commonly used in build pipelines. Lightweight with zero dependencies.

error Error: Cannot find module 'eslint-json'
cause Module not installed or path incorrect.
fix
npm install --save-dev eslint-json and use full path: eslint --format=./node_modules/eslint-json file.js
error TypeError: formatter is not a function
cause Using wrong require pattern (e.g., import from ESM).
fix
Use require('eslint-json') and call as function: formatter(results, config);
error TypeError: results is not iterable
cause Passed entire report object instead of results array.
fix
Use report.results (the array) as first argument.
gotcha Must pass results array as first argument, not the full report object.
fix Use report.results (array) instead of report (object).
gotcha The formatter output is a string, not a JavaScript object. Must JSON.parse before using as object.
fix const output = JSON.parse(formatter(results, config));
gotcha When using ESLint CLI, the format path must be exactly 'node_modules/eslint-json' or full path; relative path may fail if cwd is not project root.
fix Use absolute path or 'node_modules/eslint-json'.
npm install eslint-json
yarn add eslint-json
pnpm add eslint-json

Demonstrates how to programmatically use eslint-json to format ESLint results as JSON.

const eslint = require('eslint');
const formatter = require('eslint-json');
const cli = new eslint.CLIEngine({});
const report = cli.executeOnFiles(['index.js']);
const jsonOutput = formatter(report.results, report.config);
console.log(jsonOutput);