fix(plugin-docs-cli): mask inline code before HTML checks - #2840
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves @grafana/plugin-docs-cli validation correctness and content completeness checks by preventing inline-code placeholders (e.g., <slug>) from being misinterpreted as raw HTML, and by adding a rule to catch unfilled scaffolded documentation stubs before publishing.
Changes:
- Add
maskInlineCode()and apply it to the raw-HTML tag detector so inline backtick spans don’t trigger false positives. - Introduce a new strict-mode validation rule (
unfilled-section-brief) to fail (or warn in non-strict mode) when scaffold markers remain in docs pages. - Add unit tests covering inline-code masking behavior and stub-marker detection.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/plugin-docs-cli/src/validation/types.ts | Adds the new unfilled-section-brief rule identifier to the shared rule registry. |
| packages/plugin-docs-cli/src/validation/rules/utils.ts | Introduces maskInlineCode() helper for neutralizing inline code span contents on a line. |
| packages/plugin-docs-cli/src/validation/rules/utils.test.ts | Adds unit tests validating maskInlineCode() behavior across common inline-code patterns. |
| packages/plugin-docs-cli/src/validation/rules/stub-content.ts | Adds a new rule runner to detect leftover section-brief:start scaffold markers in markdown pages. |
| packages/plugin-docs-cli/src/validation/rules/stub-content.test.ts | Adds coverage for stub-content detection, strict vs non-strict severity, line numbers, and multi-file behavior. |
| packages/plugin-docs-cli/src/validation/rules/markdown.ts | Updates matching logic to optionally mask inline code before running specific regex checks (used for raw HTML). |
| packages/plugin-docs-cli/src/validation/rules/markdown.test.ts | Adds regression tests ensuring inline-code placeholders don’t trigger no-raw-html, while real HTML still does. |
| packages/plugin-docs-cli/src/validation/rules/index.ts | Registers the new checkStubContent rule in the rule runner pipeline. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
mckn
left a comment
There was a problem hiding this comment.
LGTM! Left two nits/questions
| } | ||
|
|
||
| const lines = raw.split('\n'); | ||
| for (let i = 0; i < lines.length; i++) { |
There was a problem hiding this comment.
Is it any value in running these lines in the getCodeBlockLines or maskInlineCode? I'm asking since the other rules seems to use those functions to check for code.
|
|
||
| const lines = raw.split('\n'); | ||
| for (let i = 0; i < lines.length; i++) { | ||
| if (!SECTION_BRIEF_START_RE.test(lines[i])) { |
There was a problem hiding this comment.
Do we also need to verify that there is an end block? Or will this fail if it is missing?
What this PR does / why we need it:
Angle-bracket placeholder text inside inline code (e.g.
<slug>in a URL example) was being flagged as a raw HTML tag, since the no-raw-html check only skipped fenced code blocks, not inline backtick spans. This PR adds amaskInlineCode()helper that neutralizes inline code spans before the HTML-tag regex runs.Also adds a new
unfilled-section-briefvalidation rule that fails strict validation if a page still contains a scaffolded<!-- section-brief:start -->marker, so an unfilled documentation stub can never ship silently.Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Both issues were found while manually testing the
panel-docscodemod (#2834) against a real plugin.