Authoring ESLint rules
This guide covers how to add or evolve a rule safely.
Workflowโ
- Create or update a rule module under
src/rules/. - Ensure
meta.docsand preset metadata are correct. - Register the rule if needed via the internal rules registry.
- Add rule docs in
docs/rules/<rule-name>.md. - Add tests in
test/for valid/invalid cases and edge behavior.
Metadata checklistโ
meta.docs.descriptionis clear and actionable.meta.docs.urlpoints to the docs page.meta.docs.configsincludes correct preset references.meta.messageshas stable message IDs.
Safety checksโ
Run before opening a PR:
npm run typecheck
npm run test
npm run lint:all
Tipsโ
- Prefer narrow, deterministic diagnostics over broad heuristics.
- Keep rule options minimal and strongly typed.
- Avoid false positives in common workflow patterns.