eslint-formatter-html

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

A enhanced ESLint formatter that outputs HTML reports with interactive features built on React and Ant Design. Version 2.7.3 is stable and actively maintained. It supports dark mode, ANSI code display, and file path/line copying. Unlike ESLint's built-in HTML formatter, it uses pako compression for small file sizes and relative file paths for brevity. The package is released irregularly but receives updates.

error Error: Cannot find module 'eslint-formatter-html'
cause Missing dependency or using wrong formatter name in ESLint config.
fix
Run npm install --save-dev eslint-formatter-html and use -f html (not the full package name).
error TypeError: formatter is not a function
cause Using default import in ESM context or calling a nonexistent named export.
fix
Use require('eslint-formatter-html') (CommonJS) or treat the default export as the function.
deprecated The 'format' export is deprecated; use default export instead.
fix Use `require('eslint-formatter-html')` directly instead of `require('eslint-formatter-html').format`.
gotcha The formatter expects the LintResult array exactly as returned by ESLint. Modifying the structure may cause errors.
fix Ensure you pass the raw results array from ESLint's API.
gotcha The output HTML file is self-contained but uses external CDN for React and Ant Design fonts (if not bundled).
fix No built-in offline support; ensure network access or modify the formatter to inline dependencies.
npm install eslint-formatter-html
yarn add eslint-formatter-html
pnpm add eslint-formatter-html

Shows how to use eslint-formatter-html programmatically to generate an HTML report from lint results.

// Install: npm i -D eslint-formatter-html
// Generate HTML report:
const { ESLint } = require('eslint');
const formatter = require('eslint-formatter-html');

async function main() {
  const eslint = new ESLint();
  const results = await eslint.lintFiles(['src/**/*.js']);
  const html = formatter(results); // results is array of LintResult
  require('fs').writeFileSync('report.html', html);
  console.log('Report saved to report.html');
}
main().catch(err => console.error(err));