// with an inline arrow function (BEFORE)
iterate([], (v) => {});
// with an inline arrow function (AFTER)
for (const v of ([])) {};
// with a referenced function (BEFORE)
const fn = (v) => {};
iterate([], fn);
// with a referenced function (AFTER)
for (const value of ([])) { fn(value); };
// without a callback (BEFORE)
iterate([1, 1, 1]);
// without a callback (AFTER)
Array.from([1, 1, 1]);
the semi colon gets left behind on the for loops which feels awkward. however, i think people should be expected to run a formatter after using this codemod anyway since we're adding blocks of code rather than simple changes.
Adds a codemod for
iterate-value
.This handles the following cases:
the semi colon gets left behind on the
for
loops which feels awkward. however, i think people should be expected to run a formatter after using this codemod anyway since we're adding blocks of code rather than simple changes.