Fix eslintno-plusplus, eslintno-param-reassign linter errors when adding to accumulator in TypeScript reduce function

前端 未结 0 895
眼角桃花
眼角桃花 2021-02-09 17:27

Give this code in TypeScript:

const res = arr.reduce((acc, cur) => (cur.id ? ++acc : acc), 0);

How do I stop the linter throwing the errors:

相关标签:
回答
  • 消灭零回复
提交回复
热议问题