noUnwantedPolyfillio
¥Summary
-
规则生效日期:
v2.0.0¥Rule available since:
v2.0.0 -
诊断类别:
lint/performance/noUnwantedPolyfillio¥Diagnostic Category:
lint/performance/noUnwantedPolyfillio -
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 warning。
¥The default severity of this rule is warning.
-
此规则属于以下域:
¥This rule belongs to the following domains:
-
来源:
¥Sources:
¥How to configure
{ "linter": { "rules": { "performance": { "noUnwantedPolyfillio": "error" } } }}¥Description
防止从 Polyfill.io 引入重复的 polyfill。
¥Prevent duplicate polyfills from Polyfill.io.
你正在使用来自 Polyfill.io 的 polyfill,并且包含了 Next.js 自带的 polyfill。这会不必要地增加页面大小,从而影响加载性能。
¥You are using polyfills from Polyfill.io and including polyfills already shipped with Next.js. This unnecessarily increases page weight which can affect loading performance.
¥Examples
¥Invalid
<script src='https://polyfill.io/v3/polyfill.min.js?features=AbortController,Object.fromEntries'></script>code-block.jsx:1:13 lint/performance/noUnwantedPolyfillio ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Prevent duplicate polyfills from Polyfill.io
> 1 │ <script src=‘https://polyfill.io/v3/polyfill.min.js?features=AbortController,Object.fromEntries’></script>
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Object.fromEntries is already shipped with Next.js.
ℹ This unnecessarily increases page weight which can affect loading performance.
import NextScript from 'next/script';
export function MyApp({ Component, pageProps }) { return <NextScript src='https://polyfill.io/v3/polyfill.min.js?features=Array.prototype.copyWithin' />}code-block.jsx:4:26 lint/performance/noUnwantedPolyfillio ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Prevent duplicate polyfills from Polyfill.io
3 │ export function MyApp({ Component, pageProps }) {
> 4 │ return <NextScript src=‘https://polyfill.io/v3/polyfill.min.js?features=Array.prototype.copyWithin’ />
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5 │ }
6 │
ℹ Array.prototype.copyWithin is already shipped with Next.js.
ℹ This unnecessarily increases page weight which can affect loading performance.
¥Valid
<> <script src='https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=AbortController'></script> <script src='https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=IntersectionObserver'></script> <Script src='https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=IntersectionObserver' /> <Script src='https://polyfill-fastly.io/v3/polyfill.min.js?features=IntersectionObserver' /></>¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号