A collection of lint rules for JSON Schema with metadata, examples, and documentation generation.
- Rule Metadata: Each rule is defined as a JSON file with a title, description, message, vocabularies, valid/invalid examples, and references.
- Schema Validation: All rule files are validated against a central
rule.schema.json
. - Documentation Generation: Automatically generates Markdown documentation for each rule in the
docs/
directory. - Best Practices: Includes rules to promote best practices, such as preferring
const
over single-valueenum
.
json-schema-lint-rules/
├── docs/ # Generated Markdown documentation for rules
├── rules/ # Rule definitions organized
├── .dockerignore
├── Dockerfile
├── LICENSE
├── rule.schema.json # JSON Schema for rule metadata
├── generate.mjs # Script to validate rules and generate docs
├── package.json
├── package-lock.json
└── .gitignore
npm install
Run the documentation generator and validate JSON files:
node generate.mjs
This will validate all rules against rule.schema.json
and generate Markdown documentation in the docs/
directory.
You can also validate rules separately:
npm run validate:rules
The project includes a pre-commit hook that automatically formats JSON schema files using jsonschema fmt
. This runs automatically when you make a commit that includes changes to:
rule.schema.json
- Any files in the
rules/
directory
To set up the pre-commit hook (already configured in the project):
npm install
The hook will automatically run when you make commits that include changes to JSON schema files.
Generate Markdown documentation for each rule:
npm run build
The generated docs will appear in the docs/
directory, organized by category.
You can use Docker to build and run this project without installing Node.js locally.
docker build -t jsonschema-lint-rules .
docker run --rm -v $(pwd):/app jsonschema-lint-rules
This will execute the documentation generator inside a container. The output will appear in the docs/
directory of your local project.
- The Dockerfile and .dockerignore are provided for convenience.
- You can override the default command if needed, e.g.:
docker run --rm -v $(pwd):/app jsonschema-lint-rules npm run validate:rules
Generate Markdown documentation for each rule:
npm run build
The generated docs will appear in the docs/
directory, organized by category.
- Create a new JSON file in the appropriate category under
rules/
. - Follow the structure defined in
rule.schema.json
. - Add before and after examples.
- Run validation and documentation generation scripts.