mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-01 02:12:36 +02:00
feat(eslint-plugin): new prefer-docusaurus-heading rule (#8384)
This commit is contained in:
parent
a53d4cb2b3
commit
90e7e321d1
31 changed files with 254 additions and 52 deletions
|
@ -53,6 +53,7 @@ For more fine-grained control, you can also enable the plugin manually and confi
|
|||
| [`@docusaurus/no-untranslated-text`](./no-untranslated-text.mdx) | Enforce text labels in JSX to be wrapped by translate calls | |
|
||||
| [`@docusaurus/string-literal-i18n-messages`](./string-literal-i18n-messages.mdx) | Enforce translate APIs to be called on plain text labels | ✅ |
|
||||
| [`@docusaurus/no-html-links`](./no-html-links.mdx) | Ensures @docusaurus/Link is used instead of `<a>` tags | ✅ |
|
||||
| [`@docusaurus/prefer-docusaurus-heading`](./prefer-docusaurus-heading.mdx) | Ensures @theme/Heading is used instead of `<hn>` tags for headings | ✅ |
|
||||
|
||||
✅ = recommended
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
slug: /api/misc/@docusaurus/eslint-plugin/prefer-docusaurus-heading
|
||||
---
|
||||
|
||||
# prefer-docusaurus-heading
|
||||
|
||||
Ensures that the `@theme/Heading` theme component provided by Docusaurus [`theme-classic`](../../themes/theme-classic.mdx) is used instead of `<hn>` tags for headings.
|
||||
|
||||
## Rule Details {#details}
|
||||
|
||||
Examples of **incorrect** code for this rule:
|
||||
|
||||
```html
|
||||
<h1>This is heading 1</h1>
|
||||
|
||||
<h2>This is heading 2</h2>
|
||||
|
||||
<h3>This is heading 3</h3>
|
||||
```
|
||||
|
||||
Examples of **correct** code for this rule:
|
||||
|
||||
```javascript
|
||||
import Heading from '@theme/Heading'
|
||||
|
||||
<Heading as='h1'>This is heading 1</Heading>
|
||||
|
||||
<Heading as='h2'>This is heading 2</Heading>
|
||||
|
||||
<Heading as='h3'>This is heading 3</Heading>
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue