javascriptnode.jseslintarrow-functionsairbnb-js-styleguide

Eslint - Unexpected block statement surrounding arrow body


I just started using Airbnb's eslint config - and it seems really good.

I am however getting the below error, and I'm unsure of what the fix is - I guess it's due to the function only existing to return a val.

I've played around with it - but I can't seem to make it 'correct'.

const getAccountInfo = ((e) => {
  return new Promise((resolve, reject) => {
   ...
  });
});

[eslint] Unexpected block statement surrounding arrow body (arrow-body-style)

Thanks

Ollie


Solution

  • The reason you are having this error is, that airbnb's eslint config prefers implicit return with arrow function, you can fix it like this:

    const getAccountInfo = e => new Promise((resolve, reject) => ...)