如何升级Visual Studio 2019中使用的ESLint版本? [英] How to upgrade the version of ESLint used in Visual Studio 2019?
问题描述
我将ESLint与Visual Studio 2019一起使用.集成效果很好,我可以直接在IDE中看到ESLint错误.
I am using ESLint with Visual Studio 2019. The integration works well, I can see the ESLint errors directly in the IDE.
但是当我向配置文件中添加更多规则时,例如无异步-promise-executor ,我收到类似
But when I add more rules to my config file, like no-async-promise-executor, I get errors like
(ESLint)找不到规则'no-async-promise-executor'的定义C:\ Work \ GatewayServer \ Multicheck.GW.Web(tsconfig或jsconfig项目)
(ESLint) Definition for rule 'no-async-promise-executor' was not found C:\Work\GatewayServer\Multicheck.GW.Web (tsconfig or jsconfig project)
事实证明,ESLint版本有点过时.在 C:\ Users \ username \ AppData \ Local \ Microsoft \ TypeScript \ ESLint \ package.json
中,我们可以看到"eslint":"4.19.1"
.
It turns out that the ESLint version is a bit outdated. In C:\Users\username\AppData\Local\Microsoft\TypeScript\ESLint\package.json
, we can see "eslint": "4.19.1"
.
我已经在计算机上安装了ESLint的最新版本(6.7.2),并且该文件位于PATH中.
I have installed the latest (6.7.2) version of ESLint on my computer, and it is in the PATH.
如何强制Visual Studio使用最新的ESLint?我正在使用VS2019 16.4.2.
How can I force Visual Studio to use an up-to-date ESLint? I am using VS2019 16.4.2.
推荐答案
After some research, I was able to find specific documentation:
默认情况下,Visual Studio将使用其ESLint 4安装.但是,如果您想使用其他版本,则可以使用Visual Studio.将选择本地安装的ESLint并使用它.在特别是,如果要删除文件的任何父目录包含将ESLint列为依赖项的package.json以及安装了ESLint的node_modules文件夹,则它将使用那个短绒棉的副本.
Visual Studio will use its installation of ESLint 4 by default. However, if you would like to use a different version, Visual Studio will pick up a local installation of ESLint and use it instead. In particular, if any parent directory of the file you want to be linted contains a package.json that lists ESLint as a dependency, as well as a node_modules folder with an installation of ESLint, then it will use that copy of the linter.
然后的解决方案是在项目的根目录下有一个 package.json
文件:
The solution was then to have a package.json
file at the root of the project:
{
...
"dependencies": {
...
"eslint": "6.7.2"
}
}
这篇关于如何升级Visual Studio 2019中使用的ESLint版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!