Skip to main content

prefer-theme-config-docsearch

Prefer themeConfig.docsearch for sites that configure the standalone DocSearch adapter.

Targeted pattern scopeโ€‹

This rule checks docusaurus.config.* files that statically register @docsearch/docusaurus-adapter in plugins or themes. Docusaurus's built-in Algolia integration reads themeConfig.algolia. The rule leaves that key alone on sites that rely on the classic preset's built-in search, explicitly register @docusaurus/theme-search-algolia, or have no recognized adapter registration.

What this rule reportsโ€‹

With the standalone adapter configured, the rule reports:

  • themeConfig.algolia in place of themeConfig.docsearch
  • both themeConfig.docsearch and themeConfig.algolia in the same configuration

Why this rule existsโ€‹

The standalone adapter uses themeConfig.docsearch. Version 4 also accepts themeConfig.algolia as a legacy alias. Changing the key on a site that uses the built-in integration can remove search because the classic preset loads the built-in search theme when themeConfig.algolia is present.

โŒ Incorrectโ€‹

export default {
plugins: ["@docsearch/docusaurus-adapter"],
themeConfig: {
algolia: {
appId: "APP",
apiKey: "KEY",
indexName: "docs",
},
},
};

โœ… Correctโ€‹

export default {
plugins: ["@docsearch/docusaurus-adapter"],
themeConfig: {
docsearch: {
appId: "APP",
apiKey: "KEY",
indexName: "docs",
},
},
};

Behavior and migration notesโ€‹

The autofix renames the property and preserves its value. When both keys are present, the rule reports the conflict and leaves both values for you to resolve.

The examples use DocSearch v4 options. Upgrading to v5 also requires updating the options, such as replacing indexName with indices.

Additional examplesโ€‹

โœ… Correct โ€” built-in Algolia search with the classic presetโ€‹

export default {
presets: ["classic"],
themeConfig: {
algolia: {
appId: "APP",
apiKey: "KEY",
indexName: "docs",
},
},
};

ESLint flat config exampleโ€‹

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

export default [docusaurus2.configs.recommended];

When not to use itโ€‹

Disable the rule if a DocSearch v4 site deliberately keeps the legacy alias during a migration.

Rule catalog ID: R089

Further readingโ€‹