![](/img/trans.png)
[英]Converting eslint config from json to JavaScript throws error when exporting config
[英]Eslint 8.0.1 - implementing jest into config throws an error
在我的 Next/React/Typescript/Jest 項目中,我試圖配置我的 eslint 配置。 更新到版本 8.x(當前為 8.0.1)后,linter 拋出以下錯誤:
Error: .eslintrc.js » ./eslint/config.js:
Environment key "jest/globals" is unknown
然后我將'plugin:jest/recommended'
到我的config.js
的extends
數組,這導致我出現了這個錯誤:
TypeError: Failed to load plugin 'jest' declared in '.eslintrc.js » ./eslint/config.js': Class extends value undefined is not a constructor or null
該插件已安裝並位於我的package.json
。 甚至幾個npm ci
在這里也沒有幫助我。
將不勝感激的想法!
您是否使用任何其他 eslint 插件? 如果是這樣,npm 是否警告過您任何對等依賴問題?
我在升級到 eslint v8.0.1 時遇到了同樣的問題。 在可能的情況下,我列出了一個早期版本的@typescript-eslint/eslint-plugin
作為直接依賴項( @typescript-eslint/eslint-plugin
也是eslint-plugin-jest
的對等依賴項)。 這個早期版本的@typescript-eslint/eslint-plugin
與eslint
v8.0.1 不兼容。 所以我選擇降級到 v7.32.0
如果您可以控制使用的其他插件,則可以升級它們的依賴項並發布新版本。 否則,你可能不得不在你的項目中降級eslint
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.