buildo / eslint-plugin-no-loops

It's 2024 and you still use loops?

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is it about?

Uzlopak opened this issue · comments

Is it suggested to use the assumed slow forEach() .map() .filter() etc. methods of arrays?

Sorry, I don't understand the question. Could you elaborate?

yes, sure :)
Your plugin proposes that loops are bad practice ("loops are bad").

Why are you considering them as bad practice. And what are the alternatives? Should we use the slower Array-Methods if we want to iterate over Arrays?

I am open for considering loops as bad practice, but performance wise I consider the classical for loop to the best method to process large arrays and stuff.

But maybe I am missing somehow the point. So I would like to know more.

If your use case is affected by the performance of loops vs patterns like map or reduce, I recommend not using the plugin and potentially running some microbenchmarks.

I'd go as far as saying that most applications don't fall in the case where any potential performance hit of map vs loop would make any difference.

For those applications the choice is purely semantics, so depending on whether you find loops more or less readable than combinators you can enable this plugin or not.

Thank you for your explaination