Update MD043/required-headings to support "?" meaning "exactly one unspecified heading" (fixes #475).

This commit is contained in:
David Anson 2025-03-10 21:57:28 -07:00
parent 06b60b7372
commit 5749c8dcf7
15 changed files with 297 additions and 18 deletions

View file

@ -907,7 +907,7 @@ test("readme", async(t) => {
});
test("validateJsonUsingConfigSchemaStrict", async(t) => {
t.plan(187);
t.plan(192);
// @ts-ignore
const ajv = new Ajv(ajvOptions);
const validateSchemaStrict = ajv.compile(configSchemaStrict);

View file

@ -0,0 +1,15 @@
# Project Name
## Description
<!-- markdownlint-configure-file {
"required-headings": {
"headings": [
"# Project Name",
"## Description",
"?"
]
}
} -->
{MD043:+1}

View file

@ -0,0 +1,15 @@
# Project Name
## Description
## Examples
<!-- markdownlint-configure-file {
"required-headings": {
"headings": [
"?",
"## Description",
"## Examples"
]
}
} -->

View file

@ -0,0 +1,15 @@
# Project Name
## Description
## Examples
<!-- markdownlint-configure-file {
"required-headings": {
"headings": [
"# Project Name",
"## Description",
"?"
]
}
} -->

View file

@ -0,0 +1,15 @@
# Project Name
## Description
## Examples
<!-- markdownlint-configure-file {
"required-headings": {
"headings": [
"# Project Name",
"?",
"## Examples"
]
}
} -->

View file

@ -0,0 +1,15 @@
# Project Name
## Examples
<!-- markdownlint-configure-file {
"required-headings": {
"headings": [
"# Project Name",
"?",
"## Examples"
]
}
} -->
{MD043:+1}

View file

@ -48588,6 +48588,154 @@ Generated by [AVA](https://avajs.dev).
`,
}
## required-headings-question-extra.md
> Snapshot 1
{
errors: [
{
errorContext: '?',
errorDetail: null,
errorRange: null,
fixInfo: null,
lineNumber: 16,
ruleDescription: 'Required heading structure',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md043.md',
ruleNames: [
'MD043',
'required-headings',
],
},
],
fixed: `# Project Name␊
## Description␊
<!-- markdownlint-configure-file {␊
"required-headings": {␊
"headings": [␊
"# Project Name",␊
"## Description",␊
"?"␊
]␊
}␊
} -->␊
{MD043:+1}␊
`,
}
## required-headings-question-first.md
> Snapshot 1
{
errors: [],
fixed: `# Project Name␊
## Description␊
## Examples␊
<!-- markdownlint-configure-file {␊
"required-headings": {␊
"headings": [␊
"?",␊
"## Description",␊
"## Examples"␊
]␊
}␊
} -->␊
`,
}
## required-headings-question-last.md
> Snapshot 1
{
errors: [],
fixed: `# Project Name␊
## Description␊
## Examples␊
<!-- markdownlint-configure-file {␊
"required-headings": {␊
"headings": [␊
"# Project Name",␊
"## Description",␊
"?"␊
]␊
}␊
} -->␊
`,
}
## required-headings-question-middle.md
> Snapshot 1
{
errors: [],
fixed: `# Project Name␊
## Description␊
## Examples␊
<!-- markdownlint-configure-file {␊
"required-headings": {␊
"headings": [␊
"# Project Name",␊
"?",␊
"## Examples"␊
]␊
}␊
} -->␊
`,
}
## required-headings-question-missing.md
> Snapshot 1
{
errors: [
{
errorContext: '## Examples',
errorDetail: null,
errorRange: null,
fixInfo: null,
lineNumber: 16,
ruleDescription: 'Required heading structure',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md043.md',
ruleNames: [
'MD043',
'required-headings',
],
},
],
fixed: `# Project Name␊
## Examples␊
<!-- markdownlint-configure-file {␊
"required-headings": {␊
"headings": [␊
"# Project Name",␊
"?",␊
"## Examples"␊
]␊
}␊
} -->␊
{MD043:+1}␊
`,
}
## required-headings-wrong-match-case.md
> Snapshot 1