[eslint] Unexpected block statement surrounding arrow body; move the returned value immediately a…

[eslint] Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`. [arrow-body-style]

1 res => {
2 
3   return new Promise().resolve(null);
4 
5 }

Originally, it was written as follows. When only one returns, eslint stipulates that it should be written as follows:

1 res => (new Promise().resolve(null));

If there are multiple returns, for example:

res => {

  if (abc === true) {

    return 0; 

      }

  return 1; 

}

This error will not be reported.

Similar Posts: