Update MD051/link-fragments to add the ignored_pattern configuration parameter (fixes #547).

This commit is contained in:
David Anson 2025-04-05 22:34:54 -07:00
parent 45932c7837
commit 02478d24cf
17 changed files with 297 additions and 4 deletions

View file

@ -0,0 +1,9 @@
# Link Fragments Ignored Pattern Default
## Heading
[Present](#heading)
[Ignored](#ignored) {MD051}
[Missing](#missing) {MD051}

View file

@ -0,0 +1,15 @@
# Link Fragments Ignored Pattern Empty
## Heading
[Present](#heading)
[Ignored](#ignored) {MD051}
[Missing](#missing) {MD051}
<!-- markdownlint-configure-file {
"link-fragments": {
"ignored_pattern": ""
}
} -->

View file

@ -0,0 +1,15 @@
# Link Fragments Ignored Pattern Multiple
## Heading
[Present](#heading)
[Ignored](#ignored)
[Missing](#missing)
<!-- markdownlint-configure-file {
"link-fragments": {
"ignored_pattern": "^igno|^missing$"
}
} -->

View file

@ -0,0 +1,15 @@
# Link Fragments Ignored Pattern Present
## Heading
[Present](#heading)
[Ignored](#ignored)
[Missing](#missing) {MD051}
<!-- markdownlint-configure-file {
"link-fragments": {
"ignored_pattern": "^igno"
}
} -->

View file

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

View file

@ -25399,6 +25399,179 @@ Generated by [AVA](https://avajs.dev).
`,
}
## link-fragments-ignored-pattern-default.md
> Snapshot 1
{
errors: [
{
errorContext: '[Ignored](#ignored)',
errorDetail: null,
errorRange: [
1,
19,
],
fixInfo: null,
lineNumber: 7,
ruleDescription: 'Link fragments should be valid',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md051.md',
ruleNames: [
'MD051',
'link-fragments',
],
},
{
errorContext: '[Missing](#missing)',
errorDetail: null,
errorRange: [
1,
19,
],
fixInfo: null,
lineNumber: 9,
ruleDescription: 'Link fragments should be valid',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md051.md',
ruleNames: [
'MD051',
'link-fragments',
],
},
],
fixed: `# Link Fragments Ignored Pattern Default␊
## Heading␊
[Present](#heading)␊
[Ignored](#ignored) {MD051}␊
[Missing](#missing) {MD051}␊
`,
}
## link-fragments-ignored-pattern-empty.md
> Snapshot 1
{
errors: [
{
errorContext: '[Ignored](#ignored)',
errorDetail: null,
errorRange: [
1,
19,
],
fixInfo: null,
lineNumber: 7,
ruleDescription: 'Link fragments should be valid',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md051.md',
ruleNames: [
'MD051',
'link-fragments',
],
},
{
errorContext: '[Missing](#missing)',
errorDetail: null,
errorRange: [
1,
19,
],
fixInfo: null,
lineNumber: 9,
ruleDescription: 'Link fragments should be valid',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md051.md',
ruleNames: [
'MD051',
'link-fragments',
],
},
],
fixed: `# Link Fragments Ignored Pattern Empty␊
## Heading␊
[Present](#heading)␊
[Ignored](#ignored) {MD051}␊
[Missing](#missing) {MD051}␊
<!-- markdownlint-configure-file {␊
"link-fragments": {␊
"ignored_pattern": ""␊
}␊
} -->␊
`,
}
## link-fragments-ignored-pattern-multiple.md
> Snapshot 1
{
errors: [],
fixed: `# Link Fragments Ignored Pattern Multiple␊
## Heading␊
[Present](#heading)␊
[Ignored](#ignored)␊
[Missing](#missing)␊
<!-- markdownlint-configure-file {␊
"link-fragments": {␊
"ignored_pattern": "^igno|^missing$"␊
}␊
} -->␊
`,
}
## link-fragments-ignored-pattern-present.md
> Snapshot 1
{
errors: [
{
errorContext: '[Missing](#missing)',
errorDetail: null,
errorRange: [
1,
19,
],
fixInfo: null,
lineNumber: 9,
ruleDescription: 'Link fragments should be valid',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md051.md',
ruleNames: [
'MD051',
'link-fragments',
],
},
],
fixed: `# Link Fragments Ignored Pattern Present␊
## Heading␊
[Present](#heading)␊
[Ignored](#ignored)␊
[Missing](#missing) {MD051}␊
<!-- markdownlint-configure-file {␊
"link-fragments": {␊
"ignored_pattern": "^igno"␊
}␊
} -->␊
`,
}
## link-fragments.md
> Snapshot 1