Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion schema/ValidatingConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ npx ajv-cli validate -s ./markdownlint/schema/markdownlint-config-schema.json -d
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.
schema instead.

To allow trailing commas in a JSONC file, use the
[`markdownlint-config-schema-jsonc.json`][markdownlint-config-schema-jsonc]
schema instead. (This is based on the strict schema.)

[json-schema]: https://json-schema.org
[markdownlint-config-schema]: markdownlint-config-schema.json
[markdownlint-config-schema-strict]: markdownlint-config-schema-strict.json
[markdownlint-config-schema-jsonc]: markdownlint-config-schema-jsonc.json
11 changes: 11 additions & 0 deletions schema/build-config-schema.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const schemaName = "markdownlint-config-schema.json";
const schemaUri = `https://raw.githubusercontent.com/DavidAnson/markdownlint/v${version}/schema/${schemaName}`;
const schemaStrictName = "markdownlint-config-schema-strict.json";
const schemaStrictUri = `https://raw.githubusercontent.com/DavidAnson/markdownlint/v${version}/schema/${schemaStrictName}`;
const schemaJsoncName = "markdownlint-config-schema-jsonc.json";
const schemaJsoncUri = `https://raw.githubusercontent.com/DavidAnson/markdownlint/v${version}/schema/${schemaJsoncName}`;

// Schema scaffolding
const schema = {
Expand Down Expand Up @@ -691,6 +693,15 @@ const schemaStrict = {
const schemaFileStrict = path.join(__dirname(import.meta), schemaStrictName);
await fs.writeFile(schemaFileStrict, JSON.stringify(schemaStrict, null, " "));

// Create and write JSONC schema
const schemaJsonc = {
...schemaStrict,
"$id": schemaJsoncUri,
"allowTrailingCommas": true
};
const schemaFileJsonc = path.join(__dirname(import.meta), schemaJsoncName);
await fs.writeFile(schemaFileJsonc, JSON.stringify(schemaJsonc, null, " "));

// Write TypeScript declaration file
const declarationStrictName = path.join(__dirname(import.meta), "..", "lib", "configuration-strict.d.ts");
schemaStrict.title = "ConfigurationStrict";
Expand Down
Loading