-
Notifications
You must be signed in to change notification settings - Fork 10
Port react of hooks rule #289
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
base: main
Are you sure you want to change the base?
Port react of hooks rule #289
Conversation
✅ Deploy Preview for rslint ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
84515a8
to
b4af881
Compare
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.
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 |
internal/plugins/react_hooks/rules/rules_of_hooks/rules_of_hooks.go
Outdated
Show resolved
Hide resolved
internal/plugins/react_hooks/rules/rules_of_hooks/rules_of_hooks.go
Outdated
Show resolved
Hide resolved
internal/plugins/react_hooks/rules/rules_of_hooks/rules_of_hooks.go
Outdated
Show resolved
Hide resolved
3e25ef6
to
b053be8
Compare
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)
WildcardTokenKind
andWildcardExitTokenKind
to mimic the ESLint"*"
and"*:exit"
pattern selectors