坚持 eslint 错误,即分别地,应该避免循环以支持数组迭代

Stuck with eslint Error i.e Separately, loops should be avoided in favor of array iterations

我有一些迭代的代码,它运行良好。安装 eslint 后,我​​的代码之一通过 eslint 生成错误。

我的代码是:

for (const column of columns) {
    for (const slugname of result[column.name]) {
        const alphabet = slugname.slugname;
        if (total[alphabet]) {
            total[alphabet] += column.value;
        } else {
            total[alphabet] = column.value;
        }
    }
}

eslint 生成一个错误,就是这样

error iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations no-restricted-syntax

非常感谢任何帮助或建议。据我说 代码写的很细很细,不知道eslint报错的线索

columns.map(x => result[x.name].map((y) => {
  const alphabet = y.slugname;
  if (total[alphabet]) {
      total[alphabet] += x.value;
    } else {
      total[alphabet] = x.value;
    }
    return true;
}));

您的代码没有任何问题,这是过时的指南。