eslint-formatter-pretty
raw JSON → 7.1.0 verified Sat Apr 25 auth: no javascript
A pretty formatter for ESLint that provides aesthetically pleasing output with syntax highlighting, clickable hyperlinks for filenames and rule IDs, and severity-sorted results. Version 7.1.0 is the latest stable release, released in 2025, with a cadence of major breaking changes tied to Node.js version bumps. It ships TypeScript types and is maintained by Sindre Sorhus. Key differentiators: stylish output with inline codeblock styling, open-in-editor support for filenames, and rule doc links. Alternatives like `eslint-formatter-codeframe` focus on code frames without the visual polish.
Common errors
error SyntaxError: Unexpected token 'export' ↓
cause ESM-only package imported with require() in a CommonJS context.
fix
Use import() or set 'type': 'module' in package.json.
error Error: Cannot find module 'eslint' ↓
cause eslint is a peer dependency and must be installed separately.
fix
Run: npm install --save-dev eslint
error TypeError: eslintFormatterPretty is not a function ↓
cause Wrong import style (e.g., named import instead of default).
fix
Use: import eslintFormatterPretty from 'eslint-formatter-pretty';
Warnings
breaking v6 requires Node.js 18 and ESLint v9+. ESLint v8 users must stick to v5. ↓
fix If using ESLint <9, install eslint-formatter-pretty@5 instead.
breaking v7 drops Node.js 18 support; requires Node.js 20. ↓
fix Upgrade Node.js to 20 or use v6 which supports Node.js 18.
deprecated v5 is deprecated; it only receives critical security fixes. ↓
fix Upgrade to v6+ if using ESLint 9+, else stick with v5.
gotcha The package is ESM-only from v6 onwards; require() will fail. ↓
fix Use dynamic import() or add 'type': 'module' to package.json.
gotcha Clickable hyperlinks for filenames and rule IDs only work in terminals with hyperlink support (e.g., iTerm2, VSCode terminal). ↓
fix Use a compatible terminal or rely on standard text output.
Install
npm install eslint-formatter-pretty yarn add eslint-formatter-pretty pnpm add eslint-formatter-pretty Imports
- default wrong
const eslintFormatterPretty = require('eslint-formatter-pretty');correctimport eslintFormatterPretty from 'eslint-formatter-pretty'; - default (CommonJS)
import eslintFormatterPretty from 'eslint-formatter-pretty';
Quickstart
// Quick start: run ESLint with the pretty formatter
// Install: npm install --save-dev eslint eslint-formatter-pretty
// Then run: eslint --format=pretty src/
// Example to use programmatically:
import eslint from 'eslint';
import eslintFormatterPretty from 'eslint-formatter-pretty';
async function lintAndFormat() {
const engine = new eslint.ESLint();
const results = await engine.lintFiles(['src/']);
const formatted = eslintFormatterPretty(results);
console.log(formatted);
}
lintAndFormat().catch(console.error);