Lesson 18 / 25
Reporting & Performance
Optimize ESLint performance and generate useful reports.
Performance tuning
ESLint can be slow on large codebases. Use --cache to skip unchanged files, and --max-warnings to treat warnings as errors when thresholds are exceeded.
Performance optimization
Cache linting results and generate reports for visibility.
# Use cache for faster linting
eslint . --cache
# Generate JSON report
eslint . --format json > lint-report.json
# Package.json scripts
"scripts": {
"lint": "eslint . --cache",
"lint:report": "eslint . --format json > lint-report.json",
"lint:html": "eslint . --format html > lint-report.html"
}
Output:
Cache and reporting configured
Clear cache regularly
ESLint cache can become stale. Clear it with rm .eslintcache or eslint . --cache --cache-location ./node_modules/.cache/eslint before major updates.
Quick check
Quick check: What does the --cache flag do?
- Caches linting results to skip unchanged files on next run.
- Stores config in memory.
- Increases memory usage.
Answer
Caches linting results to skip unchanged files on next run. — --cache significantly speeds up linting by skipping files that haven't changed since the last lint run.