Node.js Feathers服务使用和eslint
为了向我的游乐设施列表中添加一些用户数据,我添加了以下钩子:Node.js Feathers服务使用和eslint,node.js,eslint,feathersjs,Node.js,Eslint,Feathersjs,为了向我的游乐设施列表中添加一些用户数据,我添加了以下钩子: async(上下文:HookContext)=>{ //eslint禁用下一行无限制语法 for(context.result.data的常量){ if(typeof ride.driverId!=“未定义”){ //eslint禁用循环中的下一行无等待 const driver=wait context.app.service('users').get(ride.driverId); //无法复制完整对象,因为内部服务未筛选字段。
async(上下文:HookContext)=>{
//eslint禁用下一行无限制语法
for(context.result.data的常量){
if(typeof ride.driverId!=“未定义”){
//eslint禁用循环中的下一行无等待
const driver=wait context.app.service('users').get(ride.driverId);
//无法复制完整对象,因为内部服务未筛选字段。
//@见https://github.com/feathersjs/feathers/issues/1715
驾驶人={
_身份证:司机,
名称:driver.name,
};
}
}
},
配置了Airbnb建议的ESLint会抛出错误无限制语法
和无等待循环
我明白为什么,但我不知道如何让它在没有
什么是正确且有效的语法?受限语法规则不希望您使用
来进行of
我会考虑一些类似于图迭代器的问题,看看这是否解决了这两个问题。
return context.result.data.map(ride => {
if (typeof ride.driverId !== 'undefined') {
const driver = await context.app.service('users').get(ride.driverId);
// We can't copy the complete object because field are not filtered by the internal service.
// @see https://github.com/feathersjs/feathers/issues/1715
ride.driver = {
_id: driver._id,
name: driver.name,
};
}
}