Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 4, 2025

The no-skip-heading-levels rule incorrectly flagged sequential h1-h6 headings as invalid, reporting "Unexpected skipping heading level.

is expected" on valid markup.

Root Cause

The heading tag validation array was missing "h4":

// Before
if (!["h1", "h2", "h3", "h5", "h6"].includes(node.name)) {
  return;
}

// After
if (!["h1", "h2", "h3", "h4", "h5", "h6"].includes(node.name)) {
  return;
}

This caused h4 tags to be ignored during validation. When encountering h3 → h4 → h5, the rule only tracked h3 → h5, triggering a false positive.

Changes

  • Add "h4" to heading tag validation array in no-skip-heading-levels.js
  • Add test case for sequential h1-h6 headings to prevent regression
Original prompt

This section details on the original issue you should resolve

<issue_title>[BUG] no-skip-heading-levels: Unexpected skipping heading level.

is expected</issue_title>
<issue_description>Describe the bug
Follow the HTML

<div>
  <h1>Heading 1</h1>
  <h2>Heading 2</h2>
  <h3>Heading 3</h3>
  <h4>Heading 4</h4>
  <h5>Heading 5</h5>
  <h6>Heading 6</h6>
</div>

The plugin return the followin error

Unexpected skipping heading level. <h4> is expectedeslint[@html-eslint/no-skip-heading-levels](https://html-eslint.org/docs/rules/no-skip-heading-levels)
Image

To Reproduce
Steps to reproduce the behavior:

Run eslint againt the HTML.

VSCode and cli returns the same error.

Expected behavior
No error.

Additional context

Version

"@html-eslint/eslint-plugin": "^0.47.0",
"@html-eslint/parser": "^0.47.0",
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@yeonjuan</author><body>
@tiagoporto Thanks for the report! Let me fix it</body></comment_new>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: yeonjuan <41323220+yeonjuan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unexpected skipping heading level error in ESLint Fix no-skip-heading-levels: h4 tag was not being validated Nov 4, 2025
Copilot finished work on behalf of yeonjuan November 4, 2025 13:01
Copilot AI requested a review from yeonjuan November 4, 2025 13:01
@yeonjuan yeonjuan marked this pull request as ready for review November 4, 2025 13:07
@yeonjuan yeonjuan changed the title Fix no-skip-heading-levels: h4 tag was not being validated fix: no-skip-heading-levels: h4 tag was not being validated Nov 4, 2025
@yeonjuan yeonjuan merged commit a8da32d into main Nov 4, 2025
7 of 12 checks passed
@yeonjuan yeonjuan deleted the copilot/fix-heading-level-error-again branch November 4, 2025 13:47
@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.56%. Comparing base (0e3f5c0) to head (6546ef9).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #442   +/-   ##
=======================================
  Coverage   98.56%   98.56%           
=======================================
  Files          84       84           
  Lines        2788     2788           
  Branches      777      777           
=======================================
  Hits         2748     2748           
  Misses         40       40           
Flag Coverage Δ
unittest 98.56% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
.../eslint-plugin/lib/rules/no-skip-heading-levels.js 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

[BUG] no-skip-heading-levels: Unexpected skipping heading level. <h4> is expected

2 participants