2019-10-30 20:37:06 -07:00
|
|
|
// @ts-check
|
|
|
|
|
2024-11-28 20:36:44 -08:00
|
|
|
import fs from "node:fs/promises";
|
|
|
|
import path from "node:path";
|
2024-12-03 19:58:28 -08:00
|
|
|
/** @type {import("markdownlint").Rule[]} */
|
2024-11-28 20:36:44 -08:00
|
|
|
import rules from "../lib/rules.mjs";
|
|
|
|
import jsonSchemaToTypeScript from "json-schema-to-typescript";
|
|
|
|
import { version } from "../lib/constants.mjs";
|
|
|
|
import { __dirname } from "../test/esm-helpers.mjs";
|
2023-11-24 15:23:36 -08:00
|
|
|
|
2024-08-27 20:47:33 -07:00
|
|
|
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}`;
|
2016-10-05 22:21:54 -07:00
|
|
|
|
|
|
|
// Schema scaffolding
|
2018-04-27 22:05:34 -07:00
|
|
|
const schema = {
|
2023-09-27 22:48:01 -07:00
|
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
2023-11-24 15:23:36 -08:00
|
|
|
"$id": schemaUri,
|
2023-09-27 22:48:01 -07:00
|
|
|
"title": "markdownlint configuration schema",
|
2016-10-05 22:21:54 -07:00
|
|
|
"type": "object",
|
2025-09-16 20:47:08 -07:00
|
|
|
/** @type {Object.<string, object>} */
|
2016-10-05 22:21:54 -07:00
|
|
|
"properties": {
|
2023-11-24 15:23:36 -08:00
|
|
|
"$schema": {
|
|
|
|
"description": "JSON Schema URI (expected by some editors)",
|
|
|
|
"type": "string",
|
|
|
|
"default": schemaUri
|
|
|
|
},
|
2016-10-05 22:21:54 -07:00
|
|
|
"default": {
|
|
|
|
"description": "Default state for all rules",
|
2025-09-13 15:35:07 -07:00
|
|
|
"oneOf": [
|
2025-09-16 20:47:08 -07:00
|
|
|
{ "type": "boolean" },
|
2025-09-19 22:03:06 -07:00
|
|
|
// "off" not (yet) supported because behavior of older versions would be to enable
|
|
|
|
{ "enum": [ "error", "warning" ] }
|
2025-09-13 15:35:07 -07:00
|
|
|
],
|
2016-10-05 22:21:54 -07:00
|
|
|
"default": true
|
2017-05-19 22:36:46 -07:00
|
|
|
},
|
|
|
|
"extends": {
|
|
|
|
"description": "Path to configuration file to extend",
|
2021-01-19 20:41:04 -08:00
|
|
|
"type": [
|
|
|
|
"string",
|
|
|
|
"null"
|
|
|
|
],
|
2017-05-19 22:36:46 -07:00
|
|
|
"default": null
|
2016-10-05 22:21:54 -07:00
|
|
|
}
|
|
|
|
},
|
2020-09-15 21:48:00 -07:00
|
|
|
"additionalProperties": {
|
2021-06-15 12:33:55 -07:00
|
|
|
"type": [
|
2020-09-15 21:48:00 -07:00
|
|
|
"boolean",
|
|
|
|
"object"
|
|
|
|
]
|
|
|
|
}
|
2016-10-05 22:21:54 -07:00
|
|
|
};
|
2025-09-16 20:47:08 -07:00
|
|
|
/** @type {Object.<string, string[]>} */
|
2018-04-27 22:05:34 -07:00
|
|
|
const tags = {};
|
2016-10-05 22:21:54 -07:00
|
|
|
|
|
|
|
// Add rules
|
2022-06-08 22:10:27 -07:00
|
|
|
for (const rule of rules) {
|
2025-03-17 20:10:25 -07:00
|
|
|
const ruleName = rule.names[0];
|
2022-06-08 22:10:27 -07:00
|
|
|
for (const tag of rule.tags) {
|
2018-04-27 22:05:34 -07:00
|
|
|
const tagRules = tags[tag] || [];
|
2025-03-17 20:10:25 -07:00
|
|
|
tagRules.push(ruleName);
|
2016-10-05 22:21:54 -07:00
|
|
|
tags[tag] = tagRules;
|
2022-06-08 22:10:27 -07:00
|
|
|
}
|
2018-04-27 22:05:34 -07:00
|
|
|
const scheme = {
|
2023-11-03 20:23:13 -07:00
|
|
|
"description":
|
|
|
|
`${rule.names.join("/")} : ${rule.description} : ${rule.information}`,
|
2025-09-13 15:35:07 -07:00
|
|
|
"oneOf": [
|
2025-09-16 20:47:08 -07:00
|
|
|
{ "type": "boolean" },
|
2025-09-19 22:03:06 -07:00
|
|
|
// "off" not (yet) supported because behavior of older versions would be to enable
|
|
|
|
{ "enum": [ "error", "warning" ] }
|
2025-09-13 15:35:07 -07:00
|
|
|
],
|
2016-10-05 22:21:54 -07:00
|
|
|
"default": true
|
|
|
|
};
|
2025-09-13 15:35:07 -07:00
|
|
|
const subscheme = {
|
|
|
|
"type": "object",
|
2025-09-18 21:21:12 -07:00
|
|
|
"additionalProperties": false,
|
|
|
|
"properties": {
|
|
|
|
"severity": {
|
|
|
|
"description": "Rule severity",
|
|
|
|
"type": "string",
|
2025-09-19 22:03:06 -07:00
|
|
|
"enum": [ "error", "warning", "off" ],
|
2025-09-18 21:21:12 -07:00
|
|
|
"default": "error"
|
|
|
|
}
|
|
|
|
}
|
2025-09-13 15:35:07 -07:00
|
|
|
};
|
2025-09-18 21:21:12 -07:00
|
|
|
scheme.oneOf.push(subscheme);
|
|
|
|
/* eslint-disable camelcase */
|
2025-03-17 20:10:25 -07:00
|
|
|
switch (ruleName) {
|
2025-06-07 04:54:23 +02:00
|
|
|
case "MD001":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.front_matter_title = {
|
|
|
|
"description": "RegExp for matching title in front matter",
|
|
|
|
"type": "string",
|
|
|
|
"default": "^\\s*title\\s*[:=]"
|
2025-06-07 04:54:23 +02:00
|
|
|
};
|
|
|
|
break;
|
2016-10-05 22:21:54 -07:00
|
|
|
case "MD003":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.style = {
|
|
|
|
"description": "Heading style",
|
|
|
|
"type": "string",
|
|
|
|
"enum": [
|
|
|
|
"consistent",
|
|
|
|
"atx",
|
|
|
|
"atx_closed",
|
|
|
|
"setext",
|
|
|
|
"setext_with_atx",
|
|
|
|
"setext_with_atx_closed"
|
|
|
|
],
|
|
|
|
"default": "consistent"
|
2016-10-05 22:21:54 -07:00
|
|
|
};
|
|
|
|
break;
|
|
|
|
case "MD004":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.style = {
|
|
|
|
"description": "List style",
|
|
|
|
"type": "string",
|
|
|
|
"enum": [
|
|
|
|
"consistent",
|
|
|
|
"asterisk",
|
|
|
|
"plus",
|
|
|
|
"dash",
|
|
|
|
"sublist"
|
|
|
|
],
|
|
|
|
"default": "consistent"
|
2016-10-05 22:21:54 -07:00
|
|
|
};
|
|
|
|
break;
|
|
|
|
case "MD007":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.indent = {
|
|
|
|
"description": "Spaces for indent",
|
|
|
|
"type": "integer",
|
|
|
|
"minimum": 1,
|
|
|
|
"default": 2
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.start_indented = {
|
|
|
|
"description": "Whether to indent the first level of the list",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": false
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.start_indent = {
|
|
|
|
"description":
|
|
|
|
"Spaces for first level indent (when start_indented is set)",
|
|
|
|
"type": "integer",
|
|
|
|
"minimum": 1,
|
|
|
|
"default": 2
|
2016-10-05 22:21:54 -07:00
|
|
|
};
|
|
|
|
break;
|
|
|
|
case "MD009":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.br_spaces = {
|
|
|
|
"description": "Spaces for line break",
|
|
|
|
"type": "integer",
|
|
|
|
"minimum": 0,
|
|
|
|
"default": 2
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.list_item_empty_lines = {
|
|
|
|
"description": "Allow spaces for empty lines in list items",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": false
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.strict = {
|
|
|
|
"description": "Include unnecessary breaks",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": false
|
2016-10-05 22:21:54 -07:00
|
|
|
};
|
|
|
|
break;
|
|
|
|
case "MD010":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.code_blocks = {
|
|
|
|
"description": "Include code blocks",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": true
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.ignore_code_languages = {
|
|
|
|
"description": "Fenced code languages to ignore",
|
|
|
|
"type": "array",
|
|
|
|
"items": {
|
|
|
|
"type": "string"
|
2022-04-28 21:09:06 -07:00
|
|
|
},
|
2025-09-18 21:21:12 -07:00
|
|
|
"default": []
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.spaces_per_tab = {
|
|
|
|
"description": "Number of spaces for each hard tab",
|
|
|
|
"type": "integer",
|
|
|
|
"minimum": 0,
|
|
|
|
"default": 1
|
2016-10-05 22:21:54 -07:00
|
|
|
};
|
|
|
|
break;
|
|
|
|
case "MD012":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.maximum = {
|
|
|
|
"description": "Consecutive blank lines",
|
|
|
|
"type": "integer",
|
|
|
|
"minimum": 1,
|
|
|
|
"default": 1
|
2016-10-05 22:21:54 -07:00
|
|
|
};
|
|
|
|
break;
|
|
|
|
case "MD013":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.line_length = {
|
|
|
|
"description": "Number of characters",
|
|
|
|
"type": "integer",
|
|
|
|
"minimum": 1,
|
|
|
|
"default": 80
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.heading_line_length = {
|
|
|
|
"description": "Number of characters for headings",
|
|
|
|
"type": "integer",
|
|
|
|
"minimum": 1,
|
|
|
|
"default": 80
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.code_block_line_length = {
|
|
|
|
"description": "Number of characters for code blocks",
|
|
|
|
"type": "integer",
|
|
|
|
"minimum": 1,
|
|
|
|
"default": 80
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.code_blocks = {
|
|
|
|
"description": "Include code blocks",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": true
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.tables = {
|
|
|
|
"description": "Include tables",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": true
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.headings = {
|
|
|
|
"description": "Include headings",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": true
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.strict = {
|
|
|
|
"description": "Strict length checking",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": false
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.stern = {
|
|
|
|
"description": "Stern length checking",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": false
|
2016-10-05 22:21:54 -07:00
|
|
|
};
|
|
|
|
break;
|
2019-03-24 21:50:56 -07:00
|
|
|
case "MD022":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.lines_above = {
|
|
|
|
"description": "Blank lines above heading",
|
|
|
|
"type": [
|
|
|
|
"integer",
|
|
|
|
"array"
|
|
|
|
],
|
|
|
|
"items": {
|
|
|
|
"type": "integer"
|
|
|
|
},
|
|
|
|
"minimum": -1,
|
|
|
|
"default": 1
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.lines_below = {
|
|
|
|
"description": "Blank lines below heading",
|
|
|
|
"type": [
|
|
|
|
"integer",
|
|
|
|
"array"
|
|
|
|
],
|
|
|
|
"items": {
|
|
|
|
"type": "integer"
|
2019-03-24 21:50:56 -07:00
|
|
|
},
|
2025-09-18 21:21:12 -07:00
|
|
|
"minimum": -1,
|
|
|
|
"default": 1
|
2019-03-24 21:50:56 -07:00
|
|
|
};
|
|
|
|
break;
|
2018-07-19 21:49:30 -07:00
|
|
|
case "MD024":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.siblings_only = {
|
|
|
|
"description": "Only check sibling headings",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": false
|
2018-07-19 21:49:30 -07:00
|
|
|
};
|
|
|
|
break;
|
2016-10-05 22:21:54 -07:00
|
|
|
case "MD026":
|
|
|
|
case "MD036":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.punctuation = {
|
|
|
|
"description": "Punctuation characters",
|
|
|
|
"type": "string",
|
|
|
|
"default": (ruleName === "MD026") ? ".,;:!。,;:!" : ".,;:!?。,;:!?"
|
2016-10-05 22:21:54 -07:00
|
|
|
};
|
|
|
|
break;
|
2025-03-03 23:22:28 -08:00
|
|
|
case "MD027":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.list_items = {
|
|
|
|
"description": "Include list items",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": true
|
2025-03-03 23:22:28 -08:00
|
|
|
};
|
|
|
|
break;
|
2016-10-05 22:21:54 -07:00
|
|
|
case "MD029":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.style = {
|
|
|
|
"description": "List style",
|
|
|
|
"type": "string",
|
|
|
|
"enum": [
|
|
|
|
"one",
|
|
|
|
"ordered",
|
|
|
|
"one_or_ordered",
|
|
|
|
"zero"
|
|
|
|
],
|
|
|
|
"default": "one_or_ordered"
|
2016-10-05 22:21:54 -07:00
|
|
|
};
|
|
|
|
break;
|
|
|
|
case "MD030":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.ul_single = {
|
|
|
|
"description": "Spaces for single-line unordered list items",
|
|
|
|
"type": "integer",
|
|
|
|
"minimum": 1,
|
|
|
|
"default": 1
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.ol_single = {
|
|
|
|
"description": "Spaces for single-line ordered list items",
|
|
|
|
"type": "integer",
|
|
|
|
"minimum": 1,
|
|
|
|
"default": 1
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.ul_multi = {
|
|
|
|
"description": "Spaces for multi-line unordered list items",
|
|
|
|
"type": "integer",
|
|
|
|
"minimum": 1,
|
|
|
|
"default": 1
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.ol_multi = {
|
|
|
|
"description": "Spaces for multi-line ordered list items",
|
|
|
|
"type": "integer",
|
|
|
|
"minimum": 1,
|
|
|
|
"default": 1
|
2016-10-05 22:21:54 -07:00
|
|
|
};
|
|
|
|
break;
|
2019-08-02 22:58:41 -07:00
|
|
|
case "MD031":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.list_items = {
|
|
|
|
"description": "Include list items",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": true
|
2019-08-02 22:58:41 -07:00
|
|
|
};
|
|
|
|
break;
|
2016-10-05 22:21:54 -07:00
|
|
|
case "MD033":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.allowed_elements = {
|
|
|
|
"description": "Allowed elements",
|
|
|
|
"type": "array",
|
|
|
|
"items": {
|
|
|
|
"type": "string"
|
2025-05-27 01:32:15 +02:00
|
|
|
},
|
2025-09-18 21:21:12 -07:00
|
|
|
"default": []
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.table_allowed_elements = {
|
|
|
|
"description": "Allowed elements in tables",
|
|
|
|
"type": "array",
|
|
|
|
"items": {
|
|
|
|
"type": "string"
|
|
|
|
},
|
|
|
|
"default": []
|
2016-10-05 22:21:54 -07:00
|
|
|
};
|
|
|
|
break;
|
|
|
|
case "MD035":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.style = {
|
|
|
|
"description": "Horizontal rule style",
|
|
|
|
"type": "string",
|
|
|
|
"default": "consistent"
|
2016-10-05 22:21:54 -07:00
|
|
|
};
|
|
|
|
break;
|
2022-10-18 03:29:29 +08:00
|
|
|
case "MD040":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.allowed_languages = {
|
|
|
|
"description": "List of languages",
|
|
|
|
"type": "array",
|
|
|
|
"items": {
|
|
|
|
"type": "string"
|
2022-11-11 07:07:04 +01:00
|
|
|
},
|
2025-09-18 21:21:12 -07:00
|
|
|
"default": []
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.language_only = {
|
|
|
|
"description": "Require language only",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": false
|
2022-10-18 03:29:29 +08:00
|
|
|
};
|
|
|
|
break;
|
2019-03-16 20:21:57 -07:00
|
|
|
case "MD025":
|
2017-05-06 15:25:14 -07:00
|
|
|
case "MD041":
|
2025-09-18 21:21:12 -07:00
|
|
|
if (ruleName === "MD041") {
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.allow_preamble = {
|
|
|
|
"description": "Allow content before first heading",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": false
|
2025-03-22 16:15:59 -07:00
|
|
|
};
|
|
|
|
}
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.front_matter_title = {
|
|
|
|
"description": "RegExp for matching title in front matter",
|
|
|
|
"type": "string",
|
|
|
|
"default": "^\\s*title\\s*[:=]"
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.level = {
|
|
|
|
"description": "Heading level",
|
|
|
|
"type": "integer",
|
|
|
|
"minimum": 1,
|
|
|
|
"maximum": 6,
|
|
|
|
"default": 1
|
|
|
|
};
|
2017-05-06 15:25:14 -07:00
|
|
|
break;
|
2016-10-05 22:21:54 -07:00
|
|
|
case "MD043":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.headings = {
|
|
|
|
"description": "List of headings",
|
|
|
|
"type": "array",
|
|
|
|
"items": {
|
|
|
|
"type": "string",
|
|
|
|
"pattern": "^(\\*|\\+|\\?|#{1,6}\\s+\\S.*)$"
|
2018-03-19 23:39:42 +01:00
|
|
|
},
|
2025-09-18 21:21:12 -07:00
|
|
|
"default": []
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.match_case = {
|
|
|
|
"description": "Match case of headings",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": false
|
2016-10-05 22:21:54 -07:00
|
|
|
};
|
|
|
|
break;
|
2016-12-22 13:34:18 -08:00
|
|
|
case "MD044":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.names = {
|
|
|
|
"description": "List of proper names",
|
|
|
|
"type": "array",
|
|
|
|
"items": {
|
|
|
|
"type": "string"
|
2017-03-18 19:47:26 -07:00
|
|
|
},
|
2025-09-18 21:21:12 -07:00
|
|
|
"default": []
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.code_blocks = {
|
|
|
|
"description": "Include code blocks",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": true
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.html_elements = {
|
|
|
|
"description": "Include HTML elements",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": true
|
2016-12-22 13:34:18 -08:00
|
|
|
};
|
|
|
|
break;
|
2019-04-17 14:42:17 -07:00
|
|
|
case "MD046":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.style = {
|
|
|
|
"description": "Block style",
|
|
|
|
"type": "string",
|
|
|
|
"enum": [
|
|
|
|
"consistent",
|
|
|
|
"fenced",
|
|
|
|
"indented"
|
|
|
|
],
|
|
|
|
"default": "consistent"
|
2019-04-17 14:42:17 -07:00
|
|
|
};
|
|
|
|
break;
|
2019-10-08 21:10:02 -07:00
|
|
|
case "MD048":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.style = {
|
|
|
|
"description": "Code fence style",
|
|
|
|
"type": "string",
|
|
|
|
"enum": [
|
|
|
|
"consistent",
|
|
|
|
"backtick",
|
|
|
|
"tilde"
|
|
|
|
],
|
|
|
|
"default": "consistent"
|
2021-10-24 06:54:58 +02:00
|
|
|
};
|
|
|
|
break;
|
|
|
|
case "MD049":
|
2021-10-21 06:42:48 +02:00
|
|
|
case "MD050":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.style = {
|
|
|
|
"description": (ruleName === "MD049") ? "Emphasis style" : "Strong style",
|
|
|
|
"type": "string",
|
|
|
|
"enum": [
|
|
|
|
"consistent",
|
|
|
|
"asterisk",
|
|
|
|
"underscore"
|
|
|
|
],
|
|
|
|
"default": "consistent"
|
2021-10-21 06:42:48 +02:00
|
|
|
};
|
2023-09-04 16:40:48 -07:00
|
|
|
break;
|
2024-10-08 22:40:11 -07:00
|
|
|
case "MD051":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.ignore_case = {
|
|
|
|
"description": "Ignore case of fragments",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": false
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.ignored_pattern = {
|
|
|
|
"description": "Pattern for ignoring additional fragments",
|
|
|
|
"type": "string",
|
|
|
|
"default": ""
|
2024-10-08 22:40:11 -07:00
|
|
|
};
|
|
|
|
break;
|
2023-09-04 16:40:48 -07:00
|
|
|
case "MD052":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.ignored_labels = {
|
|
|
|
"description": "Ignored link labels",
|
|
|
|
"type": "array",
|
|
|
|
"items": {
|
|
|
|
"type": "string"
|
2025-04-27 22:36:07 -07:00
|
|
|
},
|
2025-09-18 21:21:12 -07:00
|
|
|
"default": [ "x" ]
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.shortcut_syntax = {
|
|
|
|
"description": "Include shortcut syntax",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": false
|
2023-09-04 16:40:48 -07:00
|
|
|
};
|
2021-10-21 06:42:48 +02:00
|
|
|
break;
|
2022-08-02 20:36:47 -07:00
|
|
|
case "MD053":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.ignored_definitions = {
|
|
|
|
"description": "Ignored definitions",
|
|
|
|
"type": "array",
|
|
|
|
"items": {
|
|
|
|
"type": "string"
|
|
|
|
},
|
|
|
|
"default": [ "//" ]
|
2022-08-02 20:36:47 -07:00
|
|
|
};
|
|
|
|
break;
|
2023-10-24 21:07:46 -07:00
|
|
|
case "MD054":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.autolink = {
|
|
|
|
"description": "Allow autolinks",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": true
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.inline = {
|
|
|
|
"description": "Allow inline links and images",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": true
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.full = {
|
|
|
|
"description": "Allow full reference links and images",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": true
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.collapsed = {
|
|
|
|
"description": "Allow collapsed reference links and images",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": true
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.shortcut = {
|
|
|
|
"description": "Allow shortcut reference links and images",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": true
|
|
|
|
};
|
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.url_inline = {
|
|
|
|
"description": "Allow URLs as inline links",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": true
|
2023-10-24 21:07:46 -07:00
|
|
|
};
|
|
|
|
break;
|
2023-12-30 18:15:38 -08:00
|
|
|
case "MD055":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.style = {
|
|
|
|
"description": "Table pipe style",
|
|
|
|
"type": "string",
|
|
|
|
"enum": [
|
|
|
|
"consistent",
|
|
|
|
"leading_only",
|
|
|
|
"trailing_only",
|
|
|
|
"leading_and_trailing",
|
|
|
|
"no_leading_or_trailing"
|
|
|
|
],
|
|
|
|
"default": "consistent"
|
2023-12-30 18:15:38 -08:00
|
|
|
};
|
|
|
|
break;
|
2025-01-06 11:35:17 -05:00
|
|
|
case "MD059":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.prohibited_texts = {
|
|
|
|
"description": "Prohibited link texts",
|
|
|
|
"type": "array",
|
|
|
|
"items": {
|
|
|
|
"type": "string"
|
|
|
|
},
|
|
|
|
"default": [
|
|
|
|
"click here",
|
|
|
|
"here",
|
|
|
|
"link",
|
|
|
|
"more"
|
|
|
|
]
|
2025-01-06 11:35:17 -05:00
|
|
|
};
|
|
|
|
break;
|
2025-08-19 21:42:08 -07:00
|
|
|
case "MD060":
|
2025-09-18 21:21:12 -07:00
|
|
|
// @ts-ignore
|
|
|
|
subscheme.properties.style = {
|
|
|
|
"description": "Table column style",
|
|
|
|
"type": "string",
|
|
|
|
"enum": [
|
|
|
|
"any",
|
|
|
|
"aligned",
|
|
|
|
"compact",
|
|
|
|
"tight"
|
|
|
|
],
|
|
|
|
"default": "any"
|
2025-08-19 21:42:08 -07:00
|
|
|
};
|
|
|
|
break;
|
2016-10-05 22:21:54 -07:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2025-09-18 21:21:12 -07:00
|
|
|
/* eslint-enable camelcase */
|
2023-11-08 19:49:02 -08:00
|
|
|
for (const name of rule.names) {
|
|
|
|
schema.properties[name] = scheme;
|
|
|
|
// Using $ref causes rule aliases not to get JSDoc comments
|
|
|
|
// schema.properties[name] = (index === 0) ? scheme : {
|
2025-03-17 20:10:25 -07:00
|
|
|
// "$ref": `#/properties/${firstName}`
|
2023-11-08 19:49:02 -08:00
|
|
|
// };
|
2022-06-08 22:10:27 -07:00
|
|
|
}
|
|
|
|
}
|
2016-10-05 22:21:54 -07:00
|
|
|
|
|
|
|
// Add tags
|
2022-06-08 22:10:27 -07:00
|
|
|
for (const [ tag, tagTags ] of Object.entries(tags)) {
|
2018-04-27 22:05:34 -07:00
|
|
|
const scheme = {
|
2023-11-03 20:23:13 -07:00
|
|
|
"description": `${tag} : ${tagTags.join(", ")}`,
|
2025-09-16 20:47:08 -07:00
|
|
|
"oneOf": [
|
|
|
|
{ "type": "boolean" },
|
2025-09-19 22:03:06 -07:00
|
|
|
// "off" not (yet) supported because behavior of older versions would be to enable
|
2025-09-20 22:19:47 -07:00
|
|
|
{ "enum": [ "error", "warning" ] },
|
|
|
|
{
|
|
|
|
"type": "object",
|
|
|
|
"additionalProperties": false,
|
|
|
|
"properties": {
|
|
|
|
"severity": {
|
|
|
|
"description": "Tag severity",
|
|
|
|
"type": "string",
|
|
|
|
"enum": [ "error", "warning", "off" ],
|
|
|
|
"default": "error"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2025-09-16 20:47:08 -07:00
|
|
|
],
|
2016-10-05 22:21:54 -07:00
|
|
|
"default": true
|
|
|
|
};
|
|
|
|
schema.properties[tag] = scheme;
|
2022-06-08 22:10:27 -07:00
|
|
|
}
|
2016-10-05 22:21:54 -07:00
|
|
|
|
|
|
|
// Write schema
|
2024-11-28 20:36:44 -08:00
|
|
|
const schemaFile = path.join(__dirname(import.meta), schemaName);
|
|
|
|
await fs.writeFile(schemaFile, JSON.stringify(schema, null, " "));
|
2023-11-08 19:49:02 -08:00
|
|
|
|
2024-08-27 20:47:33 -07:00
|
|
|
// Create and write strict schema
|
|
|
|
const schemaStrict = {
|
|
|
|
...schema,
|
|
|
|
"$id": schemaStrictUri,
|
|
|
|
"additionalProperties": false
|
|
|
|
};
|
2024-11-28 20:36:44 -08:00
|
|
|
const schemaFileStrict = path.join(__dirname(import.meta), schemaStrictName);
|
|
|
|
await fs.writeFile(schemaFileStrict, JSON.stringify(schemaStrict, null, " "));
|
2024-08-27 20:47:33 -07:00
|
|
|
|
|
|
|
// Write TypeScript declaration file
|
2024-11-28 20:36:44 -08:00
|
|
|
const declarationStrictName = path.join(__dirname(import.meta), "..", "lib", "configuration-strict.d.ts");
|
2024-08-27 20:47:33 -07:00
|
|
|
schemaStrict.title = "ConfigurationStrict";
|
2024-11-28 20:36:44 -08:00
|
|
|
const declaration = await jsonSchemaToTypeScript.compile(
|
2023-11-08 19:49:02 -08:00
|
|
|
// @ts-ignore
|
2024-08-27 20:47:33 -07:00
|
|
|
schemaStrict,
|
2023-11-08 19:49:02 -08:00
|
|
|
"UNUSED"
|
2024-11-28 20:36:44 -08:00
|
|
|
);
|
|
|
|
await fs.writeFile(declarationStrictName, declaration);
|