Thanks for your interest in contributing! This document provides guidelines and information for developers working on React Analyzer.
Current Phase: MVP Development (v0.1.0)
- CLI interface and argument parsing
- File validation and error handling
- Help and version commands
- Tree-sitter parser integration (in progress)
- AST traversal and semantic analysis
-
no-object-depsrule implementation - Output formatting with diagnostics
- Go 1.21 or later
- Git
- Make (optional, for convenience commands)
-
Clone the repository:
git clone https://github.com/rautio/react-analyzer cd react-analyzer -
Install dependencies:
go mod download
-
Build the project:
go build -o react-analyzer ./cmd/react-analyzer
-
Run tests:
go test ./... -
Test the CLI:
./react-analyzer test/fixtures/simple.tsx
react-analyzer/
├── cmd/
│ └── react-analyzer/ # CLI entry point
│ └── main.go # Argument parsing, orchestration
├── internal/
│ ├── cli/ # CLI implementation
│ │ ├── help.go # Help text
│ │ └── runner.go # Analysis orchestration
│ ├── parser/ # Tree-sitter wrapper (planned)
│ │ ├── parser.go # Parser interface
│ │ └── node.go # AST node wrapper
│ ├── analyzer/ # Analysis logic (planned)
│ │ ├── analyzer.go # Main analyzer
│ │ └── scope.go # Scope tracking
│ └── rules/ # Rule implementations (planned)
│ ├── rule.go # Rule interface
│ └── no_object_deps.go # First MVP rule
├── test/
│ └── fixtures/ # Test React files
├── prompts/ # Design documents
│ ├── technical_design.md # Architecture overview
│ ├── mvp_scope.md # MVP scope definition
│ └── interfaces.md # CLI interface spec
├── go.mod
├── go.sum
└── README.md
- Go 1.21+ - Performance, concurrency, easy distribution
- tree-sitter - Fast, incremental parsing of TypeScript/JSX
- Standard library - Minimal dependencies for MVP
- Incremental Development - Build working features iteratively
- Simple First - Avoid premature abstraction
- Test-Driven - Write tests alongside implementation
- User-Focused - Optimize for clear error messages and fast feedback
1. CLI Layer (cmd/react-analyzer/, internal/cli/)
- Argument parsing using standard library
flagpackage - File validation
- Output formatting
- Exit code handling
2. Parser Layer (internal/parser/) - In Progress
- tree-sitter wrapper
- AST node abstraction
- Semantic helpers (IsComponent, IsHookCall, etc.)
3. Analyzer Layer (internal/analyzer/) - Planned
- Scope analysis
- Symbol tracking
- Variable stability detection
4. Rule Engine (internal/rules/) - Planned
- Rule interface
- Rule registration
- Diagnostic generation
-
Create a branch:
git checkout -b feature/your-feature-name
-
Make your changes
- Write code
- Add tests
- Update documentation
-
Test your changes:
# Run tests go test ./... # Build and test CLI go build -o react-analyzer ./cmd/react-analyzer ./react-analyzer test/fixtures/simple.tsx
-
Commit your changes:
git add . git commit -m "Add feature: description"
Run all tests:
go test ./...Run with coverage:
go test -cover ./...Run with race detection:
go test -race ./...Test CLI manually:
# Build first
go build -o react-analyzer ./cmd/react-analyzer
# Test various scenarios
./react-analyzer --help
./react-analyzer --version
./react-analyzer test/fixtures/simple.tsx
./react-analyzer --verbose test/fixtures/simple.tsx
./react-analyzer missing.tsx # Should error- Follow standard Go conventions (
gofmt,go vet) - Write clear, self-documenting code
- Add comments for complex logic
- Keep functions small and focused
Create test React files in test/fixtures/:
cat > test/fixtures/my-test.tsx << 'EOF'
import React from 'react';
function MyComponent() {
return <div>Test</div>;
}
export default MyComponent;
EOFGoal: Working CLI with one rule
- CLI interface (Week 1, Days 1-2)
- Parser integration (Week 1, Days 3-4)
- Scope analysis (Week 1, Day 5)
-
no-object-depsrule (Week 2, Days 1-2) - Output formatter (Week 2, Days 3-4)
- Testing & polish (Week 2, Day 5)
Deliverable: CLI tool that detects inline objects in hook dependencies
-
no-unstable-propsrule - Configuration file support
- Multiple file analysis
- Enhanced error messages
- Language Server Protocol (LSP) implementation
- VS Code extension
- Real-time analysis
- Auto-fix suggestions
- Cross-file analysis (
memo-unstable-props) - Import resolution
- Component graph visualization
- Performance profiling integration
Based on POC validation:
| Operation | Target | Current Status |
|---|---|---|
| Parse 30-line file | <1ms | ✅ 80μs (POC) |
| Parse 233-line file | <5ms | ✅ 1.85ms (POC) |
| Single file analysis | <100ms | 🎯 On track |
| Full project (10k LOC) | <10s | 🎯 On track |
See tree-sitter-poc/POC_RESULTS.md for detailed benchmarks.
Key design documents in prompts/:
technical_design.md- Overall architecture and technology decisionsmvp_scope.md- MVP scope and simplificationsinterfaces.md- CLI interface specificationimplementation_plan.md- Detailed implementation phases
(To be defined as we approach first release)
- Update version in
cmd/react-analyzer/main.go - Update CHANGELOG.md
- Tag release:
git tag v0.1.0 - Build binaries for all platforms
- Create GitHub release
- Questions? Open a GitHub issue
- Bugs? Open a GitHub issue with reproduction steps
- Ideas? Open a GitHub discussion
Be respectful, collaborative, and constructive. We're all here to build something useful together.
TBD