-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
Description
Is your feature request related to a problem? Please describe.
A single useEffect can be easy to understand. However, multiple useEffect calls in a relatively complex application can be hard to understand.
Describe the solution you'd like
I propose a rule vtex/react-explicit-effects, or vtex/react-documented-effects, that looks for effect react hooks (not only useEffect) and enforces one of two ways to document the purpose of the hook:
- Adding a comment above the hook call, explaining the effect use-case.
import { useEffect } from 'react'
const Potato = () => {
// do this and do that
useEffect(() => {
/// ...
})
}- Using a named function instead of an arrow function:
import { useEffect } from 'react'
const Potato = () => {
useEffect(function doThisAndThat() {
/// ...
})
}Describe alternatives you've considered
Leave people to document effects themselves (which is a big no-no)
rerissondaniel, klzns and estacioneto