Port Rule
Port ESLint rules to rslint with 1:1 behavior parity.
Prerequisites
Step 1: Get Rule Name
If user didn't provide the rule name, ask for it. Accept formats:
- •ESLint core:
no-console,no-unused-vars - •TypeScript-ESLint:
@typescript-eslint/no-explicit-any - •Other plugins:
import/no-duplicates,react/jsx-uses-react
Step 2: Get Rule Documentation URL
If user already provided a documentation URL, skip this step.
Otherwise, ask user to choose:
- •Auto search (Recommended) - Run the search script to find documentation
- •Provide URL manually - User provides the URL directly
For auto search, run:
bash
node agents/port-rule/scripts/search_rule.mjs <rule-name>
The script searches:
- •ESLint core rules → https://eslint.org/docs/latest/rules/
- •TypeScript-ESLint rules → https://typescript-eslint.io/rules/
- •Other plugins → GitHub repositories
After search:
- •If found: Show results and ask user to confirm the URLs are correct
- •If not found: Ask user to provide the documentation URL manually
Workflow
After prerequisites are complete, follow the phases in PORT_RULE.md:
- •Phase 0: Branch Setup - Create feature branch from main
- •Phase 1: Preparation - Collect test cases and identify edge cases
- •Phase 2: Implementation - Write Go rule, tests, and documentation
- •Phase 3: Integration - Add JS tests and register rule
- •Phase 4: Verification - Build binary and run all tests
- •Phase 5: Submission - Commit and create PR
Quick Reference
Directory Structure:
- •Core rules:
internal/rules/<rule_name_snake_case>/ - •Plugin rules:
internal/plugins/<plugin_name>/rules/<rule_name_snake_case>/
Key Commands:
bash
# Build binary (REQUIRED before JS tests) cd packages/rslint && pnpm run build:bin # Run Go tests go test -count=1 ./internal/rules/<rule_name> # Run JS tests cd packages/rslint-test-tools && npx rstest run --testTimeout=10000 <rule-name> # Lint and format checks (REQUIRED before commit) pnpm format:check && pnpm lint:go # Auto-fix formatting issues pnpm format && pnpm format:go
References
- •PORT_RULE.md - Complete porting guide with code templates
- •AST_PATTERNS.md - AST traversal patterns
- •UTILS_REFERENCE.md - Utility functions
- •QUICK_REFERENCE.md - Commands cheatsheet