[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