Skip to content

feat(docs): add custom lint rule to match frontmatter title with page title#189

Merged
avivkeller merged 2 commits into
webpack:mainfrom
moshams272:feat/lint-frontmatter-title
Jul 18, 2026
Merged

feat(docs): add custom lint rule to match frontmatter title with page title#189
avivkeller merged 2 commits into
webpack:mainfrom
moshams272:feat/lint-frontmatter-title

Conversation

@moshams272

@moshams272 moshams272 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR creates a custom linting ESlint script that enforces matches between the frontmatter title and the Markdown H1 heading across all .md pages.

- Created scripts/lint/frontmatter-title.mjs that recursively parses markdown files using gray-matter.
- Added npm run lint:md:fix which updates the frontmatter title to match the H1 heading where a mismatch is detected, using lineWidth: -1 to avoid unwanted YAML line-wrapping on long strings like authors.

  • Created eslint-local-rules/frontmatter-title.mjs that hooks into Markdown AST nodes (heading and root:exit).
  • Added @eslint/markdown as a devDependency to empower ESLint to natively parse .md files without crashing on JS specific rules.
  • Configured eslint.config.mjs to target pages/**/*.md and safely excludes all auto-generated content (e.g., pages/docs/api, pages/docs/loaders) and skips layout-only pages (e.g., 404.md).

Fixes #186

@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
webpack-doc-kit Ready Ready Preview, Comment Jul 18, 2026 1:07pm

Request Review

@moshams272 moshams272 changed the title feat(docs): add custom lint rule to match frontmatter title with page… feat(docs): add custom lint rule to match frontmatter title with page title Jul 16, 2026
Comment thread scripts/lint/frontmatter-title.mjs Outdated
@avivkeller
avivkeller merged commit 33a847e into webpack:main Jul 18, 2026
10 checks passed
@moshams272
moshams272 deleted the feat/lint-frontmatter-title branch July 19, 2026 00:52
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.

Custom Lint Rule to Match Frontmatter and Page Title

2 participants