[英]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.我在 VSCode 中打开了我的项目文件夹,打开后,我运行了 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".之后 VSCode 在顶部显示确认框,上面写着“单击允许使用工作区文件夹中本地配置的 eslint”。 I clicked Allow.
我点击了允许。
But then it started giving unnecessary errors like double quotes should be used instead of single quotes.但随后它开始出现不必要的错误,例如应该使用双引号而不是单引号。
How to revert back to global ESlint?如何恢复到全局 ESlint?
I tried exploring ESLint settings in VSCode but didn't find the appropriate setting.我尝试在 VSCode 中探索 ESLint 设置,但没有找到合适的设置。 Please help me in this.
请帮助我。
Got the answer, to get this dialog box again, run the following command in command palette得到答案,要再次获得此对话框,请在命令面板中运行以下命令
ESLint: Reset Library Decision ESLint:重置库决策
Reference: https://github.com/microsoft/vscode-eslint/issues/1023参考: https://github.com/microsoft/vscode-eslint/issues/1023
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.我使用 Vagrant VM,当
node_modules
位于我的本地硬盘驱动器和 VM 都可见的目录中时,性能会受到很大影响。
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.
我想当 VM 位于该共享目录中时,从 VM 中进行读取会产生很多开销。 When the directory is moved into the VM and not directly accessible from the shared directory, it goes a lot faster.
当目录被移动到 VM 中并且不能从共享目录直接访问时,它会更快。
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.然而,这给 VS Code 带来了问题,因为它想使用它希望在符号链接的 node_modules 中看到的
node_modules
版本……但它无法通过符号链接导航。
My solution was to force VS Code to use the globally-installed eslint on my machine, separate from the VM.我的解决方案是强制 VS Code 在我的机器上使用全局安装的 eslint,与 VM 分开。 To do that, ensure you have eslint installed globally, then:
为此,请确保您已全局安装 eslint,然后:
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!希望这可以帮助其他人完成这个有点奇怪的 VM 设置!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.