mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-03 11:22:30 +02:00
feat: add eslint plugin no-html-links (#8156)
Co-authored-by: Joshua Chen <sidachen2003@gmail.com> Co-authored-by: Viktor Malmedal <viktor.malmedal@eniro.com> Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com> Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
This commit is contained in:
parent
81f30dd495
commit
4a448773b6
23 changed files with 291 additions and 67 deletions
|
@ -52,6 +52,7 @@ For more fine-grained control, you can also enable the plugin manually and confi
|
|||
| --- | --- | --- |
|
||||
| [`@docusaurus/no-untranslated-text`](./no-untranslated-text.md) | Enforce text labels in JSX to be wrapped by translate calls | |
|
||||
| [`@docusaurus/string-literal-i18n-messages`](./string-literal-i18n-messages.md) | Enforce translate APIs to be called on plain text labels | ✅ |
|
||||
| [`@docusaurus/no-html-links`](./no-html-links.md) | Ensures @docusaurus/Link is used instead of `<a>` tags | ✅ |
|
||||
|
||||
✅ = recommended
|
||||
|
||||
|
|
45
website/docs/api/misc/eslint-plugin/no-html-links.md
Normal file
45
website/docs/api/misc/eslint-plugin/no-html-links.md
Normal file
|
@ -0,0 +1,45 @@
|
|||
---
|
||||
slug: /api/misc/@docusaurus/eslint-plugin/no-html-links
|
||||
---
|
||||
|
||||
# no-html-links
|
||||
|
||||
Ensure that the Docusaurus [`<Link>`](../../../docusaurus-core.md#link) component is used instead of `<a>` tags.
|
||||
|
||||
The `<Link>` component has prefetching and preloading built-in. It also does build-time broken link detection, and helps Docusaurus understand your site's structure better.
|
||||
|
||||
## Rule Details {#details}
|
||||
|
||||
Examples of **incorrect** code for this rule:
|
||||
|
||||
```html
|
||||
<a href="/page">go to page!</a>
|
||||
|
||||
<a href="https://twitter.com/docusaurus" target="_blank">Twitter</a>
|
||||
```
|
||||
|
||||
Examples of **correct** code for this rule:
|
||||
|
||||
```js
|
||||
import Link from '@docusaurus/Link'
|
||||
|
||||
<Link to="/page">go to page!</Link>
|
||||
|
||||
<Link to="https://twitter.com/docusaurus">Twitter</Link>
|
||||
```
|
||||
|
||||
## Rule Configuration {#configuration}
|
||||
|
||||
Accepted fields:
|
||||
|
||||
```mdx-code-block
|
||||
<APITable>
|
||||
```
|
||||
|
||||
| Option | Type | Default | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `ignoreFullyResolved` | `boolean` | `false` | Set to true will not report any `<a>` tags with absolute URLs including a protocol. |
|
||||
|
||||
```mdx-code-block
|
||||
</APITable>
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue