簡體   English   中英

預期分配或 function 調用,而是看到一個表達式 no-unused-expressions - 如何修復此 CI 錯誤?

[英]Expected an assignment or function call and instead saw an expression no-unused-expressions - how to fix this CI error?

預期分配或 function 調用,而是看到一個表達式 no-unused-expressions,我需要幫助來解決這個問題。 謝謝

 export const setDecimalFormat = amount => { ['de', 'fr'].includes(getLocale())? amount.replace(/\./g, ','): amount; };

嘗試返回值

如果箭頭 function 只是返回一行代碼,則可以省略語句括號和 return 關鍵字。 這告訴箭頭 function 返回語句。

export const setDecimalFormat = amount => {
  return ['de' , 'fr'].includes(getLocale())
    ? amount.replace(/\./g, ',')
    : amount;
};

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM