在使用hasOwnProperty()方法判断对象是否具有某种属性时eslint报下列错误:
Do not access Object.prototype method 'hasOwnProperty' from target object.eslintno-prototype-builtins
ESLINT修改了规则,禁止state.hasOwnProperty(key) 这样判断
修改规则前是这样判断:
JS 在使用hasOwnProperty()函数时报错

修改规则后是这样判断:
JS 在使用hasOwnProperty()函数时报错
所以修改代码为:

JS 在使用hasOwnProperty()函数时报错
参考资料:
https://zhuanlan.zhihu.com/p/118126825
https://host.zzidc.com/wljc/1297.html





相关文章:

  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
  • 2021-07-09
  • 2019-02-11
猜你喜欢
  • 2022-01-07
  • 2021-06-30
  • 2022-12-23
  • 2022-12-23
  • 2018-03-28
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案