Skip to content

feat: add frontmatterTitle option to heading-increment #454

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

Merged
merged 5 commits into from
Jul 23, 2025

Conversation

xbinaryx
Copy link
Contributor

@xbinaryx xbinaryx commented Jul 1, 2025

Prerequisites checklist

What is the purpose of this pull request?

This pull request adds a new frontmatterTitle option to the heading-increment rule. The rule will treat a frontmatter title as a level 1 heading for the purpose of heading increment checks, ensuring that heading levels are not skipped after a frontmatter title.

What changes did you make? (Give an overview)

  • Added a frontmatterTitle option to the heading-increment rule, allowing users to specify a regex pattern to detect a title in frontmatter blocks.
  • Added tests to verify the new behavior.
  • Updated documentation to describe the new option and its usage.

Related Issues

Fixes #443

Is there anything you'd like reviewers to focus on?

@lumirlumir lumirlumir added this to Triage Jul 1, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Jul 1, 2025
@nzakas nzakas requested a review from Copilot July 2, 2025 15:17
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a frontmatterTitle option to the heading-increment rule so that a matching title in frontmatter counts as an H1, preventing skipped-heading errors. It adds a helper, integrates frontmatter handlers, expands tests, and updates documentation.

  • Introduce frontmatterHasTitle in util.js and use it in heading-increment
  • Expand heading-increment rule with schema, default options, and frontmatter listeners
  • Add tests covering YAML/TOML/JSON frontmatter variations and update docs

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/rules/heading-increment.test.js Added valid/invalid cases for frontmatter title handling
src/util.js Added frontmatterHasTitle helper
src/rules/no-multiple-h1.js Imported helper and updated JSDoc typedefs (unused import)
src/rules/heading-increment.js Added schema, defaultOptions, and YAML/TOML/JSON handlers
docs/rules/heading-increment.md Documented new frontmatterTitle option

@nzakas nzakas moved this from Needs Triage to Implementing in Triage Jul 2, 2025
nzakas
nzakas previously approved these changes Jul 7, 2025
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Would like another review before merging.

@nzakas nzakas moved this from Implementing to Second Review Needed in Triage Jul 7, 2025
Copy link
Member

@lumirlumir lumirlumir left a comment

Choose a reason for hiding this comment

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

The rest looks good to me.

Copy link
Member

@lumirlumir lumirlumir left a comment

Choose a reason for hiding this comment

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

LGTM, Would like @nzakas to verify the changes before merging.

Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks.

@nzakas nzakas merged commit 614ef3e into eslint:main Jul 23, 2025
23 checks passed
@github-project-automation github-project-automation bot moved this from Second Review Needed to Complete in Triage Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

Rule Change: Add frontmatterTitle option to heading-increment
3 participants