-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Create ESLint plugin rules to enforce best Docusaurus practices #6472
Copy link
Copy link
Closed
Labels
domain: dxRelated to developer experience of working on Docusaurus sitesRelated to developer experience of working on Docusaurus sitesfeatureThis is not a bug or issue with Docusausus, per se. It is a feature request for the future.This is not a bug or issue with Docusausus, per se. It is a feature request for the future.
Description
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Motivation
I realized there are a few text labels in our repo that are accidentally not translated. This has happened a few times in the past as well (see #4542). It would be interesting if we can make an eslint plugin with two rules:
no-dynamic-i18n-messages: ensures that all translate calls are plain text labelsno-untranslated-text: ensures all text labels in JSX are wrapped by translate calls (may have lots of false positives, but interesting to see how close we can get)
See https://docusaurus.io/docs/next/i18n/tutorial#translate-your-react-code for some documentation of the mental model of translate APIs.
We can publish this plugin as @docusaurus/eslint-plugin, so users can use this for themselves, as well as plugin/theme authors.
We may even ensure more best practices:
prefer-docusaurus-link: ensures@docusaurus/Linkis used instead ofatagsprefer-ideal-image: ensures@theme/IdealImageis used instead ofimgtagsprefer-docusaurus-heading: ensures@theme/Headingis used instead ofh2tagsno-hardcoded-src: ensures allsrcattributes are eitherrequireoruseBaseUrlno-window-eq-undefined: forbidtypeof window !== 'undefined'because this is not an adequate way to escape SSR
Self-service
- I'd be willing to do some initial work on this proposal myself.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
domain: dxRelated to developer experience of working on Docusaurus sitesRelated to developer experience of working on Docusaurus sitesfeatureThis is not a bug or issue with Docusausus, per se. It is a feature request for the future.This is not a bug or issue with Docusausus, per se. It is a feature request for the future.