我正在尝试使用 React.js 和 typescript 在 ASP.NET core MVC 项目中启用 eslint linting,并且正在努力修复上述错误。
\n我正在使用 Visual Studio 2022 社区版 17.6.3 和项目模板“ASP.NET Core with React.js”,该模板又使用 create-react-app 在 ClientApp 子文件夹中创建 React.js 应用程序项目文件夹。
\n这是yarn 报告的错误消息。编辑 .tsx 代码文件时,类似的错误消息也出现在我的代码编辑器选项卡的顶部,但纱线似乎报告了最全面的消息。
\n\n\n纱线运行 v1.22.19\n$ eslint ./src/
\n哎呀!出了些问题!:(
\nESLint:8.48.0
\nESLint 无法唯一确定插件“@typescript-eslint”。
\n\n
\n- C:\\path\\to\\MyProject\\ClientApp\\node_modules@typescript-eslint\\eslint-plugin\\dist\\index.js (在“src.eslintrc.json”中加载)
\n- C:\\path\\to\\MyProject\\ClientApp\\node_modules\\eslint-config-react-app\\node_modules@typescript-eslint\\eslint-plugin\\dist\\index.js(加载于“ src.eslintrc.json \xc2\xbb eslint-config-react-app#overrides[0]")
\n请从任一配置中删除“插件”设置或删除任一插件安装。
\n
我目前对此消息的理解是,编译器已检测到我的项目的不同部分需要不同版本的 @typescript-eslint 并且不知道要使用哪个版本(但我可能是错的,并且非常乐意予以更正)。
\n我特别好奇如何阅读这部分错误消息:
\n\n\n(加载于“src.eslintrc.json \xc2\xbb eslint-config-react-app#overrides[0]”)
\n
这似乎意味着我的 .eslintrc.json 文件包含类似的内容
\n{\n eslint-config-react-app: {\n overrides: …Run Code Online (Sandbox Code Playgroud) 通常,当我用或 等[Theory]属性装饰 XUnit 测试方法并将多组参数传递到测试中时,Visual Studio 测试资源管理器窗口可让我展开测试方法,将每组参数视为单独的测试。[InlineData][ClassData]
但是,我有一个行为不同的测试 - 它在项目、命名空间、类、测试方法等的树视图中显示为单个测试,但是在测试详细信息摘要窗格中它显示“测试有多个结果结果”,其中可以是通过和失败的混合。这使得准确查看哪些内容通过或失败变得更加困难,并且还阻止我仅使用一组参数调试测试。
这是我的单元测试:
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using Xunit;
public class MyTestClass
{
[Theory]
[ClassData(typeof(MyTestData1))]
public void MyTestMethod1(Color col, int red, int green, int blue)
{
Assert.Equal(red, col.R);
Assert.Equal(green, col.G);
Assert.Equal(blue, col.B);
}
}
Run Code Online (Sandbox Code Playgroud)
提供我的测试数据的类:
public class MyTestData1 : IEnumerable<object[]>
{
public MyTestData1()
{
this.Data = new List<object[]>();
this.Data.Add(new object[] { Color.FromArgb(255, 0, 0), 255, 0, 0 });
this.Data.Add(new object[] { Color.FromArgb(0, 255, 0), 0, 255, 0 …Run Code Online (Sandbox Code Playgroud)