I am using ESLint with Visual Studio 2019. The integration works well, I can see the ESLint errors directly in the IDE.
But when I add more rules to my config file, like no-async-promise-executor, I get errors like
(ESLint) Definition for rule 'no-async-promise-executor' was not found C:\Work\GatewayServer\Multicheck.GW.Web (tsconfig or jsconfig project)
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"
.
I have installed the latest (6.7.2) version of ESLint on my computer, and it is in the PATH.
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 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.
The solution was then to have a package.json
file at the root of the project:
{
...
"dependencies": {
...
"eslint": "6.7.2"
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With