Port react of hooks rule #289
Open
chengcyber wants to merge 6 commits into
Open
Conversation
✅ Deploy Preview for rslint ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
84515a8 to
b4af881
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements the "rules-of-hooks" rule from eslint-plugin-react-hooks in Go, providing comprehensive React Hooks validation within rslint. It includes sophisticated code path analysis to track hook calls throughout component and hook functions.
- Implements the core React hooks rules validation to ensure hooks are called in the correct order and context
- Adds comprehensive code path analysis framework to track control flow for hook validation
- Includes extensive test coverage with 1700+ lines of test cases covering valid and invalid hook usage patterns
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/rule/rule.go | Adds wildcard token kinds for universal AST node listeners |
| internal/plugins/react_hooks/rules/rules_of_hooks/rules_of_hooks.go | Main implementation of the rules-of-hooks rule with hook validation logic |
| internal/plugins/react_hooks/rules/rules_of_hooks/rules_of_hooks_test.go | Comprehensive test suite with valid and invalid hook usage scenarios |
| internal/plugins/react_hooks/code_path_analysis/*.go | Complete code path analysis framework for tracking control flow |
| internal/plugins/react_hooks/*.go | Plugin infrastructure and rule registration |
| internal/linter/linter.go | Updates linter to support wildcard listeners for all AST nodes |
3e25ef6 to
b053be8
Compare
Contributor
|
@chengcyber Huge apologies for the long delay on this! This PR completely slipped through the cracks on our end. Thank you so much for putting this together. Since it's been a while, there are likely some merge conflicts now. Are you still interested in pursuing this? |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Port react-of-hooks rule for
eslint-plugin-react-hooks.One task of #226
Details
Besides the implementation of this rule. There are some noticeable changes I would like to call out:
file.Node.ForEachChild(childVisitor)topatternVisitor(&file.Node)WildcardTokenKindandWildcardExitTokenKindto mimic the ESLint"*"and"*:exit"pattern selectors