Update MD024/no-duplicate-heading to remove duplicate parameter allow_different_nesting which confuses people.

This commit is contained in:
David Anson 2023-12-05 19:23:17 -08:00
parent c39facc73f
commit f2725178b1
15 changed files with 19 additions and 49 deletions

View file

@ -384,10 +384,6 @@ export interface Configuration {
MD024?:
| boolean
| {
/**
* Only check sibling headings
*/
allow_different_nesting?: boolean;
/**
* Only check sibling headings
*/
@ -399,10 +395,6 @@ export interface Configuration {
"no-duplicate-heading"?:
| boolean
| {
/**
* Only check sibling headings
*/
allow_different_nesting?: boolean;
/**
* Only check sibling headings
*/

View file

@ -9,8 +9,7 @@ module.exports = {
"description": "Multiple headings with the same content",
"tags": [ "headings" ],
"function": function MD024(params, onError) {
const siblingsOnly = !!params.config.siblings_only ||
!!params.config.allow_different_nesting || false;
const siblingsOnly = !!params.config.siblings_only || false;
const knownContents = [ null, [] ];
let lastLevel = 1;
let knownContent = knownContents[lastLevel];
@ -27,10 +26,15 @@ module.exports = {
}
knownContent = knownContents[newLevel];
}
// @ts-ignore
if (knownContent.includes(content)) {
addErrorContext(onError, heading.lineNumber,
heading.line.trim());
addErrorContext(
onError,
heading.lineNumber,
heading.line.trim()
);
} else {
// @ts-ignore
knownContent.push(content);
}
});