I had this code before, with an Array#forEach
:
topics.results
.map(topic => /* ... */)
.filter(topic => /* ... */)
.forEach((topic) => {
// ...
});
The new no-array-for-each
auto-fixed it to:
for (const topic of topics.results
.map(topic => /* ... */)
.filter(topic => /* ... */) {
// ...
}
But it used the name topic
for the for loop, which is already used in the .map
and .filter
methods. This triggered the no-shadow
rule.
I don't know if unicorn can do anything about it though, appart from extracting the array to a variable before the loop, or using a suggestion rather than a fix.
One thing I though of, is to add an option to disable this rule when using method chaining, because I think it looks better when using a forEach
with method chaining, than using method chaining in a for of
.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too