简体   繁体   English

Eslint 8.0.1 - 在配置中实现 jest 会引发错误

[英]Eslint 8.0.1 - implementing jest into config throws an error

In my Next/React/Typescript/Jest project I'm trying to configure my eslint config.在我的 Next/React/Typescript/Jest 项目中,我试图配置我的 eslint 配置。 After updating to version 8.x (currently 8.0.1), the linter throws following error:更新到版本 8.x(当前为 8.0.1)后,linter 抛出以下错误:

Error: .eslintrc.js » ./eslint/config.js:
    Environment key "jest/globals" is unknown

Then I added 'plugin:jest/recommended' to the extends array in my config.js , which led me to this error:然后我将'plugin:jest/recommended'到我的config.jsextends数组,这导致我出现了这个错误:

TypeError: Failed to load plugin 'jest' declared in '.eslintrc.js » ./eslint/config.js': Class extends value undefined is not a constructor or null

The plugin is installed and inside my package.json .该插件已安装并位于我的package.json Even several npm ci haven't helped me here.甚至几个npm ci在这里也没有帮助我。

Would appreciate ideas !将不胜感激的想法!

Are you using any other eslint plugins?您是否使用任何其他 eslint 插件? If so, has npm warned you of any peer dependency issues?如果是这样,npm 是否警告过您任何对等依赖问题?

I ran into this same issue when upgrading to eslint v8.0.1.我在升级到 eslint v8.0.1 时遇到了同样的问题。 In may case, one plugin I listed an an earlier version of @typescript-eslint/eslint-plugin as a direct dependency ( @typescript-eslint/eslint-plugin is also a peer dependency of eslint-plugin-jest ).在可能的情况下,我列出了一个早期版本的@typescript-eslint/eslint-plugin作为直接依赖项( @typescript-eslint/eslint-plugin也是eslint-plugin-jest的对等依赖项)。 This earlier version of @typescript-eslint/eslint-plugin was not compatible with eslint v8.0.1.这个早期版本的@typescript-eslint/eslint-plugineslint v8.0.1 不兼容。 So I opted to downgrade to v7.32.0所以我选择降级到 v7.32.0

If you have control over the other plugins you use, you might upgrade their dependencies and publish a new release.如果您可以控制使用的其他插件,则可以升级它们的依赖项并发布新版本。 Else, you'll probably have to downgrade eslint in your project.否则,你可能不得不在你的项目中降级eslint

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM