在Visual Studio 2019中使用TypeScript配置ESLint

问题描述

我正在尝试在Visual Studio 2019中配置ESLint,我在Options中启用了ESLint,并且已在项目内部的node_modules中安装了ESLint 7.4.0,这将导致Visual Studio根据this document使用该版本。但这会导致一个不太有用的错误

在与eslint .文件相同的目录中的命令行中运行.eslintrc.yml时,它将起作用,并且会报告有关我的代码错误和警告。

在Visual Studio中查看.js.ts.tsx文件时,它将在文件的第一个字符处报告以下错误internal-error: (ESLint) Unexpected token {。没有报告其他错误(命令行确实报告错误)。 Visual Studio确实会报告这些文件中常见的intellisense TypeScript错误

Error in Visual Studio 2019

以下是我的.eslintrc.yml文件

---
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

是否可以查看正在执行的Visual Studio以及导致此错误的原因?

我尝试运行devenv.exe /log,但这没什么有趣的事,只是用eslint完成了一些工作。正如您在下面看到的。

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,Culture=neutral' ({2FFE45C4-5C73-493C-B187-F2E955FF875E}). 3095452 KB of virtual memory currently available.   Profile manager 2020/08/19 08:11:21.003  

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)