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


[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 }

本来是上面这样写,当只有一个返回的时候,eslint规定要写成:

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

如果有多个返回,比如:

res => {

  if (abc === true) {

    return 0; // 第一个返回

      }

  return 1; //  第二个返回

}

则不会报这个错,具体可以参照官方说明:

https://eslint.org/docs/rules/arrow-body-style


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM