Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upgrade the version of ESLint used in Visual Studio 2019?

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.

like image 767
Andreas Schwarz Avatar asked Jan 26 '23 11:01

Andreas Schwarz


1 Answers

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"
  }
}
like image 50
Andreas Schwarz Avatar answered Apr 24 '23 06:04

Andreas Schwarz