我正在尝试在 Visual Studio 2019 中配置 ESLint,我在 Options 中启用了 ESLint,并且我在我的项目中的 node_modules 中安装了 ESLint 7.4.0,这应该会导致 Visual Studio 根据本文档使用该版本。但这会导致一个不太有用的错误。
eslint .
从与文件相同的目录在命令行中运行时,.eslintrc.yml
它会工作并报告有关我的代码的错误和警告。
在 Visual Studio 中查看或文件时.js
,它会在文件的第一个字符处报告以下错误。没有报告其他错误(命令行确实报告错误)。Visual Studio 确实在这些文件中报告了常见的智能感知 TypeScript 错误。.ts
.tsx
internal-error: (ESLint) Unexpected token {
以下是我的 .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, 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