如何解决在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错误。
以下是我的.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 举报,一经查实,本站将立刻删除。