vscode: slow Eslint

Jan 23, 2023

TLDR;

It's because Javascript runs out of memory. Put this line into VS Code user settings. (The number depends on how much memory do you need.)

"eslint.execArgv": ["--max_old_space_size=8192"]

The problem

In the same project as my blog post about Javascript heap out of memory, I usually experienced slowness of the Eslint plugin in VsCode. It often showed the notification in the picture below about 0.5-1 minute on every saving which was unaccepatable.

vscode eslint notification

I inspected the output of the Eslint plugin, and found out that the error was Javascript heap out of memory again. So the workaround was going to be increasing NodeJs allocated memory for sure but I didn't know how to do it for a VS Code plugin.

vscode eslint heap out of memory error

The fix

Thanks for an issue on Github for vscode-eslint, there is a way to input NodeJs option for the plugin by using eslint.execArgv in VS Code user settings.

"eslint.execArgv": ["--max_old_space_size=8192"]