From 0bc726091ea64699e6d64903ed2f28dd2a3ef9a5 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Mon, 24 Oct 2022 13:44:33 -0400 Subject: [PATCH] chore(website): fix Options heading level for no-empty-interface docs --- .../docs/rules/no-empty-interface.md | 2 +- packages/eslint-plugin/tests/docs.test.ts | 29 ++++++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/no-empty-interface.md b/packages/eslint-plugin/docs/rules/no-empty-interface.md index 194a6e6a654b..699ebccb64a6 100644 --- a/packages/eslint-plugin/docs/rules/no-empty-interface.md +++ b/packages/eslint-plugin/docs/rules/no-empty-interface.md @@ -48,7 +48,7 @@ interface Baz extends Foo, Bar {} -### Options +## Options This rule accepts a single object option with the following default configuration: diff --git a/packages/eslint-plugin/tests/docs.test.ts b/packages/eslint-plugin/tests/docs.test.ts index 9442ed366a38..e7872a962c9e 100644 --- a/packages/eslint-plugin/tests/docs.test.ts +++ b/packages/eslint-plugin/tests/docs.test.ts @@ -26,11 +26,15 @@ function tokenIs( return token.type === type; } -function tokenIsH2(token: marked.Token): token is marked.Tokens.Heading { +function tokenIsHeading(token: marked.Token): token is marked.Tokens.Heading { + return tokenIs(token, 'heading'); +} + +function tokenIsH2( + token: marked.Token, +): token is marked.Tokens.Heading & { depth: 2 } { return ( - tokenIs(token, 'heading') && - token.depth === 2 && - !/[a-z]+: /.test(token.text) + tokenIsHeading(token) && token.depth === 2 && !/[a-z]+: /.test(token.text) ); } @@ -93,6 +97,23 @@ describe('Validating rule docs', () => { expect(header.text).toBe(titleCase(header.text)), ); }); + + const importantHeadings = new Set([ + 'How to Use', + 'Options', + 'Related To', + 'When Not To Use It', + ]); + + test('important headings must be h2s', () => { + const headers = tokens.filter(tokenIsHeading); + + for (const header of headers) { + if (importantHeadings.has(header.raw.replace(/#/g, '').trim())) { + expect(header.depth).toBe(2); + } + } + }); }); } }); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy