Skip to content

Commit

Permalink
chore(website): fix Options heading level for no-empty-interface docs (
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg committed Oct 24, 2022
1 parent 9eea5f4 commit 3bd38ca
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/eslint-plugin/docs/rules/no-empty-interface.md
Expand Up @@ -48,7 +48,7 @@ interface Baz extends Foo, Bar {}

<!--/tabs-->

### Options
## Options

This rule accepts a single object option with the following default configuration:

Expand Down
29 changes: 25 additions & 4 deletions packages/eslint-plugin/tests/docs.test.ts
Expand Up @@ -26,11 +26,15 @@ function tokenIs<Type extends TokenType>(
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)
);
}

Expand Down Expand Up @@ -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);
}
}
});
});
}
});
Expand Down

0 comments on commit 3bd38ca

Please sign in to comment.