javascript icon indicating copy to clipboard operation
javascript copied to clipboard

no-restricted-syntax for...of warning potentially confusing

Open gpoole opened this issue 4 years ago • 2 comments

The warning about using for...of states that regenerator-runtime is required:

iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.

The explanation creates the impression regenerator-runtime is essential for any code using for...of, which is no longer true, as for...of seems to be fairly widely supported.

I think it could make sense to reword the explanation to state that regenerator may be required and that imperative loops should be avoided.

gpoole avatar May 18 '21 09:05 gpoole

It’s still true if you support older browsers, which most companies do indeed have to do.

It’s fine to improve the message tho.

ljharb avatar May 18 '21 15:05 ljharb

Rephrased the message and sent PR

ayushi-naphade avatar May 22 '22 06:05 ayushi-naphade