如何处理 Unexpected use of逗号运算符 no-sequences EsLINT 警告 [英] How to deal with Unexpected use of comma operator no-sequences EsLINT warning
本文介绍了如何处理 Unexpected use of逗号运算符 no-sequences EsLINT 警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于意外使用逗号,我收到 eslint 警告.我找到了这个答案,但它与我的问题不符.>
我有这个代码
const 减少 = _.map(_.keys(grouped), function(e) {return _.reduce(grouped[e], function(r, o) {返回 r.count += +o.amount, r}, {price: parseFloat(e), count: 0, amount: e.amount})})
如何解除警告?非常感谢.
解决方案
你在.reduce
回调中的return
语句可以写成
r.count += +o.amount;返回 r;
这完全相同,但它应该让 ESLint 高兴.
I am getting an eslint warning for unexpected use of comma. I found this answer but it does not match my issue.
I have this code
const reduced = _.map(_.keys(grouped), function(e) {
return _.reduce(grouped[e], function(r, o) {
return r.count += +o.amount, r
}, {price: parseFloat(e), count: 0, amount: e.amount})
})
How do I get rid of the warning? Thank you very much.
解决方案
Your return
statement in the .reduce
callback can be written as
r.count += +o.amount;
return r;
That does exactly the same thing, but it should make ESLint happy.
这篇关于如何处理 Unexpected use of逗号运算符 no-sequences EsLINT 警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文