पाठ 18 / 27
Reporting और Performance
--cache से ESLint तेज़ करें और --max-warnings व report formats से warning budgets लागू करें।
Performance tuning
ESLint बड़े codebases पर slow हो सकता है। Unchanged files को skip करने के लिए --cache का उपयोग करें, और जब thresholds exceed हों तो warnings को errors के रूप में treat करने के लिए --max-warnings का उपयोग करें।
Performance optimization
Linting results को cache करें और visibility के लिए reports generate करें।
# 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
नियमित रूप से cache को clear करें
ESLint cache stale हो सकता है। Major updates से पहले rm .eslintcache या eslint . --cache --cache-location ./node_modules/.cache/eslint के साथ इसे clear करें।
त्वरित जाँच
त्वरित जाँच: --cache flag क्या करता है?
- Config को memory में store करता है।
- Memory usage को बढ़ाता है।
- Lint results upload करता है
- Linting results को cache करता है ताकि अगले run पर unchanged files को skip किया जाए।
Answer
Linting results को cache करता है ताकि अगले run पर unchanged files को skip किया जाए। — --cache last lint run के बाद changed नहीं किए गए files को skip करके linting को significantly speed up करता है।