问题描述
要么在节点100%中我不理解依赖
与 devDependencies
,要么eslint在这里错了(无法正确分析):
Either I don't understand dependencies
vs. devDependencies
in node 100% yet or eslint is just wrong here (not capable of analyzing this correctly):
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
这些是测试依赖否定,为什么说它们应该列在依赖
?
These are test dependencies, so why is it saying that they should be listed in dependencies
?
附加说明:我们使用Travis作为我们的CI,所以我不知道它是否会对此产生影响。
Additional note: We're using Travis as our CI so I don't know if it makes a difference for that at all either.
推荐答案
解决这个问题,将其添加到我的 .eslintrc
:
Solved it with adding this to my .eslintrc
:
import / no-extraneous-dependencies:[error,{devDependencies:true}]
根据此用户的回复:
规则:import / no-extraneous-依赖项:[error,{devDependencies:
true}]然后,您将获得引用的任何包的报告,这些包是
未包含的依赖项或devDependencies。 然后你获得
规则的优点,没有来自禁用评论的噪音。
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.
这篇文章也有助于确认我并不想在我的依赖列表中不想要其中的一些:
这篇关于eslint应该列在项目的依赖项中,而不是devDependencies的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!