I am trying to configure ESLint in Visual Studio 2019, I enabled ESLint in Options and I have installed ESLint 7.4.0 in node_modules inside my project, which should cause Visual Studio to use that version according to this document. But this causes a single not so helpful error.
When running eslint .
in the command line from the same directory as the .eslintrc.yml
file it works and errors and warnings about my code are reported.
When viewing a .js
, .ts
or .tsx
file in Visual Studio it reports the following error internal-error: (ESLint) Unexpected token {
at the first character of the file. No other errors are reported (where the command line does report errors). Visual Studio does report the usual intellisense TypeScript errors in these files.
The following is my .eslintrc.yml file.
---
parser: "@typescript-eslint/parser" # Specifies the ESLint parser
parserOptions:
ecmaFeatures:
jsx: true # Allows for the parsing of JSX
settings:
react:
version: detect # Tells eslint-plugin-react to automatically detect the version of React to use
extends:
- plugin:react/recommended # Uses the recommended rules from @eslint-plugin-react
- plugin:react-hooks/recommended # Uses the recommended rules from @eslint-plugin-react-hooks
- plugin:@typescript-eslint/recommended # Uses the recommended rules from the @typescript-eslint/eslint-plugin
Is there a way to see what Visual Studio is executing and what causes this error?
I tried running devenv.exe /log
, but this logged nothing interesting, only that something was done with eslint. As you can see below.
821 Begin export of category 'TypeScript_EsLint' ({d5d56c12-87c4-46f2-894f-3a75ee781f48}) from package 'Microsoft.VisualStudio.LanguageServices.TypeScript.TypeScriptPackage, Microsoft.VisualStudio.LanguageServices.TypeScript, Version=16.0.0.0, Culture=neutral' ({2FFE45C4-5C73-493C-B187-F2E955FF875E}). 3095452 KB of virtual memory currently available. Profile manager 2020/08/19 08:11:21.001
822 End export of category 'TypeScript_EsLint' ({d5d56c12-87c4-46f2-894f-3a75ee781f48}) from package 'Microsoft.VisualStudio.LanguageServices.TypeScript.TypeScriptPackage, Microsoft.VisualStudio.LanguageServices.TypeScript, Version=16.0.0.0, Culture=neutral' ({2FFE45C4-5C73-493C-B187-F2E955FF875E}). 3095452 KB of virtual memory currently available. Profile manager 2020/08/19 08:11:21.003