-
Notifications
You must be signed in to change notification settings - Fork 73
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
inutil.js
and use it inheading-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 |
@@ -7,14 +7,17 @@ | |||
// Imports | |||
//----------------------------------------------------------------------------- | |||
|
|||
import { findOffsets } from "../util.js"; | |||
import { findOffsets, frontmatterHasTitle } from "../util.js"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The imported frontmatterHasTitle
is never used in this rule. Either integrate it to support a frontmatterTitle
option or remove the unused import.
Copilot uses AI. Check for mistakes.
src/rules/no-multiple-h1.js
Outdated
|
||
//----------------------------------------------------------------------------- | ||
// Type Definitions | ||
//----------------------------------------------------------------------------- | ||
|
||
/** | ||
* @typedef {import("../types.ts").MarkdownRuleDefinition<{ RuleOptions: [{ frontmatterTitle?: string; }]; }>} | ||
* @import { MarkdownRuleDefinition } from "../types.js"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSDoc does not recognize @import
as a type declaration. Replace this with a valid import-based typedef, e.g., @typedef {import("../types.js").MarkdownRuleDefinition<...>} NoMultipleH1RuleDefinition
.
* @import { MarkdownRuleDefinition } from "../types.js"; | |
* @typedef {import("../types.js").MarkdownRuleDefinition} MarkdownRuleDefinition |
Copilot uses AI. Check for mistakes.
src/rules/heading-increment.js
Outdated
* @import { MarkdownRuleDefinition } from "../types.js"; | ||
* @typedef {"skippedHeading"} HeadingIncrementMessageIds | ||
* @typedef {[{ frontmatterTitle?: string }]} HeadingIncrementOptions | ||
* @typedef {MarkdownRuleDefinition<{ RuleOptions: HeadingIncrementOptions, MessageIds: HeadingIncrementMessageIds }>} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSDoc does not support an @import
tag for types. Use @typedef {import("../types.js").MarkdownRuleDefinition<...>} HeadingIncrementRuleDefinition
to ensure the type is correctly recognized.
* @import { MarkdownRuleDefinition } from "../types.js"; | |
* @typedef {"skippedHeading"} HeadingIncrementMessageIds | |
* @typedef {[{ frontmatterTitle?: string }]} HeadingIncrementOptions | |
* @typedef {MarkdownRuleDefinition<{ RuleOptions: HeadingIncrementOptions, MessageIds: HeadingIncrementMessageIds }>} | |
* @typedef {"skippedHeading"} HeadingIncrementMessageIds | |
* @typedef {[{ frontmatterTitle?: string }]} HeadingIncrementOptions | |
* @typedef {import("../types.js").MarkdownRuleDefinition<{ RuleOptions: HeadingIncrementOptions, MessageIds: HeadingIncrementMessageIds }>} |
Copilot uses AI. Check for mistakes.
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)
Related Issues
Fixes #443
Is there anything you'd like reviewers to focus on?