Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add iterate-value #94

Merged
merged 1 commit into from
Aug 26, 2024
Merged

feat: add iterate-value #94

merged 1 commit into from
Aug 26, 2024

Conversation

43081j
Copy link
Contributor

@43081j 43081j commented Aug 21, 2024

Adds a codemod for iterate-value.

This handles the following cases:

// 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:

```ts
// 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]);
```
@thepassle thepassle merged commit 2d915ff into main Aug 26, 2024
3 checks passed
@43081j 43081j deleted the iterating-through-time branch August 26, 2024 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants