gpt4 book ai didi

visual-studio-code - VS Code 显示 eslint 错误,但 vitest 正在运行。 'vi' 未定义

转载 作者:行者123 更新时间:2023-12-05 03:19:41 24 4
gpt4 key购买 nike

我有一个这样的 tsconfig 文件

{
"include": ["tests/**/*.ts"],
"exclude": [],
"compilerOptions": {
"composite": true,
"lib": [],
"skipLibCheck": true,
"outDir": "lib",
"types": ["vitest/globals"]
}
}

因为我已经为 vitest/globals 定义了类型,所以 yarn vitest cmd 工作正常并且也在执行测试用例。但在 VS Code 中显示错误
enter image description here

我如何在 vs-code 中修复/静音它?

最佳答案

我必须将以下内容添加到我的 .eslintrc.json 文件中以在测试设置模块中解决此问题:

"globals": {
"vi": true
},

但是,如果您使用的是 TypeScript,您还应该将此添加到 tsconfig.json 中的 compilerOptions:

"types": ["vitest/globals"]

编辑:你已经在你的 tsconfig.json 中有了它,但无论如何我都会把它留在这里以防它帮助别人

关于visual-studio-code - VS Code 显示 eslint 错误,但 vitest 正在运行。 'vi' 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73392328/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com