如何修复 "Unexpected block statement surrounding arrow body; move the returned value immediately after the =>" ESLint 错误?
How to fix "Unexpected block statement surrounding arrow body; move the returned value immediately after the =>" ESLint error?
我遇到了这个错误
Unexpected block statement surrounding arrow body; move the returned value immediately after the =>"
对于以下代码:
let guestBeingEdited = SJ.Event.ListItem.previouslyAddedGuests.filter(
guest => {
return guest.id === SJ.Event.ListItem.selectPrevGuest;
},
);
我尝试了不同的建议 from here 但无法解决问题。有什么建议吗?
块体和return语句是不必要的。它要求您将代码更改为:
let guestBeingEdited = SJ.Event.ListItem.previouslyAddedGuests.filter(
guest => guest.id === SJ.Event.ListItem.selectPrevGuest
);
我遇到了这个错误
Unexpected block statement surrounding arrow body; move the returned value immediately after the =>"
对于以下代码:
let guestBeingEdited = SJ.Event.ListItem.previouslyAddedGuests.filter(
guest => {
return guest.id === SJ.Event.ListItem.selectPrevGuest;
},
);
我尝试了不同的建议 from here 但无法解决问题。有什么建议吗?
块体和return语句是不必要的。它要求您将代码更改为:
let guestBeingEdited = SJ.Event.ListItem.previouslyAddedGuests.filter(
guest => guest.id === SJ.Event.ListItem.selectPrevGuest
);