require-i18n-default-locale-in-locales
Require i18n.locales to include i18n.defaultLocale when i18n config is declared.
Targeted pattern scopeโ
This rule targets docusaurus.config.* files and inspects the top-level i18n object.
What this rule reportsโ
This rule reports when:
i18n.defaultLocaleis missing or statically empty, ori18n.localesdoes not includei18n.defaultLocale.
Why this rule existsโ
Locale routing and fallback behavior assume the default locale is part of the supported locale set. Keeping defaultLocale and locales aligned avoids hard-to-debug locale routing mismatches.
โ Incorrectโ
export default {
i18n: {
defaultLocale: "en",
locales: ["fr"],
},
};
โ Correctโ
export default {
i18n: {
defaultLocale: "en",
locales: ["en", "fr"],
},
};
Behavior and migration notesโ
This rule autofixes static-array cases by appending defaultLocale to locales.
When locales is identifier-backed but statically resolvable, it reports and provides a suggestion to replace the property value with an explicit array literal that includes defaultLocale.
When not to use itโ
Do not use this rule if your locale configuration is intentionally dynamic and enforced outside ESLint checks.
Rule catalog ID: R051