ESLint Friendly Formatter

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

An ESLint formatter that produces output compatible with Sublime Text and iTerm2 'click to open file' functionality. Version 4.0.1 is the current stable release, with irregular updates. Key differentiators: file/line/column links that open in editors, clickable rule IDs linking to documentation, errors reported at end, and a summary with contextual code snippets. It is based on the default 'stylish' formatter but enhanced for terminal usability.

error Cannot find module 'eslint-friendly-formatter'
cause Module not installed or path incorrect when using --format in CLI.
fix
npm install --save-dev eslint-friendly-formatter; use --format ./node_modules/eslint-friendly-formatter/index.js
error formatter is not a function
cause Wrong import style in ESM/CJS interop (e.g., require().default not used).
fix
Use const formatter = require('eslint-friendly-formatter').default if needed; for CJS use require('eslint-friendly-formatter') directly.
breaking v4.0.0 changed from CommonJS to hybrid ESM/CJS, breaking direct require() without .default in some bundlers.
fix Use default import: import formatter from 'eslint-friendly-formatter' or use require('eslint-friendly-formatter').default if needed.
deprecated v3.x and earlier are deprecated; upgrading to v4+ may break existing CJS code.
fix Update to v4.0.0 or later and adjust imports as needed.
gotcha Clickable file links only work in terminals that support URIs like iTerm2 or Sublime Text; not all terminals.
fix Test in your target terminal; configure editor to handle 'file://' URIs.
gotcha Formatter does not handle eslint --fix output; only displays messages.
fix Use ESLint's --fix separately; this formatter only displays results.
npm install eslint-friendly-formatter
yarn add eslint-friendly-formatter
pnpm add eslint-friendly-formatter

Demonstrates using eslint-friendly-formatter to format ESLint results for console output with clickable file links.

const formatter = require('eslint-friendly-formatter');
const results = [
  {
    filePath: 'src/index.js',
    messages: [
      {
        ruleId: 'no-unused-vars',
        severity: 2,
        message: 'foo is defined but never used',
        line: 5,
        column: 10,
        nodeType: 'Identifier',
      },
    ],
    errorCount: 1,
    warningCount: 0,
    fixableErrorCount: 0,
    fixableWarningCount: 0,
    source: 'const foo = 1;',
  },
];
const output = formatter(results);
console.log(output);