Skip to main content

require-theme-config-docsearch-config

Require themeConfig.docsearch or the legacy themeConfig.algolia alias to declare non-empty appId, apiKey, and indexName values.

Targeted pattern scopeโ€‹

This rule focuses on docusaurus.config.* files.

It validates the object-literal search config under either of these keys:

  • themeConfig.docsearch
  • themeConfig.algolia

What this rule reportsโ€‹

This rule reports search config objects that omit any of the required Algolia DocSearch keys:

  • appId
  • apiKey
  • indexName

It also reports those keys when they are present as empty strings or invalid literal values.

Why this rule existsโ€‹

Algolia DocSearch wiring is not meaningful without the required connection keys.

Leaving one of them out produces config that looks complete in code review but still cannot power the actual search integration.

This rule keeps the config honest and closer to the documented Docusaurus search setup.

โŒ Incorrectโ€‹

export default {
themeConfig: {
docsearch: {
appId: "APP",
},
},
};

โœ… Correctโ€‹

export default {
themeConfig: {
docsearch: {
appId: "APP",
apiKey: "KEY",
indexName: "docs",
},
},
};

Behavior and migration notesโ€‹

This rule is intentionally report-only.

It cannot safely invent or guess the missing Algolia credentials and index metadata for you.

Additional examplesโ€‹

โŒ Incorrect โ€” empty or invalid literal valuesโ€‹

export default {
themeConfig: {
algolia: {
appId: "",
apiKey: true,
indexName: "docs",
},
},
};

โœ… Correct โ€” dynamic environment-based values are still acceptableโ€‹

const appId = process.env["ALGOLIA_APP_ID"];
const apiKey = process.env["ALGOLIA_API_KEY"];
const indexName = process.env["ALGOLIA_INDEX_NAME"];

export default {
themeConfig: {
docsearch: {
appId,
apiKey,
indexName,
},
},
};

ESLint flat config exampleโ€‹

import docusaurus2 from "eslint-plugin-docusaurus-2";

export default [docusaurus2.configs.recommended];

When not to use itโ€‹

Do not use this rule if your project intentionally keeps incomplete placeholder search config checked in and you do not want linting to report it.

Rule catalog ID: R090

Further readingโ€‹