-
Notifications
You must be signed in to change notification settings - Fork 47k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add eslint-plugin-react-hooks/exhaustive-deps rule to check stale closure dependencies #14636
Merged
+2,235
−5
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
c0eafd8
Add ESLint rule for useEffect/useCallback/useMemo Hook dependencies
calebmer 6e2ba67
Fix ReactiveDependencies rule
jamiebuilds 4704a98
fix lint errors
jamiebuilds 6f67ef1
Support useLayoutEffect
gaearon da75f31
Add some failing tests and comments
gaearon 58183fe
Gather dependencies in child scopes too
gaearon d1515f4
If we don't find foo.bar.baz in deps, try foo.bar, then foo
gaearon 57ebe56
foo is enough for both foo.bar and foo.baz
gaearon 369aa61
Shorter rule name
gaearon 2df41d8
Add fixable meta
gaearon 3b3d7da
Remove a bunch of code and start from scratch
gaearon d4d501b
[WIP] Only report errors from dependency array
gaearon 695693c
Fix typo
gaearon 340bffb
[Temp] Skip all tests
gaearon 3832eb3
Fix the first test
gaearon 244a1ff
Revamp the test suite
gaearon 58e38ca
Fix [foo] to include foo.bar
gaearon 0aea58e
Don't suggest call expressions
gaearon 14b2229
Special case 'current' for refs
gaearon 366d5df
Don't complain about known static deps
gaearon 3d46a1e
Support useImperativeHandle
gaearon 3679627
Better punctuation and formatting
gaearon 5d2c991
More uniform message format
gaearon e0203cb
Treat React.useRef/useState/useReducer as static too
gaearon 54c2e16
Add special message for ref.current
gaearon 6fd2d12
Add a TODO case
gaearon 0c722bb
Alphabetize the autofix
gaearon 12aeaca
Only alphabetize if it already was
gaearon c40bcaa
Don't add static deps by default
gaearon 56785b5
Add an undefined variable case
gaearon 294b474
Tweak wording
gaearon 2f86a69
Rename to exhaustive-deps
gaearon 8b554ca
Clean up / refactor a little bit
gaearon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this could also be space for a future "sorted-deps" rule? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One simple compromise would be to only add at the end by default, but alphabetize if the current array is empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we could alphabetize if existing list is alphabetized. 😏