Skip to content

feat: Add no-h1-content and no-empty-heading rules#7

Merged
cypher0n3 merged 2 commits intomainfrom
feat/no-h1-content
Feb 9, 2026
Merged

feat: Add no-h1-content and no-empty-heading rules#7
cypher0n3 merged 2 commits intomainfrom
feat/no-h1-content

Conversation

@cypher0n3
Copy link
Owner

Summary

Adds two new custom markdownlint rules for heading structure:

  • no-h1-content – Under the first H1, allow only table-of-contents content (blank lines, list-of-links, badges, HTML comments). Any other content (prose, code blocks, etc.) is reported.
  • no-empty-heading – Every H2+ heading must have at least one line of content before the next same-or-higher-level heading. Blank and HTML-comment-only lines do not count; other HTML comments are allowed. Optional excludePathPatterns (e.g. **/*_index.md) and per-section suppress via <!-- no-empty-heading allow --> on its own line.

Changes

  • Rules: New no-h1-content.js and no-empty-heading.js in markdownlint-rules/, with shared logic for allowed/suppress patterns and excludePathPatterns via utils.js.
  • Config: Both rules registered in .markdownlint-cli2.jsonc. .markdownlint.yml documents no-h1-content (commented) and enables no-empty-heading with excludePathPatterns: ["**/*_index.md"].
  • Tests: Unit tests in test/markdownlint-rules/ for both rules; new/updated fixtures in md_test_files/ and expected_errors.yml.
  • Docs: README, CONTRIBUTING, and markdownlint-rules/README.md updated with rule descriptions, config options, and TOC/checklist where relevant.

Only TOC-style content (blank lines, anchor links, badges, HTML comments)
is allowed under the first H1; any other content is reported.
Includes rule implementation, tests, fixture, and config/docs updates.
- Custom rule flags H2+ headings with no content before the next same-or-higher heading.
- Supports excludePathPatterns (e.g. **/*_index.md) and per-section suppress via <!-- no-empty-heading allow --> on its own line; other HTML comments allowed in section.
- Unit tests, positive/negative fixtures, and docs/config updated.
@cypher0n3 cypher0n3 merged commit 934567b into main Feb 9, 2026
11 checks passed
@cypher0n3 cypher0n3 deleted the feat/no-h1-content branch February 9, 2026 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant