en un clic
rule-writing
// Write React Doctor rules from a validated rule contract. Use when implementing oxlint plugin rules, planning AST/scope/control-flow detection, designing adversarial tests, adding utilities, or updating rule registration.
// Write React Doctor rules from a validated rule contract. Use when implementing oxlint plugin rules, planning AST/scope/control-flow detection, designing adversarial tests, adding utilities, or updating rule registration.
| name | rule-writing |
| description | Write React Doctor rules from a validated rule contract. Use when implementing oxlint plugin rules, planning AST/scope/control-flow detection, designing adversarial tests, adding utilities, or updating rule registration. |
Use this as stage 2 of the React Doctor rule pipeline.
Pipeline:
rule-research defines the rule contract.rule-writing turns the contract into tests and implementation.rule-validate verifies noise, correctness, PR copy, and review feedback.If no rule contract exists, create a compact one first or use the research skill before editing.
Before substantial edits, show the implementation plan:
If the user asked for direct implementation, keep the plan short and proceed.
docs/HOW_TO_WRITE_A_RULE.md when available.Use @antfu/ni commands in this repo:
nr test
nr lint
nr typecheck
nr format
nr smoke:json-report
Use narrower package or file-specific commands when iterating, then record what passed.
Plan against real AST behavior:
Pseudocode shape:
for each file:
collect framework/library imports and aliases
find candidate syntax
resolve bindings needed for identity
skip unsupported or unknown cases
analyze only the local paths required by the rule
report only when the exact diagnostic condition is proven
Design varied invalid and valid cases:
Include valid tests for v1 non-goals so the rule stays quiet where it should.
utils/ only when there is real reuse.When the writing stage is done, report:
Implemented:
- <rule, tests, registry, utilities>
Detector behavior:
- <what reports>
- <what intentionally stays quiet>
Validation run:
- <focused tests/checks>
Known v1 non-goals:
- <unsupported cases preserved from the rule contract>
Next stage:
- Run `rule-validate`.
Validate implemented React Doctor rules before PR or merge. Use after rule tests pass to review correctness, run RDE against OSS, inspect false positives, generate changesets, write PR descriptions, and triage bot or human review comments.
Research and scope React Doctor rule ideas before implementation. Use when validating a proposed rule, grounding it in docs, OSS examples, RDE evidence, false-positive traps, detector precision, or v1 non-goals.
Use when finishing a feature, fixing a bug, before committing React code, or when the user types `/doctor`, asks to scan, triage, or clean up React diagnostics. Covers lint, accessibility, bundle size, architecture. Includes a regression check and a full local-triage workflow that fetches the canonical playbook.