mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Refactor build-config-schema.mjs slightly to reuse code.
This commit is contained in:
parent
95f82760ce
commit
9b46692b8d
1 changed files with 6 additions and 26 deletions
|
|
@ -50,9 +50,10 @@ const tags = {};
|
||||||
|
|
||||||
// Add rules
|
// Add rules
|
||||||
for (const rule of rules) {
|
for (const rule of rules) {
|
||||||
|
const ruleName = rule.names[0];
|
||||||
for (const tag of rule.tags) {
|
for (const tag of rule.tags) {
|
||||||
const tagRules = tags[tag] || [];
|
const tagRules = tags[tag] || [];
|
||||||
tagRules.push(rule.names[0]);
|
tagRules.push(ruleName);
|
||||||
tags[tag] = tagRules;
|
tags[tag] = tagRules;
|
||||||
}
|
}
|
||||||
const scheme = {
|
const scheme = {
|
||||||
|
|
@ -62,7 +63,7 @@ for (const rule of rules) {
|
||||||
"default": true
|
"default": true
|
||||||
};
|
};
|
||||||
let custom = true;
|
let custom = true;
|
||||||
switch (rule.names[0]) {
|
switch (ruleName) {
|
||||||
case "MD003":
|
case "MD003":
|
||||||
scheme.properties = {
|
scheme.properties = {
|
||||||
"style": {
|
"style": {
|
||||||
|
|
@ -256,20 +257,12 @@ for (const rule of rules) {
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case "MD026":
|
case "MD026":
|
||||||
scheme.properties = {
|
|
||||||
"punctuation": {
|
|
||||||
"description": "Punctuation characters",
|
|
||||||
"type": "string",
|
|
||||||
"default": ".,;:!。,;:!"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
case "MD036":
|
case "MD036":
|
||||||
scheme.properties = {
|
scheme.properties = {
|
||||||
"punctuation": {
|
"punctuation": {
|
||||||
"description": "Punctuation characters",
|
"description": "Punctuation characters",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": ".,;:!?。,;:!?"
|
"default": (ruleName === "MD026") ? ".,;:!。,;:!" : ".,;:!?。,;:!?"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
@ -458,23 +451,10 @@ for (const rule of rules) {
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case "MD049":
|
case "MD049":
|
||||||
scheme.properties = {
|
|
||||||
"style": {
|
|
||||||
"description": "Emphasis style",
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"consistent",
|
|
||||||
"asterisk",
|
|
||||||
"underscore"
|
|
||||||
],
|
|
||||||
"default": "consistent"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
case "MD050":
|
case "MD050":
|
||||||
scheme.properties = {
|
scheme.properties = {
|
||||||
"style": {
|
"style": {
|
||||||
"description": "Strong style",
|
"description": (ruleName === "MD049") ? "Emphasis style" : "Strong style",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"consistent",
|
"consistent",
|
||||||
|
|
@ -595,7 +575,7 @@ for (const rule of rules) {
|
||||||
schema.properties[name] = scheme;
|
schema.properties[name] = scheme;
|
||||||
// Using $ref causes rule aliases not to get JSDoc comments
|
// Using $ref causes rule aliases not to get JSDoc comments
|
||||||
// schema.properties[name] = (index === 0) ? scheme : {
|
// schema.properties[name] = (index === 0) ? scheme : {
|
||||||
// "$ref": `#/properties/${rule.names[0]}`
|
// "$ref": `#/properties/${firstName}`
|
||||||
// };
|
// };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue