Create strict JSON Schema for configuration (standalone for ease of use) and corresponding strict TypeScript type (via extends for conciseness) (fixes #1248).

This commit is contained in:
David Anson 2024-08-27 20:47:33 -07:00
parent bbca3ad209
commit 9c8e7156e1
10 changed files with 3070 additions and 1207 deletions

View file

@ -1,7 +1,7 @@
# Validating Configuration
A [JSON Schema][json-schema] is provided to enable validating configuration
objects: [`markdownlint-config-schema.json`][markdownlint-config-schema]
objects: [`markdownlint-config-schema.json`][markdownlint-config-schema].
Some editors automatically use a JSON Schema with files that reference it. For
example, a `.markdownlint.json` file with:
@ -16,13 +16,11 @@ A JSON Schema validator can be used to check configuration files like so:
npx ajv-cli validate -s ./markdownlint/schema/markdownlint-config-schema.json -d "**/.markdownlint.{json,yaml}" --strict=false
```
By default, any rule name is valid in order to allow for custom rules. To ensure
that only built-in rules are used, change the value of `#/additionalProperties`
(at the bottom of the schema file) to `false` before validating:
```json
"additionalProperties": false
```
By default, any rule name is valid because of custom rules. To allow only
built-in rules, use the
[`markdownlint-config-schema-strict.json`][markdownlint-config-schema-strict]
JSON Schema instead.
[json-schema]: https://json-schema.org
[markdownlint-config-schema]: markdownlint-config-schema.json
[markdownlint-config-schema-strict]: markdownlint-config-schema-strict.json