rule-writing
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWrite a rule
编写规则
Implement the contract. If none exists, define a compact contract before editing.
rule-research实现契约。如果不存在该契约,请先定义一个简洁的契约再进行编辑。
rule-researchPlan the detector
规划检测器
State the diagnostic condition, required syntax and bindings, unsupported cases, and adversarial tests. Keep this plan short when the user already requested implementation.
Before adding a helper, search for one to reuse:
sh
bunx @rayhanadev/truffler "<symbol-or-behavior>" \
packages/oxlint-plugin-react-doctor/src/plugin \
--kind function,interface,type,constant --limit 20Read , nearby rules, utilities, and tests.
docs/HOW_TO_WRITE_A_RULE.md说明诊断条件、所需语法和绑定、不支持的情况以及对抗性测试。当用户已要求实现时,请保持此规划简洁。
在添加新工具前,先搜索是否有可复用的工具:
sh
bunx @rayhanadev/truffler "<symbol-or-behavior>" \
packages/oxlint-plugin-react-doctor/src/plugin \
--kind function,interface,type,constant --limit 20阅读、相近规则、工具和测试文档。
docs/HOW_TO_WRITE_A_RULE.mdImplement and test
实现与测试
- Write detector pseudocode.
- Add adversarial valid and invalid tests.
- Implement only the contract's supported behavior.
- Reuse utilities before creating new ones.
- Update generated registration with repository commands.
- Run focused tests and package checks.
- Use when real-code feedback could expose noise.
rde-eval - Hand the finished change to .
rule-validate
Account for:
- import aliases and shadowed bindings
- nested functions that do not execute immediately
- transparent JavaScript and TypeScript wrappers
- dynamic computed properties
- imported or unresolved values
- framework escape hatches
- control-flow paths required by the diagnostic claim
- regressions found by reviews or evals
Keep uncertain cases quiet. Match the message to the condition the detector proves.
- 编写检测器伪代码。
- 添加对抗性有效和无效测试用例。
- 仅实现契约支持的行为。
- 优先复用现有工具,再创建新工具。
- 使用仓库命令更新生成的注册信息。
- 运行聚焦测试和包检查。
- 当真实代码反馈可能产生干扰时,使用。
rde-eval - 将完成的修改提交给。
rule-validate
需要考虑以下情况:
- 导入别名和遮蔽绑定
- 不会立即执行的嵌套函数
- 透明的JavaScript和TypeScript包装器
- 动态计算属性
- 已导入或未解析的值
- 框架逃生舱口
- 诊断声明所需的控制流路径
- 评审或评估中发现的回归问题
对不确定的情况保持静默。确保提示信息与检测器验证的条件匹配。
Run repository checks
运行仓库检查
Use commands:
@antfu/nish
nr test
nr lint
nr typecheck
nr format
nr smoke:json-reportUse focused commands while iterating. Record each command that ran.
使用命令:
@antfu/nish
nr test
nr lint
nr typecheck
nr format
nr smoke:json-report迭代过程中使用聚焦命令。记录每个运行的命令。
Report the implementation
报告实现情况
Report changed rules, tests, registration, reused or added utilities, reported behavior, intentional non-goals, and validation results. End with the handoff.
rule-validate报告修改的规则、测试、注册信息、复用或新增的工具、已报告的行为、有意设定的非目标以及验证结果。最后提交给进行验证。
rule-validate