Skip to content

Instantly share code, notes, and snippets.

@pralkarz
pralkarz / case-study.md
Last active April 20, 2025 14:39
Case study: investigating and improving an ESLint rule's (`eslint-plugin-n/prefer-node-protocol`) performance

Note

My approach contains some guesswork and might lack depth in a few areas. If you notice any mistakes or opportunities for improvement, the easiest way to reach out to me is either commenting under this Gist, or writing directly on Discord where I have the same nickname as here.

The problem

After profiling ESLint rules' performance in the Svelte repository, Ben McCann noticed that the n/prefer-node-protocol rule takes almost 50% of the total linting time: eslint-community/eslint-plugin-n#404. As with most issues I tackle, I wanted to start by reproducing the result, so I cloned the Svelte repository, installed the dependencies, and ran pnpm build.

Initially, I tried to check the performance in a more granular way with the --stats option (available in ESLint 9+, which is used in this particular project). This has proven unfeasible though as even when outputting JSON and redirecting stdo