ESLint Friendly Formatter

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

An ESLint formatter that displays file paths with line/column numbers clickable in terminals like iTerm2, Sublime Text, and Guake. Version 7.0.0 is current. It aggregates errors at the end, shows rule IDs as clickable links to documentation, and provides a summary of offended rules. Unlike the default 'stylish' formatter, it adds context lines around errors and integrates well with editors that support the 'file:line:column' pattern. It is the recommended formatter for developer-friendly linting output in terminal-based editors.

error Error: Cannot find module 'eslint-formatter-friendly'
cause Package not installed or not in node_modules.
fix
Run 'npm install eslint-formatter-friendly --save-dev'.
error TypeError: formatter is not a function
cause Incorrect import usage; may have imported default as object instead of function.
fix
Use 'const formatter = require("eslint-formatter-friendly");' or 'import formatter from "eslint-formatter-friendly";'.
error Error: Invalid format output
cause Passing wrong data structure (e.g., report object instead of results array).
fix
Call formatter(report.results) where report is from CLIEngine.executeOnFiles.
gotcha The formatter expects results array directly from ESLint's CLIEngine.executeOnFiles or ESLint.lintFiles. Passing a different structure may cause errors.
fix Ensure results is the array from ESLint report.results.
gotcha Clickable file links require proper terminal emulator support (iTerm2, Guake, etc.) and appropriate editor configuration.
fix Configure your terminal to associate file URIs with your editor (e.g., Sublime Text).
deprecated The package uses CommonJS and is not ESM-first. Future versions may switch to ESM, causing import changes.
fix Use dynamic import or remain on CommonJS until ESM is stable.
gotcha When using with gulp-eslint, the formatter must be applied to the results array, not piped directly.
fix Use friendlyFormatter(results) after eslint.lintText or eslint.result.
breaking Version 7.0.0 removed support for Node.js versions < 10. Previously supported Node 0.10+. Check your Node version.
fix Update to Node >=10 or use older version (<7.0.0).
npm install eslint-formatter-friendly
yarn add eslint-formatter-friendly
pnpm add eslint-formatter-friendly

Shows how to use the formatter programmatically with ESLint's CLIEngine. It processes files and outputs formatted results.

import { CLIEngine } from 'eslint';
import formatter from 'eslint-formatter-friendly';

const engine = new CLIEngine({});
const report = engine.executeOnFiles(['src/**/*.js']);
const results = report.results || [];
const output = formatter(results);
console.log(output);