Formatters
ESLint formatters control the appearance of linting results in the CLI. ESLint comes with several built-in formatters and supports third-party formatters as well.Using Formatters
Specify a formatter using the--format or -f flag:
The default formatter is
stylish, which provides human-readable output with colors.Built-in Formatters
ESLint includes four built-in formatters:stylish
Default formatterHuman-readable with colors and context
json
JSON outputFor programmatic processing
json-with-metadata
JSON + metadataIncludes rule metadata
html
HTML reportVisual browser-based report
stylish (Default)
Thestylish formatter provides clean, readable output with color coding:
- Example Output
- Features
- Usage
Colors can be controlled with
--color and --no-color flags, or via environment variables like FORCE_COLOR, NO_COLOR, or NODE_DISABLE_COLORS.json
Outputs JSON-serialized results for programmatic processing:- Structure
- Properties
- Usage
json-with-metadata
Extends the JSON formatter with rule metadata:- Structure
- Metadata Fields
- Usage
html
Generates an interactive HTML report:- Features
- Usage
- Best For
Interactive HTML report with:
- Color-coded violations
- Sortable columns
- Filterable results
- File grouping
- Rule descriptions
- Click-to-expand details
- Summary statistics
- Professional styling
The HTML formatter is designed for viewing in a browser and includes all necessary CSS and JavaScript inline.
Saving Output to File
- Shell Redirection
- --output-file Flag
Custom Formatters
You can create and use custom formatters:Local Custom Formatter
1
Create formatter file
my-formatter.js
2
Use the formatter
NPM Package Formatter
1
Install formatter
2
Use the formatter
Formatter Context
Formatters receive two arguments:Results Array
Context Object
Comparing Formatters
- CLI Development
- CI/CD
- Reports
- Analysis
Best: stylish
- Human-readable
- Color-coded
- Quick scan of issues
- Shows line numbers
Popular Third-Party Formatters
eslint-formatter-pretty
eslint-formatter-pretty
Beautiful formatter with colors and context:Features:
- Syntax highlighting
- Code context
- File hyperlinks (VS Code, WebStorm)
- Summary statistics
eslint-formatter-table
eslint-formatter-table
Table-based output:Features:
- Tabular layout
- Column alignment
- Clear separation
- Sortable data
eslint-formatter-gitlab
eslint-formatter-gitlab
GitLab Code Quality format:Use for:
- GitLab CI/CD integration
- Code Quality widgets
- Merge request reports
eslint-formatter-codeframe
eslint-formatter-codeframe
Shows code context with pointers:Features:
- Code snippets
- Error pointers
- Detailed context
- Multiple lines
Example Workflow
- Development
- CI/CD
- Git Hooks
- Package Scripts
Best Practices
Choose the Right Formatter
Choose the Right Formatter
- Development:
stylishfor readability - CI/CD:
jsonfor processing - Reports:
htmlfor stakeholders - Analysis:
json-with-metadatafor tooling
Save Important Results
Save Important Results
Combine Formatters
Combine Formatters
Output to console AND file:
Format Warnings Separately
Format Warnings Separately
Related Resources
Command Line
CLI options including —format
Integrations
Editor and build tool integrations
Configuration
Configure ESLint for your project
Core Concepts
Understanding ESLint fundamentals