mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-21 21:30:47 +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",
|
"description": "Multiple headings with the same content",
|
||||||
"tags": ["headings"],
|
"tags": ["headings"],
|
||||||
"function": function MD024(params, onError) {
|
"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 knownContents = [null, []];
|
||||||
var lastLevel = 1;
|
var lastLevel = 1;
|
||||||
var knownContent = knownContents[lastLevel];
|
var knownContent = knownContents[lastLevel];
|
||||||
|
@ -4412,9 +4412,11 @@ module.exports = {
|
||||||
}
|
}
|
||||||
knownContent = knownContents[newLevel];
|
knownContent = knownContents[newLevel];
|
||||||
}
|
}
|
||||||
|
// @ts-ignore
|
||||||
if (knownContent.includes(content)) {
|
if (knownContent.includes(content)) {
|
||||||
addErrorContext(onError, heading.lineNumber, heading.line.trim());
|
addErrorContext(onError, heading.lineNumber, heading.line.trim());
|
||||||
} else {
|
} else {
|
||||||
|
// @ts-ignore
|
||||||
knownContent.push(content);
|
knownContent.push(content);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,9 +15,8 @@ To fix this, ensure that the content of each heading is different:
|
||||||
## Some more text
|
## Some more text
|
||||||
```
|
```
|
||||||
|
|
||||||
If the parameter `siblings_only` (alternatively `allow_different_nesting`) is
|
If the parameter `siblings_only` is set to `true`, duplication is allowed for
|
||||||
set to `true`, heading duplication is allowed for non-sibling headings (common
|
headings with different parents (as is common in changelogs):
|
||||||
in changelogs):
|
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
# Change log
|
# Change log
|
||||||
|
|
|
@ -801,8 +801,6 @@ Aliases: `no-duplicate-heading`
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
- `allow_different_nesting`: Only check sibling headings (`boolean`, default
|
|
||||||
`false`)
|
|
||||||
- `siblings_only`: 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
|
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
|
## Some more text
|
||||||
```
|
```
|
||||||
|
|
||||||
If the parameter `siblings_only` (alternatively `allow_different_nesting`) is
|
If the parameter `siblings_only` is set to `true`, duplication is allowed for
|
||||||
set to `true`, heading duplication is allowed for non-sibling headings (common
|
headings with different parents (as is common in changelogs):
|
||||||
in changelogs):
|
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
# Change log
|
# Change log
|
||||||
|
|
|
@ -6,8 +6,6 @@ Aliases: `no-duplicate-heading`
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
- `allow_different_nesting`: Only check sibling headings (`boolean`, default
|
|
||||||
`false`)
|
|
||||||
- `siblings_only`: 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
|
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
|
## Some more text
|
||||||
```
|
```
|
||||||
|
|
||||||
If the parameter `siblings_only` (alternatively `allow_different_nesting`) is
|
If the parameter `siblings_only` is set to `true`, duplication is allowed for
|
||||||
set to `true`, heading duplication is allowed for non-sibling headings (common
|
headings with different parents (as is common in changelogs):
|
||||||
in changelogs):
|
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
# Change log
|
# Change log
|
||||||
|
|
8
lib/configuration.d.ts
vendored
8
lib/configuration.d.ts
vendored
|
@ -384,10 +384,6 @@ export interface Configuration {
|
||||||
MD024?:
|
MD024?:
|
||||||
| boolean
|
| boolean
|
||||||
| {
|
| {
|
||||||
/**
|
|
||||||
* Only check sibling headings
|
|
||||||
*/
|
|
||||||
allow_different_nesting?: boolean;
|
|
||||||
/**
|
/**
|
||||||
* Only check sibling headings
|
* Only check sibling headings
|
||||||
*/
|
*/
|
||||||
|
@ -399,10 +395,6 @@ export interface Configuration {
|
||||||
"no-duplicate-heading"?:
|
"no-duplicate-heading"?:
|
||||||
| boolean
|
| boolean
|
||||||
| {
|
| {
|
||||||
/**
|
|
||||||
* Only check sibling headings
|
|
||||||
*/
|
|
||||||
allow_different_nesting?: boolean;
|
|
||||||
/**
|
/**
|
||||||
* Only check sibling headings
|
* 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",
|
"description": "Multiple headings with the same content",
|
||||||
"tags": [ "headings" ],
|
"tags": [ "headings" ],
|
||||||
"function": function MD024(params, onError) {
|
"function": function MD024(params, onError) {
|
||||||
const siblingsOnly = !!params.config.siblings_only ||
|
const siblingsOnly = !!params.config.siblings_only || false;
|
||||||
!!params.config.allow_different_nesting || false;
|
|
||||||
const knownContents = [ null, [] ];
|
const knownContents = [ null, [] ];
|
||||||
let lastLevel = 1;
|
let lastLevel = 1;
|
||||||
let knownContent = knownContents[lastLevel];
|
let knownContent = knownContents[lastLevel];
|
||||||
|
@ -27,10 +26,15 @@ module.exports = {
|
||||||
}
|
}
|
||||||
knownContent = knownContents[newLevel];
|
knownContent = knownContents[newLevel];
|
||||||
}
|
}
|
||||||
|
// @ts-ignore
|
||||||
if (knownContent.includes(content)) {
|
if (knownContent.includes(content)) {
|
||||||
addErrorContext(onError, heading.lineNumber,
|
addErrorContext(
|
||||||
heading.line.trim());
|
onError,
|
||||||
|
heading.lineNumber,
|
||||||
|
heading.line.trim()
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
|
// @ts-ignore
|
||||||
knownContent.push(content);
|
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/no-duplicate-heading : Multiple headings with the same content : https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md024.md
|
||||||
"MD024": {
|
"MD024": {
|
||||||
// Only check sibling headings
|
|
||||||
"allow_different_nesting": false,
|
|
||||||
// Only check sibling headings
|
// Only check sibling headings
|
||||||
"siblings_only": false
|
"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/no-duplicate-heading : Multiple headings with the same content : https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md024.md
|
||||||
MD024:
|
MD024:
|
||||||
# Only check sibling headings
|
|
||||||
allow_different_nesting: false
|
|
||||||
# Only check sibling headings
|
# Only check sibling headings
|
||||||
siblings_only: false
|
siblings_only: false
|
||||||
|
|
||||||
|
|
|
@ -246,11 +246,6 @@ for (const rule of rules) {
|
||||||
break;
|
break;
|
||||||
case "MD024":
|
case "MD024":
|
||||||
scheme.properties = {
|
scheme.properties = {
|
||||||
"allow_different_nesting": {
|
|
||||||
"description": "Only check sibling headings",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"siblings_only": {
|
"siblings_only": {
|
||||||
"description": "Only check sibling headings",
|
"description": "Only check sibling headings",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|
|
@ -596,11 +596,6 @@
|
||||||
],
|
],
|
||||||
"default": true,
|
"default": true,
|
||||||
"properties": {
|
"properties": {
|
||||||
"allow_different_nesting": {
|
|
||||||
"description": "Only check sibling headings",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"siblings_only": {
|
"siblings_only": {
|
||||||
"description": "Only check sibling headings",
|
"description": "Only check sibling headings",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
@ -617,11 +612,6 @@
|
||||||
],
|
],
|
||||||
"default": true,
|
"default": true,
|
||||||
"properties": {
|
"properties": {
|
||||||
"allow_different_nesting": {
|
|
||||||
"description": "Only check sibling headings",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"siblings_only": {
|
"siblings_only": {
|
||||||
"description": "Only check sibling headings",
|
"description": "Only check sibling headings",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|
|
@ -12,6 +12,6 @@
|
||||||
|
|
||||||
<!-- markdownlint-configure-file {
|
<!-- markdownlint-configure-file {
|
||||||
"no-duplicate-heading": {
|
"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 {␊
|
<!-- markdownlint-configure-file {␊
|
||||||
"no-duplicate-heading": {␊
|
"no-duplicate-heading": {␊
|
||||||
"allow_different_nesting": true␊
|
"siblings_only": true␊
|
||||||
}␊
|
}␊
|
||||||
} -->␊
|
} -->␊
|
||||||
`,
|
`,
|
||||||
|
@ -52119,7 +52119,6 @@ Generated by [AVA](https://avajs.dev).
|
||||||
"lines_below": "1"␊
|
"lines_below": "1"␊
|
||||||
},␊
|
},␊
|
||||||
"no-duplicate-heading": {␊
|
"no-duplicate-heading": {␊
|
||||||
"allow_different_nesting": 0,␊
|
|
||||||
"siblings_only": 0␊
|
"siblings_only": 0␊
|
||||||
},␊
|
},␊
|
||||||
"single-title": {␊
|
"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"
|
"lines_below": "1"
|
||||||
},
|
},
|
||||||
"no-duplicate-heading": {
|
"no-duplicate-heading": {
|
||||||
"allow_different_nesting": 0,
|
|
||||||
"siblings_only": 0
|
"siblings_only": 0
|
||||||
},
|
},
|
||||||
"single-title": {
|
"single-title": {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue