feat(prefer-mock-return-shorthand): greatly improve checking if mutable variables are used by G-Rath · Pull Request #1914 · jest-community/eslint-plugin-jest (original) (raw)

Resolves #1907 (again, mostly)

I'm pretty sure this is just about everything, though I expect there are still some edge cases where the rule still isn't actually safe, but hopefully there should be a lot less of them now.

We still currently treat objects as immuable which is technically unsafe but I think should be pretty reasonable since public object mutation is usually a bad idea - we can explore changing that later (either by default or via an option) based on how much feedback we get from users.

This should also be applied to prefer-mock-promise-shorthand as well, which I'll do "later"