gpt4 book ai didi

javascript - eslint 应该列在项目的依赖项中,而不是 devDependencies

转载 作者:IT老高 更新时间:2023-10-28 21:59:29 26 4
gpt4 key购买 nike

要么我不理解 Node 100% 中的 dependenciesdevDependencies,要么 eslint 在这里是错误的(无法正确分析):

   3:1   error  'chai' should be listed in the project's dependencies, not devDependencies              import/no-extraneous-dependencies
4:1 error 'chai-enzyme' should be listed in the project's dependencies, not devDependencies import/no-extraneous-dependencies
5:1 error 'enzyme' should be listed in the project's dependencies, not devDependencies import/no-extraneous-dependencies
7:1 error 'sinon' should be listed in the project's dependencies, not devDependencies import/no-extraneous-dependencies
9:1 error 'redux-mock-store' should be listed in the project's dependencies, not devDependencies import/no-extraneous-dependencies

这些是测试依赖,为什么说它们应该列在dependencies中呢?

附加说明:我们使用 Travis 作为我们的 CI,所以我也不知道这是否会有所不同。

最佳答案

通过将其添加到我的 .eslintrc 来解决它:

"import/no-extraneous-dependencies": ["error", {"devDependencies": true}]

[no-extraneous-dependencies] Add exceptions? #422

根据该用户的回复:

you could set the option devDependencies: true in an .eslintrc in your test folder:

rules: import/no-extraneous-dependencies: [error, { devDependencies: true }] Then you'll get reports of any packages referenced that are not included dependencies or devDependencies. Then you get the goodness of the rule, with no noise from the disable comments.

I think that might work for you? This is how I would use the rule, in your case, since you have your test code separated into a test directory.

此外,这篇文章有助于确认我不想在我的依赖项列表中加入其中的一些内容并没有发疯:Sharable ESLint Config

关于javascript - eslint 应该列在项目的依赖项中,而不是 devDependencies,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44939304/

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