Skip to content

feat: add checkSiblingsOnly option to no-duplicate-headings rule #393

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 3 commits into from
Jun 6, 2025

Conversation

xbinaryx
Copy link
Contributor

Prerequisites checklist

What is the purpose of this pull request?

This PR adds a new siblingsOnly option to the no-duplicate-headings rule to make it more flexible. Currently, the rule flags any duplicate headings in the entire document, which can be too restrictive in some cases. With this new option, users can configure the rule to only check for duplicate headings among siblings (headings at the same level under the same parent heading).

What changes did you make? (Give an overview)

Added a new siblingsOnly boolean option to the rule's schema and refactored the implementation to track headings by level, resetting tracking when moving between levels when siblingsOnly is enabled. Updated documentation and added test cases for both ATX and setext-style headings to verify the new behavior.

Related Issues

Fixes #390

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

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 adds a new siblingsOnly option to the no-duplicate-headings rule so that duplicate heading checks may be applied only among headings that share the same parent.

  • Added a siblingsOnly boolean option in the rule’s schema and updated the implementation to track headings by level.
  • Updated tests and documentation to verify the behavior for ATX and setext-style headings.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/rules/no-duplicate-headings.test.js New test cases validating the siblingsOnly behavior for both valid and invalid heading structures.
src/rules/no-duplicate-headings.js Modified duplicate heading tracking logic to support the siblingsOnly option using level-based tracking instead of a global set.
docs/rules/no-duplicate-headings.md Updated documentation with options and examples for the new siblingsOnly setting.

@github-project-automation github-project-automation bot moved this to Needs Triage in Triage May 31, 2025
@lumirlumir lumirlumir moved this from Needs Triage to Implementing in Triage May 31, 2025
@xbinaryx xbinaryx changed the title feat: add siblingsOnly option to no-duplicate-headings rule feat: add checkSiblingsOnly option to no-duplicate-headings rule Jun 2, 2025
@lumirlumir lumirlumir self-requested a review June 3, 2025 05:15
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.

Thanks for taking this issue. I've left some comments.

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 @lumirlumir to re-review before merging.

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

nzakas commented Jun 5, 2025

@xbinaryx please double-check your spam folder, I sent you an email. 😄

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, Thanks!

@lumirlumir lumirlumir merged commit 2512729 into eslint:main Jun 6, 2025
23 checks passed
@github-project-automation github-project-automation bot moved this from Second Review Needed to Complete in Triage Jun 6, 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 siblingsOnly option to no-duplicate-headings rule
3 participants