Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MD025 rule #1109

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/md025.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
if (hasTopLevelHeading || foundFrontMatterTitle) {
addErrorContext(onError, token.lineNumber,
token.line.trim());
} else if (token.lineNumber === 1) {
} else {
Copy link
Author

@oliviertassinari oliviertassinari Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix, this condition made no sense to me.

hasTopLevelHeading = true;
}
}
Expand Down
1 change: 1 addition & 0 deletions style/relaxed.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"no-inline-html": false,
"no-bare-urls": false,
"fenced-code-language": false,
"single-title": false,
"first-line-h1": false
}
1 change: 1 addition & 0 deletions test/break-all-the-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ Strong **with** different style {MD050}
"markdownlint"
]
},
"single-title": false,
"link-image-style": {
"full": false
}
Expand Down
2 changes: 1 addition & 1 deletion test/heading_mutliple_h1_no_toplevel.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Some introductory text

# Heading 1

# Heading 2
# Heading 2 {MD025}

<!-- markdownlint-configure-file {
"first-line-heading": false
Comment on lines 2 to 8
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new regression test

Expand Down
1 change: 1 addition & 0 deletions test/headings_with_spaces_at_the_beginning.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ Some text

<!-- markdownlint-configure-file {
"heading-style": false,
"single-title": false,
"first-line-heading": false
} -->
1 change: 1 addition & 0 deletions test/lists-and-headings.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ Heading 3
* list

<!-- markdownlint-configure-file {
"single-title": false,
"first-line-heading": false
} -->
1 change: 1 addition & 0 deletions test/markdownlint-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ test("styleAll", async(t) => {
"MD022": [ 86 ],
"MD023": [ 40 ],
"MD024": [ 35 ],
"MD025": [ 27, 31, 33, 35, 40 ],
"MD026": [ 40 ],
"MD027": [ 42 ],
"MD028": [ 43 ],
Expand Down
Binary file modified test/snapshots/markdownlint-test-micromark.mjs.snap
Binary file not shown.
24 changes: 21 additions & 3 deletions test/snapshots/markdownlint-test-scenarios.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -7208,7 +7208,7 @@ Generated by [AVA](https://avajs.dev).
insertText: `␊
`,
},
lineNumber: 134,
lineNumber: 135,
ruleDescription: 'Files should end with a single newline character',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md047.md',
ruleNames: [
Expand Down Expand Up @@ -7541,6 +7541,7 @@ Generated by [AVA](https://avajs.dev).
"markdownlint"␊
]␊
},␊
"single-title": false,␊
"link-image-style": {␊
"full": false␊
}␊
Expand Down Expand Up @@ -14640,12 +14641,27 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

{
errors: [],
errors: [
{
errorContext: '# Heading 2 {MD025}',
errorDetail: null,
errorRange: null,
fixInfo: null,
lineNumber: 5,
ruleDescription: 'Multiple top-level headings in the same document',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md025.md',
ruleNames: [
'MD025',
'single-title',
'single-h1',
],
},
],
fixed: `Some introductory text␊
# Heading 1␊
# Heading 2␊
# Heading 2 {MD025}
<!-- markdownlint-configure-file {␊
"first-line-heading": false␊
Expand Down Expand Up @@ -16114,6 +16130,7 @@ Generated by [AVA](https://avajs.dev).
<!-- markdownlint-configure-file {␊
"heading-style": false,␊
"single-title": false,␊
"first-line-heading": false␊
} -->␊
`,
Expand Down Expand Up @@ -32071,6 +32088,7 @@ Generated by [AVA](https://avajs.dev).
* list␊
<!-- markdownlint-configure-file {␊
"single-title": false,␊
"first-line-heading": false␊
} -->␊
`,
Expand Down
Binary file modified test/snapshots/markdownlint-test-scenarios.js.snap
Binary file not shown.