如何处理意外使用逗号运算符无序列 EsLINT 警告
How to deal with Unexpected use of comma operator no-sequences EsLINT warning
我收到 eslint 警告 意外使用逗号。我找到了 个答案,但它与我的问题不符。
这是我的代码:
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})
})
如何消除警告?非常感谢。
您在 .reduce
回调中的 return
语句可以写成
r.count += +o.amount;
return r;
这完全一样,但它应该让 ESLint 高兴。
我收到 eslint 警告 意外使用逗号。我找到了
这是我的代码:
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})
})
如何消除警告?非常感谢。
您在 .reduce
回调中的 return
语句可以写成
r.count += +o.amount;
return r;
这完全一样,但它应该让 ESLint 高兴。