ember-cli / eslint-plugin-ember

An ESLint plugin that provides set of rules for Ember applications based on commonly known good practices.
MIT License
262 stars 204 forks source link

ember/no-runloop #2079

Open amk221 opened 10 months ago

amk221 commented 10 months ago

Would it be possible to improve the docs around ember/no-runloop?

NullVoxPopuli commented 10 months ago

Fresh ember-cli apps use @ember/runloop in instance initializer tests.

this is probably a bug and the tests should be updated :sweat_smile:

The readme talks about async cleanup, but there are so many more features in there,

like more alternatives to things you listed? I imagine it'd be a bit situational -- and in some cases not needed? but maybe having a few examples would be good -- more examples never hurts.

Its necessary to wrap code in run in order for ember/test-helpers setupOnerror/resetOnerror to work.

It is not

setupOnError can happen pre-visit, pre-render, and resetOnError, I usally do after every test so I don't forget about it.

https://github.com/NullVoxPopuli/limber/blob/main/apps/repl/tests/test-helper.ts#L22

amk221 commented 10 months ago

Thanks :)

For this one:

Its necessary to wrap code in run in order for ember/test-helpers setupOnerror/resetOnerror to work.

https://github.com/emberjs/ember-test-helpers/issues/1128

In order for setupOnerror to work, the code that throws needs to be in a run.

NullVoxPopuli commented 10 months ago

if you don't want code in a run, you could use window.addEventListener('error'? perhaps?

using run at all is some api leakage :sweat_smile:

amk221 commented 10 months ago

setupOnerror doesn't work with window.addEventListener though? Anyway, that's off topic. My point is, there are reasons to use the @ember/runloop (and therefore ignore the eslint warning). At this moment in time.