gpt4 book ai didi

jestjs - Eslint开 Jest/全局环境 key 未知

转载 作者:行者123 更新时间:2023-12-03 14:38:46 26 4
gpt4 key购买 nike

我有一个自定义eslint-config,其中包含多个插件,可用于各种软件包,包括jest。我将主要设置为一个索引,该索引仅扩展了其他文件。

长话短说,我有一个开玩笑的配置文件。看起来像。

module.exports = {
plugins: ['jest'],
rules: {
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/valid-expect': 'error',
'jest/no-alias-methods': 'off',
'jest/no-jest-import': 'error',
'jest/no-large-snapshots': ['warn', {maxSize: 300}],
'jest/no-test-prefixes': 'error',
'jest/prefer-to-contain': 'warn',
'jest/prefer-to-have-length': 'warn',
'jest/valid-describe': 'error',
'jest/valid-expect-in-promise': 'error',
'jest/consistent-test-it': 'off',
'jest/lowercase-name': 'off',
'jest/no-hooks': 'off',
'jest/no-jasmine-globals': 'off',
'jest/no-test-callback': 'off',
'jest/prefer-expect-assertions': 'off',
'jest/prefer-to-be-null': 'off',
'jest/prefer-to-be-undefined': 'off',
'jest/require-tothrow-message': 'off',
'jest/expect-expect': 'off',
'jest/no-test-return-statement': 'off',
'jest/prefer-inline-snapshots': 'off',
'jest/prefer-strict-equal': 'off',
'jest/prefer-spy-on': 'off',
'jest/prefer-todo': 'warn',
'jest/prefer-called-with': 'error',
'jest/no-truthy-falsy': 'off',
'jest/no-empty-title': 'error',
'jest/no-mocks-import': 'error',
'jest/no-commented-out-tests': 'warn',
},
env: {
'jest/globals': true,
},
}

运行lint任务时,我不断收到错误 Environment key "jest/globals" is unknown。据我了解,我已经追踪了config-validator,但没有发现任何问题。 eslint-plugin-jest板上没有关于此的打开/关闭问题,我找不到其他遇到相同错误的人。

另外,为了获得额外的奖励,我还安装了cypress插件,该插件本身具有环境选项cypress/globals:true,它还会引发相同的错误。

有没有人遇到过这种情况,并且知道为什么(在过去一个月左右)开始发生这种情况。注意:我已经有一段时间这个配置了,这才刚刚开始发生。

编辑:
我只是降级为eslint ^ 6.1.0,这个问题不再存在。 6.1.0和6.4.0之间的某个原因导致了此问题。

最佳答案

把它放在“扩展”中为我解决了这个问题。
“扩展”:[
“推荐:推荐”,
“插件:开玩笑/推荐”
],

关于jestjs - Eslint开 Jest/全局环境 key 未知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58065765/

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