effector/eslint-plugin

Rule: `no-effects-in-components`

San4es opened this issue · 0 comments

Using effects in components typically leads to business logic leaks into view. A cleaner approach is to use events instead of effects.
I suggest to add corresponding rule to warn a user about it.

// Fail
function Component() {
  useUnit(someFx)
  useEvent(someFx)
  useEffect(() => {
    someFx()
    () => someFx()
  }, [])
  const callback = () => {
    someFx()
  }
  useCallback(() => {
    someFx()
  }, [])
}