prat
prat

Reputation: 143

How to make VSCode use global eslint instead of local eslint

I opened my project folder in VSCode, after opening it, I ran npm install.

After that VSCode displayed the confirmation box at the top saying "Click on Allow to use the eslint configured locally in the workspace folder". I clicked Allow.

enter image description here

But then it started giving unnecessary errors like double quotes should be used instead of single quotes.

How to revert back to global ESlint?

I tried exploring ESLint settings in VSCode but didn't find the appropriate setting. Please help me in this.

Upvotes: 4

Views: 9049

Answers (3)

karlbecker_com
karlbecker_com

Reputation: 959

I use a Vagrant VM, and when node_modules is in the directory that's visible to both my local hard drive and the VM, performance takes a significant hit.

From a tip in this post that no longer exists, when I do the following:

mkdir ~/whatever
mv /vagrant/node_modules ~/whatever/
ln -s ~/whatever/node_modules /vagrant/node_modules

...I get a significant, multi-second speedup when starting the app. I guess there's a lot of overhead for reading from within a VM when it's in that shared directory. When the directory is moved into the VM and not directly accessible from the shared directory, it goes a lot faster.

However, this caused problems for VS Code, since it wanted to use the eslint version that it expected to see in the symlinked node_modules ... but it couldn't navigate through the symlink.

My solution was to force VS Code to use the globally-installed eslint on my machine, separate from the VM. To do that, ensure you have eslint installed globally, then:

  1. Quit VS Code
  2. Remove the symlink to my node_modules directory, so my node app effectively has no node_modules in its root directory
  3. Run "ESLint: Reset Library Execution Decisions" in VS Code (and possibly quit VSCode again)
  4. Open VSCode, and click "ESLint" in the bottom - it should now ask to use the globally-installed eslint version
  5. Success! The Problems tab has eslint warning and errors.

After that's done, I brought the symlink back, and it's still working as expected.

Hope this helps someone else with this slightly strange VM setup!

Upvotes: 0

sidonaldson
sidonaldson

Reputation: 25284

You can also click the ESlint button in the tool bar at the bottom right of the window. This should open the dialogue again.

an image of VS Code toolbar

Upvotes: 0

prat
prat

Reputation: 143

Got the answer, to get this dialog box again, run the following command in command palette

ESLint: Reset Library Decision

Reference: https://github.com/microsoft/vscode-eslint/issues/1023

Upvotes: 2

Related Questions