Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eslint): enhance no-unwanted-polyfill w/ new endpoints #62719

Merged
merged 6 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/script-component/pages/polyfill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(',')
Expand Down
10 changes: 10 additions & 0 deletions test/unit/eslint-plugin-next/no-unwanted-polyfillio.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
Loading