no-deprecated-google-analytics
Disallow the deprecated Universal Analytics Docusaurus plugin and classic-preset option.
Targeted pattern scopeโ
This rule focuses on docusaurus.config.* files.
It reports deprecated Google Analytics configuration through either of these surfaces:
@docusaurus/plugin-google-analyticsin the top-levelpluginsarraygoogleAnalyticsin@docusaurus/preset-classicoptions
The modern replacement is the Google Tag integration surface:
@docusaurus/plugin-google-gtaggtagin classic-preset options
What this rule reportsโ
This rule reports deprecated Universal Analytics configuration so Docusaurus sites do not keep shipping a plugin path that the upstream docs mark as useless after the Universal Analytics shutdown.
Why this rule existsโ
Docusaurus marks @docusaurus/plugin-google-analytics as deprecated and advises sites to migrate to @docusaurus/plugin-google-gtag for GA4.
Keeping the old plugin shape around is bad public config hygiene because it:
- teaches new maintainers an obsolete config surface
- makes telemetry migrations harder to review later
- leaves dead or misleading analytics setup in a site config that otherwise looks current
โ Incorrectโ
export default {
plugins: ["@docusaurus/plugin-google-analytics"],
};
โ Correctโ
export default {
plugins: ["@docusaurus/plugin-google-gtag"],
};
Behavior and migration notesโ
This rule provides migration suggestions for the simplest structural rewrites it can prove safely:
- rename
@docusaurus/plugin-google-analyticsto@docusaurus/plugin-google-gtag - rename classic-preset
googleAnalyticstogtag
Those suggestions do not attempt to rewrite your tracking IDs.
You still need to review whether the configured IDs and analytics setup are correct for GA4.
Additional examplesโ
โ Incorrect โ deprecated classic-preset optionโ
export default {
presets: [
[
"@docusaurus/preset-classic",
{
googleAnalytics: {
trackingID: "UA-141789564-1",
anonymizeIP: true,
},
},
],
],
};
โ
Correct โ classic-preset gtagโ
export default {
presets: [
[
"@docusaurus/preset-classic",
{
gtag: {
trackingID: "G-999X9XX9XX",
anonymizeIP: true,
},
},
],
],
};
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 only if you are intentionally preserving deprecated analytics config during a short-lived migration and you do not want linting to flag it yet.
Rule catalog ID: R088