Update MD043/required-headings to standardize early-return flow.

This commit is contained in:
David Anson 2023-08-29 23:00:27 -07:00
parent b13d6a49ee
commit acd8c6ff28
2 changed files with 84 additions and 80 deletions

View file

@ -5635,8 +5635,11 @@ module.exports = {
"tags": ["headings", "headers"],
"function": function MD043(params, onError) {
var requiredHeadings = params.config.headings || params.config.headers;
if (!Array.isArray(requiredHeadings)) {
// Nothing to check; avoid doing any work
return;
}
var matchCase = params.config.match_case || false;
if (Array.isArray(requiredHeadings)) {
var levels = {};
for (var _i = 0, _arr = [1, 2, 3, 4, 5, 6]; _i < _arr.length; _i++) {
var level = _arr[_i];
@ -5682,7 +5685,6 @@ module.exports = {
addErrorContext(onError, params.lines.length, requiredHeadings[i]);
}
}
}
};
/***/ }),

View file

@ -11,8 +11,11 @@ module.exports = {
"tags": [ "headings", "headers" ],
"function": function MD043(params, onError) {
const requiredHeadings = params.config.headings || params.config.headers;
if (!Array.isArray(requiredHeadings)) {
// Nothing to check; avoid doing any work
return;
}
const matchCase = params.config.match_case || false;
if (Array.isArray(requiredHeadings)) {
const levels = {};
for (const level of [ 1, 2, 3, 4, 5, 6 ]) {
levels["h" + level] = "######".substr(-level);
@ -58,5 +61,4 @@ module.exports = {
requiredHeadings[i]);
}
}
}
};