javascript - 错误: Unnecessary use of boolean literals in conditional expression

标签 javascript reactjs eslint

我正在使用 ESLint 尝试此代码

代码片段:

if (disableFutureDates) {
    return isActiveDate < 0 ? true : false; //error
  }

出现此 ESLint 错误:错误在条件表达式中不必要地使用 bool 文字。

最佳答案

只返回条件的结果。比较返回一个 bool 值。

return isActiveDate < 0;

关于javascript - 错误: Unnecessary use of boolean literals in conditional expression,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63596204/

相关文章:

javascript - 下一个js : Refetchquery not updating for data fetched in getInitialProps

reactjs - React 查询调用的 onSuccess 单元测试

javascript - 使用 Moment JS 在聊天应用程序中设置时间格式

javascript - 图表初始化后如何更改 highcharts 事件

javascript - 如何在WebGL中本质上 "Chroma Key"?

javascript - 数据表:如何在表行中搜索字符串并隐藏行

java - 使用 jaspersoft ireport 创建 PDF 时出错

vue.js - 为什么我不能在我的 Vue 应用程序上使用调试器或 console.log

javascript - 无法加载配置 "react"以从

typescript - 避免混淆 2 种不同的 ID 类型