Curious where ESLint is spending its time?

development, productivity, tips

ESLint is a useful tool for performing static analysis on your JavaScript code to identify and fix a range of potential problems or deviation from an agreed set of style guidelines. Linting should be a quick process, ideally providing feedback to developers in near real-time while they're editing their code. Sometimes a particular plugin or rule can take a while to complete. How can we figure out which rules are the slowest, contributing the most to the wait time?

Documentation to the rescue: https://eslint.org/docs/developer-guide/working-with-rules#per-rule-performance

ESLint has a built-in method to track performance of individual rules. Setting the TIMING environment variable will trigger the display, upon linting completion, of the ten longest-running rules, along with their individual running time and relative performance impact as a percentage of total rule processing time.

$ TIMING=1 eslint lib
Rule                    | Time (ms) | Relative
:-----------------------|----------:|--------:
no-multi-spaces         |    52.472 |     6.1%
camelcase               |    48.684 |     5.7%
no-irregular-whitespace |    43.847 |     5.1%
valid-jsdoc             |    40.346 |     4.7%
handle-callback-err     |    39.153 |     4.6%
space-infix-ops         |    35.444 |     4.1%
no-undefined            |    25.693 |     3.0%
no-shadow               |    22.759 |     2.7%
no-empty-class          |    21.976 |     2.6%
semi                    |    19.359 |     2.3%
-