Skip to content

[ESLint] Assignment like foo.bar.baz = X should warn about foo.bar instead #15510

@gaearon

Description

@gaearon
  let foo = {}
  useEffect(() => {
    foo.bar.baz = 43;
  }, []);

This asks you to include foo.bar.baz into deps. But this doesn't make sense, as you write to it. Instead it should ask to include foo.bar into array.

If foo is a newly created object in render scope then we might additionally nudge you to useRef for it instead. Because otherwise it won't be shared between renders.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions