From 475e67e3d8df7442df43e657be2e27e0897b2a8e Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 27 Jun 2023 21:16:04 +0100 Subject: [PATCH 1/3] fix: Remove `gtm.js` from Google Analytics linting rule Google has multiple products with similar names: the "Google Tag" and "Google Tag Manager". Google Tag Manager uses `gtm.js` whereas the "Google Tag" uses `gtag`. Google Analytics previously used `analytics.js` (<2017) and is now delivered via the "Google Tag". The `SUPPORTED_HTML_CONTENT_URLS` includes `gtm.js` which means when a developer adds Google Tag Manager to their NextJS website, they'll receive the warning and be encouraged to swap from `gtm.js` to `gtag`. However, `gtag` is not compatible with `gtm.js` and making this change will cause very confusing Google Tag Manager behaviour. --- packages/eslint-plugin-next/src/rules/next-script-for-ga.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/eslint-plugin-next/src/rules/next-script-for-ga.ts b/packages/eslint-plugin-next/src/rules/next-script-for-ga.ts index e928e4219a1b0..502ce7aef04d3 100644 --- a/packages/eslint-plugin-next/src/rules/next-script-for-ga.ts +++ b/packages/eslint-plugin-next/src/rules/next-script-for-ga.ts @@ -7,7 +7,6 @@ const SUPPORTED_SRCS = [ ] const SUPPORTED_HTML_CONTENT_URLS = [ 'www.google-analytics.com/analytics.js', - 'www.googletagmanager.com/gtm.js', ] const description = 'Prefer `next/script` component when using the inline script for Google Analytics.' From adac739954e9db3f5fcfb2c8a7940cf19d2b072c Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 27 Jun 2023 21:38:26 +0100 Subject: [PATCH 2/3] test: Remove `gtm.js` test --- .../next-script-for-ga.test.ts | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/test/unit/eslint-plugin-next/next-script-for-ga.test.ts b/test/unit/eslint-plugin-next/next-script-for-ga.test.ts index 709042a0fbc13..6f5949115773c 100644 --- a/test/unit/eslint-plugin-next/next-script-for-ga.test.ts +++ b/test/unit/eslint-plugin-next/next-script-for-ga.test.ts @@ -123,35 +123,6 @@ ruleTester.run('sync-scripts', rule, { }, ], }, - { - code: ` - export class Blah extends Head { - render() { - return ( -
-

Hello title

qqq - {/* Google Tag Manager - Global base code */} -