Skip to content

Add prefer-iterator-to-array-at-end rule#2938

Open
nami8824 wants to merge 2 commits intosindresorhus:mainfrom
nami8824:prefer-iterator-to-array-at-end
Open

Add prefer-iterator-to-array-at-end rule#2938
nami8824 wants to merge 2 commits intosindresorhus:mainfrom
nami8824:prefer-iterator-to-array-at-end

Conversation

@nami8824
Copy link
Copy Markdown
Contributor

Closes #2767

What

Adds a new rule that enforces calling .toArray() at the end of an iterator method chain, rather than in the middle.

Notes

  • flatMap is intentionally excluded: Iterator#flatMap requires the callback to return an iterable, while Iterator#flatMap requires the callback to return an iterable, whereas Array#flatMap does not.
  • Callbacks with more than 2 parameters are skipped: Array#filter/map passes a third argument (the array itself), but Iterator#filter/map does not.

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.

Rule proposal: Enforce .toArray() at the end of Iterator methods chain

2 participants