pke / eslint-plugin-redux-saga

ESLint rules for redux-saga
MIT License
135 stars 16 forks source link

yield-effects autofix modifies code functionality violating eslint best practices #71

Closed wdoug closed 4 years ago

wdoug commented 4 years ago

I just tried to add this plugin to our codebase and noticed that if with code like this:

const requests = endpoints.map(endpoint => call(fetch, endpoint));
yield all(requests);

The autofix for the yield-effects rule will update code to be:

const requests = endpoints.map(endpoint => yield call(fetch, endpoint));
yield all(requests);

There are two less than ideal things here, so I'll open a second issue for the second request, but the first is that the runtime functionality of the code is changed. The eslint best practices for applying fixes say this:

Avoid any fixes that could change the runtime behavior of code and cause it to stop working

As of eslint 6.7 (released Nov 2019), there is a new suggestions API that allows editors to provide an optional ability for users to apply fixes that could change the underlying code functionality.

pke commented 4 years ago

Nice catch, @wdoug. There are always edge-cases and as you mentioned in your other filed issues, infinite ones for this one. Thanks for helping this plugin to become more robust. Good idea to use the new suggestion API which I was unaware of until you mentioned it.