mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-04 01:09:20 +02:00
feat: Docusaurus ESLint plugin to enforce best Docusaurus practices (#7206)
* feat: add eslint plugin * refactor * add tests * fixups! * fix(no-dynamic-i18n-messages): make translate() recognize template literals * refactor: rename rule no-dynamic-i18n-messages --> string-literal-i18n-messages * feat: add ignoreStrings option and refactor * docs: migrate docs to /docs/api/plugins * docs: fix anchor links in README.md * fix: add some ignored strings * docs: update eslint-plugin docs * fix: update README link * docs: various updates - Reorder sidebar entries - Fix title size - Use Markdown file paths - Simplify relative links * address reviews * wording polish * add npmignore * fix all internal warnings * doc improvements * fix test Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
This commit is contained in:
parent
ae788c536f
commit
3b1170eb44
34 changed files with 885 additions and 52 deletions
48
website/docs/api/misc/eslint-plugin/no-untranslated-text.md
Normal file
48
website/docs/api/misc/eslint-plugin/no-untranslated-text.md
Normal file
|
@ -0,0 +1,48 @@
|
|||
---
|
||||
slug: '/api/misc/@docusaurus/eslint-plugin/no-untranslated-text'
|
||||
---
|
||||
|
||||
# no-untranslated-text
|
||||
|
||||
Enforce text labels in JSX to be wrapped by translate calls.
|
||||
|
||||
When the [i18n feature](../../../i18n/i18n-introduction.md) is used, this rule ensures that all labels appearing on the website are translatable, so no string accidentally slips through untranslated.
|
||||
|
||||
## Rule Details {#details}
|
||||
|
||||
Examples of **incorrect** code for this rule:
|
||||
|
||||
```js
|
||||
// Hello World is not translated
|
||||
<Component>Hello World</Component>
|
||||
```
|
||||
|
||||
Examples of **correct** code for this rule:
|
||||
|
||||
```js
|
||||
// Hello World is translated
|
||||
<Component>
|
||||
<Translate>Hello World</Translate>
|
||||
</Component>
|
||||
```
|
||||
|
||||
## Rule Configuration {#configuration}
|
||||
|
||||
Accepted fields:
|
||||
|
||||
<APITable>
|
||||
|
||||
| Option | Type | Default | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `ignoreStrings` | `string[]` | `[]` | Text labels that only contain strings in this list will not be reported. |
|
||||
|
||||
</APITable>
|
||||
|
||||
## When Not To Use It {#when-not-to-use}
|
||||
|
||||
If you're not using the [i18n feature](../../../i18n/i18n-introduction.md), you can disable this rule. You can also disable this rule where the text is not supposed to be translated.
|
||||
|
||||
## Further Reading {#further-reading}
|
||||
|
||||
- https://docusaurus.io/docs/docusaurus-core#translate
|
||||
- https://docusaurus.io/docs/docusaurus-core#translate-imperative
|
Loading…
Add table
Add a link
Reference in a new issue