Improve JSON schema (fixes #493).

This commit is contained in:
EmilySeville7cfg 2022-01-23 16:25:30 +10:00 committed by David Anson
parent 3a62220e87
commit 245791f79f
2 changed files with 108 additions and 741 deletions

View file

@ -59,6 +59,8 @@ rules.forEach(function forRule(rule) {
"level": {
"description": "Heading level",
"type": "integer",
"minimum": 1,
"maximum": 6,
"default": 1
}
};
@ -101,6 +103,7 @@ rules.forEach(function forRule(rule) {
"indent": {
"description": "Spaces for indent",
"type": "integer",
"minimum": 1,
"default": 2
},
"start_indented": {
@ -112,6 +115,7 @@ rules.forEach(function forRule(rule) {
"description":
"Spaces for first level indent (when start_indented is set)",
"type": "integer",
"minimum": 1,
"default": 2
}
};
@ -121,6 +125,7 @@ rules.forEach(function forRule(rule) {
"br_spaces": {
"description": "Spaces for line break",
"type": "integer",
"minimum": 0,
"default": 2
},
"list_item_empty_lines": {
@ -144,7 +149,8 @@ rules.forEach(function forRule(rule) {
},
"spaces_per_tab": {
"description": "Number of spaces for each hard tab",
"type": "number",
"type": "integer",
"minimum": 0,
"default": 1
}
};
@ -154,6 +160,7 @@ rules.forEach(function forRule(rule) {
"maximum": {
"description": "Consecutive blank lines",
"type": "integer",
"minimum": 1,
"default": 1
}
};
@ -163,16 +170,19 @@ rules.forEach(function forRule(rule) {
"line_length": {
"description": "Number of characters",
"type": "integer",
"minimum": 1,
"default": 80
},
"heading_line_length": {
"description": "Number of characters for headings",
"type": "integer",
"minimum": 1,
"default": 80
},
"code_block_line_length": {
"description": "Number of characters for code blocks",
"type": "integer",
"minimum": 1,
"default": 80
},
"code_blocks": {
@ -212,11 +222,13 @@ rules.forEach(function forRule(rule) {
"lines_above": {
"description": "Blank lines above heading",
"type": "integer",
"minimum": 0,
"default": 1
},
"lines_below": {
"description": "Blank lines below heading",
"type": "integer",
"minimum": 0,
"default": 1
}
};
@ -273,21 +285,25 @@ rules.forEach(function forRule(rule) {
"ul_single": {
"description": "Spaces for single-line unordered list items",
"type": "integer",
"minimum": 1,
"default": 1
},
"ol_single": {
"description": "Spaces for single-line ordered list items",
"type": "integer",
"minimum": 1,
"default": 1
},
"ul_multi": {
"description": "Spaces for multi-line unordered list items",
"type": "integer",
"minimum": 1,
"default": 1
},
"ol_multi": {
"description": "Spaces for multi-line ordered list items",
"type": "integer",
"minimum": 1,
"default": 1
}
};
@ -328,6 +344,8 @@ rules.forEach(function forRule(rule) {
"level": {
"description": "Heading level",
"type": "integer",
"minimum": 1,
"maximum": 6,
"default": 1
},
"front_matter_title": {
@ -343,7 +361,8 @@ rules.forEach(function forRule(rule) {
"description": "List of headings",
"type": "array",
"items": {
"type": "string"
"type": "string",
"pattern": "^(\\*|\\+|#{1,6} .*)$"
},
"default": []
},
@ -351,7 +370,8 @@ rules.forEach(function forRule(rule) {
"description": "List of headings",
"type": "array",
"items": {
"type": "string"
"type": "string",
"pattern": "^(\\*|\\+|#{1,6} .*)$"
},
"default": []
}
@ -439,8 +459,10 @@ rules.forEach(function forRule(rule) {
scheme.type = [ "boolean", "object" ];
scheme.additionalProperties = false;
}
rule.names.forEach(function forName(name) {
schema.properties[name] = scheme;
rule.names.forEach(function forName(name, index) {
schema.properties[name] = (index === 0) ? scheme : {
"$ref": `#/properties/${rule.names[0]}`
};
});
});