Skip to content

Commit 2aac986

Browse files
fix(linter): exclude .introductory from headingless check (#5249)
1 parent bc158be commit 2aac986

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎src/core/linter-rules/no-headingless-sections.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function run(conf) {
4040
}
4141
/** @type {NodeListOf<HTMLElement>} */
4242
const sections = document.querySelectorAll(
43-
"section:not(.head,#abstract,#sotd)"
43+
"section:not(.head,.introductory,#abstract,#sotd)"
4444
);
4545
const offendingElements = [...sections].filter(
4646
({ firstElementChild: e }) =>

‎tests/spec/core/linter-rules/no-headingless-sections-spec.js‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,19 @@ describe("Core Linter Rule - 'no-headingless-sections'", () => {
8181
expect(warnings[0].elements).toHaveSize(1);
8282
expect(warnings[0].elements[0].id).toBe("badone");
8383
});
84+
85+
it("doesn't warn for introductory sections without headings", async () => {
86+
const body = `
87+
<section class="introductory">
88+
<p>Some introductory content without a heading.</p>
89+
</section>
90+
<section>
91+
<h2>Normal section</h2>
92+
</section>
93+
`;
94+
const opts = makeStandardOps(config, body);
95+
const doc = await makeRSDoc(opts);
96+
const warnings = warningsFilter(doc);
97+
expect(warnings).toHaveSize(0);
98+
});
8499
});

0 commit comments

Comments
 (0)