mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Update MD024/no-duplicate-heading to remove duplicate parameter allow_different_nesting which confuses people.
This commit is contained in:
parent
c39facc73f
commit
f2725178b1
15 changed files with 19 additions and 49 deletions
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
8
lib/configuration.d.ts
vendored
8
lib/configuration.d.ts
vendored
|
@ -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
|
||||
*/
|
||||
|
|
12
lib/md024.js
12
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);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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
|
||||
},
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -12,6 +12,6 @@
|
|||
|
||||
<!-- markdownlint-configure-file {
|
||||
"no-duplicate-heading": {
|
||||
"allow_different_nesting": true
|
||||
"siblings_only": true
|
||||
}
|
||||
} -->
|
||||
|
|
Binary file not shown.
|
@ -14526,7 +14526,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
␊
|
||||
<!-- markdownlint-configure-file {␊
|
||||
"no-duplicate-heading": {␊
|
||||
"allow_different_nesting": true␊
|
||||
"siblings_only": true␊
|
||||
}␊
|
||||
} -->␊
|
||||
`,
|
||||
|
@ -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": {␊
|
||||
|
|
Binary file not shown.
|
@ -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": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue