javascript - 陷入 eslint 错误,即单独地,应避免循环以支持数组迭代
问题描述
我有一些迭代的代码,它运行良好。安装 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;
}));
推荐阅读
- python - 问题:Glib-Gobject-warning **:无法注册现有类型“GDKDisplayManager”
- windows - powershell中Winform透明背景
- c# - 我们如何将 \\u003C\\u003F\\ 这种格式的 unicode 字符转换为普通的 html 文本
- javascript - scrollIntoView({behaviour: "smooth"}) 不适用于勇敢的铬但适用于 Firefox (REACT JS)
- sass - 你如何应用 scss 模板来进行 vuetify?
- amazon-web-services - 如何忽略 Terraform 中的嵌套字段?
- r - geom_text() 的边界位置
- azure-devops - Azure Devpos Server 2019:如何正确管理用户角色
- java - Java geoip2 java.io.FileNotFoundException:
- go - 使用 golang 表达式包删除 DynamoDB 字符串属性