Update MD043 to fix required header checks in middle and last when using special char "*" (#396)

This commit is contained in:
Jeremy Suriel 2021-05-20 15:45:27 -04:00 committed by GitHub
parent 9122b8d935
commit c6d95cb904
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 90 additions and 6 deletions

View file

@ -28,8 +28,11 @@ module.exports = {
const actual = levels[heading.tag] + " " + content;
const expected = getExpected();
if (expected === "*") {
matchAny = true;
getExpected();
const nextExpected = getExpected();
if (nextExpected.toLowerCase() !== actual.toLowerCase()) {
matchAny = true;
i--;
}
} else if (expected === "+") {
matchAny = true;
} else if (expected.toLowerCase() === actual.toLowerCase()) {
@ -43,9 +46,11 @@ module.exports = {
}
}
});
const extraHeadings = requiredHeadings.length - i;
if (
!hasError &&
(i < requiredHeadings.length) &&
((extraHeadings > 1) ||
((extraHeadings === 1) && (requiredHeadings[i] !== "*"))) &&
(anyHeadings || !requiredHeadings.every((heading) => heading === "*"))
) {
addErrorContext(onError, params.lines.length,