पाठ 18 / 25

Reporting और Performance

ESLint performance को optimize करें और useful reports generate करें।

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 क्या करता है?

  • Linting results को cache करता है ताकि अगले run पर unchanged files को skip किया जाए।
  • Config को memory में store करता है।
  • Memory usage को बढ़ाता है।
Answer

Linting results को cache करता है ताकि अगले run पर unchanged files को skip किया जाए। — --cache last lint run के बाद changed नहीं किए गए files को skip करके linting को significantly speed up करता है।