How to fix "Unexpected block statement surrounding arrow body; move the returned value immediately after the =>" ESLint error?

I’m getting this error

Unexpected block statement surrounding arrow body; move the returned value immediately after the =>"

for the code below:

let guestBeingEdited = SJ.Event.ListItem.previouslyAddedGuests.filter(
    guest => {
        return guest.id === SJ.Event.ListItem.selectPrevGuest;
    },
);

I tried different suggestions from here but couldn’t get it fixed. Any suggestions?

8 thoughts on “How to fix "Unexpected block statement surrounding arrow body; move the returned value immediately after the =>" ESLint error?”

  1. The block body and return statement are unnecessary. It’s asking you to change your code to this:

    let guestBeingEdited = SJ.Event.ListItem.previouslyAddedGuests.filter(
        guest => guest.id === SJ.Event.ListItem.selectPrevGuest
    );
    
    Reply

Leave a Comment