From 8d0623e2948ede5cce00162e00ae7ed2fd54006f Mon Sep 17 00:00:00 2001 From: SukkaW Date: Fri, 1 Mar 2024 18:06:50 +0800 Subject: [PATCH 1/4] feat(eslint): enhance `no-unwanted-polyfill` w/ new endpoints --- .../src/rules/no-unwanted-polyfillio.ts | 7 ++++++- .../eslint-plugin-next/no-unwanted-polyfillio.test.ts | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/eslint-plugin-next/src/rules/no-unwanted-polyfillio.ts b/packages/eslint-plugin-next/src/rules/no-unwanted-polyfillio.ts index 35ebf0acf1107..fc575e9919292 100644 --- a/packages/eslint-plugin-next/src/rules/no-unwanted-polyfillio.ts +++ b/packages/eslint-plugin-next/src/rules/no-unwanted-polyfillio.ts @@ -115,7 +115,12 @@ export = defineRule({ const src = srcNode.value.value if ( src.startsWith('https://cdn.polyfill.io/v2/') || - src.startsWith('https://polyfill.io/v3/') + src.startsWith('https://polyfill.io/v3/') || + // https://community.fastly.com/t/new-options-for-polyfill-io-users/2540 + src.startsWith('https://polyfill-fastly.net/') || + src.startsWith('https://polyfill-fastly.io/') || + // https://blog.cloudflare.com/polyfill-io-now-available-on-cdnjs-reduce-your-supply-chain-risk + src.startsWith('https://cdnjs.cloudflare.com/polyfill/') ) { const featureQueryString = new URL(src).searchParams.get('features') const featuresRequested = (featureQueryString || '').split(',') diff --git a/test/unit/eslint-plugin-next/no-unwanted-polyfillio.test.ts b/test/unit/eslint-plugin-next/no-unwanted-polyfillio.test.ts index f1383c2f67d9c..4871505b4f3c7 100644 --- a/test/unit/eslint-plugin-next/no-unwanted-polyfillio.test.ts +++ b/test/unit/eslint-plugin-next/no-unwanted-polyfillio.test.ts @@ -48,6 +48,16 @@ ruleTester.run('unwanted-polyfillsio', rule, { ); }`, + `import Script from 'next/script'; + + export function MyApp({ Component, pageProps }) { + return ( +
+ +