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 (https://github.com/polyfillpolyfill/polyfill-service/issues/2835, https://github.com/polyfillpolyfill/polyfill-service/issues/2838, https://github.com/alist-org/alist/issues/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>
This commit is contained in:
parent
3ed96f92cb
commit
c206d89ec2
3 changed files with 17 additions and 2 deletions
|
@ -32,7 +32,7 @@ export default function Polyfill() {
|
|||
<>
|
||||
{/* We ensure that intersection observer is available by polyfilling it */}
|
||||
<Script
|
||||
src="https://polyfill.io/v3/polyfill.min.js?features=IntersectionObserverEntry%2CIntersectionObserver"
|
||||
src="https://polyfill-fastly.io/v3/polyfill.min.js?features=IntersectionObserverEntry%2CIntersectionObserver"
|
||||
strategy="beforeInteractive"
|
||||
/>
|
||||
|
||||
|
|
|
@ -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(',')
|
||||
|
|
|
@ -48,6 +48,16 @@ ruleTester.run('unwanted-polyfillsio', rule, {
|
|||
</div>
|
||||
);
|
||||
}`,
|
||||
`import Script from 'next/script';
|
||||
|
||||
export function MyApp({ Component, pageProps }) {
|
||||
return (
|
||||
<div>
|
||||
<Component {...pageProps} />
|
||||
<Script src='https://polyfill-fastly.io/v3/polyfill.min.js?features=IntersectionObserver' />
|
||||
</div>
|
||||
);
|
||||
}`,
|
||||
],
|
||||
|
||||
invalid: [
|
||||
|
|
Loading…
Reference in a new issue