Skip to content

Conversation

chengcyber
Copy link

@chengcyber chengcyber commented Aug 19, 2025

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:

  1. Linter goes through SourceFileNode now by changing the logic from file.Node.ForEachChild(childVisitor) to patternVisitor(&file.Node)
  2. Add a speicial WildcardTokenKind and WildcardExitTokenKind to mimic the ESLint "*" and "*:exit" pattern selectors

Copy link

netlify bot commented Aug 19, 2025

Deploy Preview for rslint ready!

Name Link
🔨 Latest commit b053be8
🔍 Latest deploy log https://app.netlify.com/projects/rslint/deploys/68b2a0a87fb61a0008532bf4
😎 Deploy Preview https://deploy-preview-289--rslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@CLAassistant
Copy link

CLAassistant commented Aug 22, 2025

CLA assistant check
All committers have signed the CLA.

@chengcyber chengcyber force-pushed the feat-rule-react-of-hooks branch from 84515a8 to b4af881 Compare August 29, 2025 08:58
@chengcyber chengcyber marked this pull request as ready for review August 30, 2025 06:49
@Copilot Copilot AI review requested due to automatic review settings August 30, 2025 06:49
Copy link
Contributor

@Copilot Copilot AI left a 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

@chengcyber chengcyber force-pushed the feat-rule-react-of-hooks branch from 3e25ef6 to b053be8 Compare August 30, 2025 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants