Skip to content

6472 - feat(new-plugin): add @docusaurus/eslint-plugin for i18n and best practices#11807

Open
Byte-Architect-ot wants to merge 1 commit intofacebook:mainfrom
Byte-Architect-ot:feat/eslint-plugin
Open

6472 - feat(new-plugin): add @docusaurus/eslint-plugin for i18n and best practices#11807
Byte-Architect-ot wants to merge 1 commit intofacebook:mainfrom
Byte-Architect-ot:feat/eslint-plugin

Conversation

@Byte-Architect-ot
Copy link

@docusaurus/eslint-plugin

ESLint plugin for detecting internationalization (i18n) issues in Docusaurus projects.

This plugin helps ensure that all user-facing text is properly prepared for translation and that translation messages can be statically extracted.

Motivation

Sometimes text labels in the repository are accidentally left untranslated (see issue #4542).
This plugin introduces ESLint rules to automatically detect such cases during development.

This PR resolves #6472.

Installation

npm install --save-dev @docusaurus/eslint-plugin

or

yarn add -D @docusaurus/eslint-plugin

Usage

Add the plugin to your ESLint configuration.

// .eslintrc.js
module.exports = {
  plugins: ['@docusaurus'],
  rules: {
    '@docusaurus/no-dynamic-i18n-messages': 'error',
    '@docusaurus/no-untranslated-text': 'warn',
  },
};

Rules

no-dynamic-i18n-messages

Ensures that all translate() calls and <Translate> components use static string literals.

Dynamic values prevent static extraction of translation strings.

Bad

translate({ message: variable });

translate({ message: `Hello ${name}` });

Good

translate({ message: 'Hello' });

translate({ id: 'greeting', message: 'Hello' });

no-untranslated-text

Ensures that all user-facing text in JSX is wrapped with <Translate> or translate().

This helps catch accidentally untranslated text.

Bad

<p>Hello World</p>

Good

<p>
  <Translate>Hello World</Translate>
</p>

or

translate({ message: 'Hello World' });

Benefits

  • Prevents untranslated UI text
  • Enforces best practices for Docusaurus i18n
  • Enables reliable static extraction of translation messages
  • Improves consistency across the codebase

…tices

- Add no-dynamic-i18n-messages rule
- Add no-untranslated-text rule
- Add recommended config
- Add tests

Closes facebook#6514
@meta-cla
Copy link

meta-cla bot commented Mar 14, 2026

Hi @Byte-Architect-ot!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@netlify
Copy link

netlify bot commented Mar 14, 2026

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit c745e1c
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/69b5b1bca1536500080206ea
😎 Deploy Preview https://deploy-preview-11807--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@meta-cla meta-cla bot added the CLA Signed Signed Facebook CLA label Mar 15, 2026
@meta-cla
Copy link

meta-cla bot commented Mar 15, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create ESLint plugin rules to enforce best Docusaurus practices

1 participant