我为猫鼬模式编写了以下代码:
localeTypesSchema.statics.findAndModify =
function findAndModify(query, sort, update, options, callback) {
const promised = q.nbind(this.collection.findAndModify, this.collection);
return promised(query || {}, sort || [], update || {}, options, callback);
};SonarQube正在抱怨Make this function anonymous by removing its name (cross-browser, user-experience) (专业,代码嗅觉)。
如果我删除名称,那么eslint扩展airbnb就会抱怨(警告) [eslint] Missing function expression name. (func-names)。
我不能将它转换为箭头函数,因为它使用了this,this应该绑定到函数调用者,而不是箭头函数的作用域。
我该怎么写代码?
发布于 2016-10-10 08:03:30
这两种选择都是有效的:阅读SonarQube规则和eslint规则的描述。实际上,可以将eslint规则配置为强制执行一种选择或相反的选择。如果您想要强制执行一条规则,工具就会在这里提供帮助。
https://stackoverflow.com/questions/39933379
复制相似问题