Contributing
Thanks for your interest in contributing to AI Guardrails!
Prerequisites
- Node.js ≥ 18
- npm (comes with Node)
Local Setup
Terminal
git clone https://github.com/isaacnewton123/eslint-plugin-ai-guardrails.git
cd eslint-plugin-ai-guardrails
npm installDevelopment Workflow
- Add or update a rule in
src/rules/. - Add tests in
tests/. - Update rule docs in
docs/rules/. - Run quality checks:
Terminal
npm run lint # Zero warnings
npm run build # TypeScript compilation
npm test # All tests must passArchitecture Overview
src/
index.ts Plugin entry point (rules, configs, flatConfigs)
cli.ts CLI initializer (npx eslint-plugin-ai-guardrails init)
configs/
recommended.ts ESLint v8 legacy recommended config
rules/
max-file-lines.ts
max-function-lines.ts
no-orphan-todos.ts
no-ai-obvious-comments.ts
tests/
*.test.ts Unit tests (RuleTester)
integration.test.ts Plugin export smoke tests
docs/
rules/ Per-rule documentation
configuration.md Full options reference
integrations.md Framework-specific setup guides
troubleshooting.md Common issues and fixesKey Design Decisions
- Lazy parser loading:
@typescript-eslint/parseris loaded viarequire()inside a try/catch so the plugin never crashes at import time if the parser isn't installed yet. - Self-referencing flat config:
flatConfigs.recommended.plugins['ai-guardrails']references the plugin object itself, which is required by ESLint v9. - CJS module with ESM compatibility: The package uses
"type": "commonjs"with TypeScript'sexport default, enabling bothrequire()andimportto work.
Rule Authoring Checklist
- Add complete
metaobject:type,docs.description,schema,messages - Set
defaultOptionsarray - Use the compatibility shim for
sourceCode - Write tests covering: defaults, option overrides, edge cases, valid and invalid
- Add docs in
docs/rules/<rule-name>.md - Register the rule in
src/index.ts - Update
src/configs/recommended.tsfor ESLint v8
Testing
Terminal
# Run all tests
npm test
# Run a specific test file
npx jest tests/max-file-lines.test.ts
# Run with coverage
npx jest --coveragePull Requests
- Keep changes focused and reviewable
- Include tests for behavior changes
- Update docs for user-facing changes
- Run
npm run build && npm testbefore submitting
Commit Messages
Use clear, imperative-mood messages:
fix: lazy-load parser to prevent import crashes
feat: add skipSingleLine option to max-function-lines
docs: add SvelteKit integration guide
test: add edge cases for empty filesMaintainer
Hanif Maulana (Isaac Newton) — github.com/isaacnewton123