admin管理员组文章数量:1201403
I have the Code for some iterations and it works well. After installing eslint, One of my code generates an error by eslint.
My code is:
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 generates an error which is this
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
Any help or suggestion is really appreciated for that. According to me The code was written very precisely and very small, don't know about the clue of eslint error
I have the Code for some iterations and it works well. After installing eslint, One of my code generates an error by eslint.
My code is:
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 generates an error which is this
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
Any help or suggestion is really appreciated for that. According to me The code was written very precisely and very small, don't know about the clue of eslint error
Share Improve this question asked Apr 25, 2019 at 8:07 AksAks 1,2243 gold badges15 silver badges37 bronze badges 5 |2 Answers
Reset to default 19There is nothing wrong with your code, this is outdated guidance.
"iterators/generators require regenerator-runtime" hasn't been true since 2014 caniuse.com/es6-generators this error looks like it came from airbnb's style guide and you'd have to ask them if they still stick to it
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;
}));
本文标签:
版权声明:本文标题:javascript - Stuck with eslint Error i.e Separately, loops should be avoided in favor of array iterations - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738567305a2100382.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
for ... of
? – Chase Choi Commented Apr 25, 2019 at 8:14.map()
? – evolutionxbox Commented Apr 26, 2019 at 13:24.map()
function, unless in the case where you want to iterate through an async block in series, in which case you should set up an ignore for this rule. – Willster Commented Nov 7, 2022 at 14:40