Skip to content

Commit c206d89

Browse files
SukkaWstyfle
andauthored
feat(eslint): enhance no-unwanted-polyfill w/ new endpoints (#62719)
The PR adds the new `polyfill.io` instance endpoint (from Fastly and Cloudflare) to the `eslint-plugin-next`'s `no-unwanted-polyfillio` rules, so these new endpoints can be detected by the rule. --- `polyfill.io` was acquired by **a China-based CDN company** "Funnull", see [the announcement from the `polyfill.io` domain owner's Twitter](https://x.com/JakeDChampion/status/1761315227008643367) and https://github.com/polyfillpolyfill/polyfill-service/issues/2834. Despite Funnull's claims of operating in the United States, the predominance of Simplified Chinese on its website suggests otherwise, and it turns out that **"Funnull" is notorious for providing service for the betting and pornography industries**. [The original creator of the `polyfill.io` has voiced his concern on Twitter](https://twitter.com/triblondon/status/1761852117579427975). And since the acquisition, numerous issues have emerged (polyfillpolyfill/polyfill-service#2835, polyfillpolyfill/polyfill-service#2838, AlistGo/alist#6100), rendering the `polyfill.io` service **extremely unstable**. Since then, Fastly ([Announcement](https://community.fastly.com/t/new-options-for-polyfill-io-users/2540)) and Cloudflare ([Announcement](https://blog.cloudflare.com/polyfill-io-now-available-on-cdnjs-reduce-your-supply-chain-risk)) has hosted their own instances of `polyfill.io` service. --------- Co-authored-by: Steven <steven@ceriously.com>
1 parent 3ed96f9 commit c206d89

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

examples/script-component/pages/polyfill.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default function Polyfill() {
3232
<>
3333
{/* We ensure that intersection observer is available by polyfilling it */}
3434
<Script
35-
src="https://polyfill.io/v3/polyfill.min.js?features=IntersectionObserverEntry%2CIntersectionObserver"
35+
src="https://polyfill-fastly.io/v3/polyfill.min.js?features=IntersectionObserverEntry%2CIntersectionObserver"
3636
strategy="beforeInteractive"
3737
/>
3838

packages/eslint-plugin-next/src/rules/no-unwanted-polyfillio.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,12 @@ export = defineRule({
115115
const src = srcNode.value.value
116116
if (
117117
src.startsWith('https://cdn.polyfill.io/v2/') ||
118-
src.startsWith('https://polyfill.io/v3/')
118+
src.startsWith('https://polyfill.io/v3/') ||
119+
// https://community.fastly.com/t/new-options-for-polyfill-io-users/2540
120+
src.startsWith('https://polyfill-fastly.net/') ||
121+
src.startsWith('https://polyfill-fastly.io/') ||
122+
// https://blog.cloudflare.com/polyfill-io-now-available-on-cdnjs-reduce-your-supply-chain-risk
123+
src.startsWith('https://cdnjs.cloudflare.com/polyfill/')
119124
) {
120125
const featureQueryString = new URL(src).searchParams.get('features')
121126
const featuresRequested = (featureQueryString || '').split(',')

test/unit/eslint-plugin-next/no-unwanted-polyfillio.test.ts

+10
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ ruleTester.run('unwanted-polyfillsio', rule, {
4848
</div>
4949
);
5050
}`,
51+
`import Script from 'next/script';
52+
53+
export function MyApp({ Component, pageProps }) {
54+
return (
55+
<div>
56+
<Component {...pageProps} />
57+
<Script src='https://polyfill-fastly.io/v3/polyfill.min.js?features=IntersectionObserver' />
58+
</div>
59+
);
60+
}`,
5161
],
5262

5363
invalid: [

0 commit comments

Comments
 (0)