diff --git a/demo/markdownlint-browser.js b/demo/markdownlint-browser.js index aca6535f..95e110d9 100644 --- a/demo/markdownlint-browser.js +++ b/demo/markdownlint-browser.js @@ -4395,7 +4395,7 @@ module.exports = { "description": "Multiple headings with the same content", "tags": ["headings"], "function": function MD024(params, onError) { - var siblingsOnly = !!params.config.siblings_only || !!params.config.allow_different_nesting || false; + var siblingsOnly = !!params.config.siblings_only || false; var knownContents = [null, []]; var lastLevel = 1; var knownContent = knownContents[lastLevel]; @@ -4412,9 +4412,11 @@ module.exports = { } knownContent = knownContents[newLevel]; } + // @ts-ignore if (knownContent.includes(content)) { addErrorContext(onError, heading.lineNumber, heading.line.trim()); } else { + // @ts-ignore knownContent.push(content); } }); diff --git a/doc-build/md024.md b/doc-build/md024.md index afe663f5..142b2035 100644 --- a/doc-build/md024.md +++ b/doc-build/md024.md @@ -15,9 +15,8 @@ To fix this, ensure that the content of each heading is different: ## Some more text ``` -If the parameter `siblings_only` (alternatively `allow_different_nesting`) is -set to `true`, heading duplication is allowed for non-sibling headings (common -in changelogs): +If the parameter `siblings_only` is set to `true`, duplication is allowed for +headings with different parents (as is common in changelogs): ```markdown # Change log diff --git a/doc/Rules.md b/doc/Rules.md index 394ff498..4d2e2a37 100644 --- a/doc/Rules.md +++ b/doc/Rules.md @@ -801,8 +801,6 @@ Aliases: `no-duplicate-heading` Parameters: -- `allow_different_nesting`: Only check sibling headings (`boolean`, default - `false`) - `siblings_only`: Only check sibling headings (`boolean`, default `false`) This rule is triggered if there are multiple headings in the document that have @@ -822,9 +820,8 @@ To fix this, ensure that the content of each heading is different: ## Some more text ``` -If the parameter `siblings_only` (alternatively `allow_different_nesting`) is -set to `true`, heading duplication is allowed for non-sibling headings (common -in changelogs): +If the parameter `siblings_only` is set to `true`, duplication is allowed for +headings with different parents (as is common in changelogs): ```markdown # Change log diff --git a/doc/md024.md b/doc/md024.md index bed159c6..5c26c712 100644 --- a/doc/md024.md +++ b/doc/md024.md @@ -6,8 +6,6 @@ Aliases: `no-duplicate-heading` Parameters: -- `allow_different_nesting`: Only check sibling headings (`boolean`, default - `false`) - `siblings_only`: Only check sibling headings (`boolean`, default `false`) This rule is triggered if there are multiple headings in the document that have @@ -27,9 +25,8 @@ To fix this, ensure that the content of each heading is different: ## Some more text ``` -If the parameter `siblings_only` (alternatively `allow_different_nesting`) is -set to `true`, heading duplication is allowed for non-sibling headings (common -in changelogs): +If the parameter `siblings_only` is set to `true`, duplication is allowed for +headings with different parents (as is common in changelogs): ```markdown # Change log diff --git a/lib/configuration.d.ts b/lib/configuration.d.ts index 4cc1c2fd..7b8fd013 100644 --- a/lib/configuration.d.ts +++ b/lib/configuration.d.ts @@ -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 */ diff --git a/lib/md024.js b/lib/md024.js index 943d9d36..e0b0f6c3 100644 --- a/lib/md024.js +++ b/lib/md024.js @@ -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); } }); diff --git a/schema/.markdownlint.jsonc b/schema/.markdownlint.jsonc index 841291c8..7173601a 100644 --- a/schema/.markdownlint.jsonc +++ b/schema/.markdownlint.jsonc @@ -112,8 +112,6 @@ // MD024/no-duplicate-heading : Multiple headings with the same content : https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md024.md "MD024": { - // Only check sibling headings - "allow_different_nesting": false, // Only check sibling headings "siblings_only": false }, diff --git a/schema/.markdownlint.yaml b/schema/.markdownlint.yaml index b59a56bd..cbaf70d8 100644 --- a/schema/.markdownlint.yaml +++ b/schema/.markdownlint.yaml @@ -103,8 +103,6 @@ MD023: true # MD024/no-duplicate-heading : Multiple headings with the same content : https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md024.md MD024: - # Only check sibling headings - allow_different_nesting: false # Only check sibling headings siblings_only: false diff --git a/schema/build-config-schema.js b/schema/build-config-schema.js index 782bdcea..f59241a9 100644 --- a/schema/build-config-schema.js +++ b/schema/build-config-schema.js @@ -246,11 +246,6 @@ for (const rule of rules) { break; case "MD024": scheme.properties = { - "allow_different_nesting": { - "description": "Only check sibling headings", - "type": "boolean", - "default": false - }, "siblings_only": { "description": "Only check sibling headings", "type": "boolean", diff --git a/schema/markdownlint-config-schema.json b/schema/markdownlint-config-schema.json index 0ac0694e..7a5fe586 100644 --- a/schema/markdownlint-config-schema.json +++ b/schema/markdownlint-config-schema.json @@ -596,11 +596,6 @@ ], "default": true, "properties": { - "allow_different_nesting": { - "description": "Only check sibling headings", - "type": "boolean", - "default": false - }, "siblings_only": { "description": "Only check sibling headings", "type": "boolean", @@ -617,11 +612,6 @@ ], "default": true, "properties": { - "allow_different_nesting": { - "description": "Only check sibling headings", - "type": "boolean", - "default": false - }, "siblings_only": { "description": "Only check sibling headings", "type": "boolean", diff --git a/test/heading_duplicate_content_different_nesting.md b/test/heading_duplicate_content_different_nesting.md index d7d4a64f..23dd72f5 100644 --- a/test/heading_duplicate_content_different_nesting.md +++ b/test/heading_duplicate_content_different_nesting.md @@ -12,6 +12,6 @@ diff --git a/test/snapshots/markdownlint-test-micromark.mjs.snap b/test/snapshots/markdownlint-test-micromark.mjs.snap index a1c5d04d..3db2a9e0 100644 Binary files a/test/snapshots/markdownlint-test-micromark.mjs.snap and b/test/snapshots/markdownlint-test-micromark.mjs.snap differ diff --git a/test/snapshots/markdownlint-test-scenarios.js.md b/test/snapshots/markdownlint-test-scenarios.js.md index c301142b..1d84e520 100644 --- a/test/snapshots/markdownlint-test-scenarios.js.md +++ b/test/snapshots/markdownlint-test-scenarios.js.md @@ -14526,7 +14526,7 @@ Generated by [AVA](https://avajs.dev). ␊ ␊ `, @@ -52119,7 +52119,6 @@ Generated by [AVA](https://avajs.dev). "lines_below": "1"␊ },␊ "no-duplicate-heading": {␊ - "allow_different_nesting": 0,␊ "siblings_only": 0␊ },␊ "single-title": {␊ diff --git a/test/snapshots/markdownlint-test-scenarios.js.snap b/test/snapshots/markdownlint-test-scenarios.js.snap index c43fa608..e3f7ffb3 100644 Binary files a/test/snapshots/markdownlint-test-scenarios.js.snap and b/test/snapshots/markdownlint-test-scenarios.js.snap differ diff --git a/test/wrong-types-in-config-file.md b/test/wrong-types-in-config-file.md index a3d9f32e..4896ef19 100644 --- a/test/wrong-types-in-config-file.md +++ b/test/wrong-types-in-config-file.md @@ -38,7 +38,6 @@ Long line long line long line long line long line long line long line long line "lines_below": "1" }, "no-duplicate-heading": { - "allow_different_nesting": 0, "siblings_only": 0 }, "single-title": {