FG
🌐 Web & Full-Stack

[ESLint] Feedback for 'exhaustive-deps' lint rule

Freshabout 7 years ago
Mar 14, 20260 views
Confidence Score89%
89%

Problem

Common Answers πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘ We analyzed the comments on this post to provide some guidance: https://github.com/facebook/react/issues/14920#issuecomment-471070149. πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘πŸ’‘ ---- What is this This is a new ESLint rule that verifies the list of dependencies for Hooks like `useEffect` and similar, protecting against the stale closure pitfalls. For most cases it has an autofix. We'll add more documentation over the next weeks. Installation [code block] ESLint config: [code block] Simple test case to verify the rule works: [code block] The lint rule complains but my code is fine! If this new `react-hooks/exhaustive-deps` lint rule fires for you but you think your code is correct, please post in this issue. ---- BEFORE YOU POST A COMMENT Please include these three things: 1. A CodeSandbox demonstrating a minimal code example that still expresses your intent (not "foo bar" but actual UI pattern you're implementing). 2. An explanation of the steps a user does and what you expect to see on the screen. 3. An explanation of the intended API of your Hook/component. But my case is simple, I don't want to include those things! It might be simple to you β€” but it’s not at all simple to us. If your comment doesn't include either of them (e.g. no CodeSandbox link), we will hide your comment because it’s very hard to track the discussion otherwise. Thank you for respecting everyone’s time by including them.

Error Output

error and offer autofix to [props.name]

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
84% confidence100% success rate3 verificationsLast verified Mar 14, 2026

Solution: [ESLint] Feedback for 'exhaustive-deps' lint rule

Low Risk

[code block] I expect the lint to fix the deps into `[emails, props.onSubmit]`, but right now it always fix the deps into `[emails, props]`. > 1. A CodeSandbox demonstrating a minimal code example that still expresses your intent (not "foo bar" but actual UI pattern you're implementing). https://codesandbox.io/s/xpr69pllmz > 2. An explanation of the steps a user does and what you expect to see

84

Trust Score

3 verifications

100% success
  1. 1

    I expect the lint to fix the deps into `[emails, props.onSubmit]`, but right now

    I expect the lint to fix the deps into `[emails, props.onSubmit]`, but right now it always fix the deps into `[emails, props]`.

  2. 2

    > 1. A CodeSandbox demonstrating a minimal code example that still expresses you

    > 1. A CodeSandbox demonstrating a minimal code example that still expresses your intent (not "foo bar" but actual UI pattern you're implementing).

  3. 3

    https://codesandbox.io/s/xpr69pllmz

    https://codesandbox.io/s/xpr69pllmz

  4. 4

    > 2. An explanation of the steps a user does and what you expect to see on the s

    > 2. An explanation of the steps a user does and what you expect to see on the screen.

Validation

Resolved in facebook/react GitHub issue #14920. Community reactions: 2 upvotes.

Verification Summary

Worked: 3
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

reactjavascripttype:-discussioncomponent:-eslint-rules