小编sbr*_*ell的帖子

如何修复“ESLint 无法唯一确定插件“@typescript-eslint””?

我正在尝试使用 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

纱线运行 v1.22.19\n$ eslint ./src/

\n

哎呀!出了些问题!:(

\n

ESLint:8.48.0

\n

ESLint 无法唯一确定插件“@typescript-eslint”。

\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

请从任一配置中删除“插件”设置或删除任一插件安装。

\n
\n

我目前对此消息的理解是,编译器已检测到我的项目的不同部分需要不同版本的 @typescript-eslint 并且不知道要使用哪个版本(但我可能是错的,并且非常乐意予以更正)。

\n

我特别好奇如何阅读这部分错误消息:

\n
\n

(加载于“src.eslintrc.json \xc2\xbb eslint-config-react-app#overrides[0]”)

\n
\n

这似乎意味着我的 .eslintrc.json 文件包含类似的内容

\n
{\n    eslint-config-react-app: {\n        overrides: …
Run Code Online (Sandbox Code Playgroud)

node.js typescript reactjs typescript-eslint

6
推荐指数
1
解决办法
5985
查看次数

为什么我的理论单元测试在测试资源管理器摘要中显示“测试有多个结果”?

通常,当我用或 等[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)

c# unit-testing xunit.net

5
推荐指数
1
解决办法
1334
查看次数