eslint-plugin icon indicating copy to clipboard operation
eslint-plugin copied to clipboard

Rule: `no-direct-event-calls-in-components`

Open sergeysova opened this issue 3 years ago • 0 comments

It can be useful for SSR or SPA with testing approaches.

Should ban direct calls of effector events inside React/Solid components.

Fail:

// no-direct-event-calls-in-components: 'error'
import { somethingHappened } from './model'; // Event

function Example() {
  // Should suggest to wrap it with `useEvent` from "effector-react/scope"
  return <div onClick={() => somethingHappened()} />
}

Okay:

// no-direct-event-calls-in-components: 'error'
import { useEvent } from 'effector-react/scope';
import { somethingHappened } from './model'; // Event

function Example() {
  const handleClick = useUnit(somethingHappened);
  return <div onClick={() => handleClick()} />
}

sergeysova avatar Aug 02 '22 08:08 sergeysova