noBeforeInteractiveScriptOutsideDocument
Цей контент ще не доступний вашою мовою.
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/noBeforeInteractiveScriptOutsideDocument - This rule doesn’t have a fix.
- The default severity of this rule is warning.
- This rule belongs to the following domains:
- Sources:
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noBeforeInteractiveScriptOutsideDocument": "error" } } }}Description
Section titled “Description”Prevent usage of next/script’s beforeInteractive strategy outside of pages/_document.js in a Next.js project.
Next.js provides a next/script component to optimize the loading of third-party scripts. Using the beforeInteractive
strategy allows scripts to be preloaded before any first-party code. beforeInteractive scripts must be placed in pages/_document.js.
This rule checks for any usage of the beforeInteractive scripts outside of these files.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”import Script from 'next/script'
export default function Index() { return ( <div> <Script src="https://example.com/script.js" strategy="beforeInteractive" ></Script> </div> )}code-block.jsx:7:7 lint/nursery/noBeforeInteractiveScriptOutsideDocument ━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Don’t use next/script component with the `beforeInteractive` strategy outside of pages/_document.js.
5 │ return (
6 │ <div>
> 7 │ <Script
│ ^^^^^^^
> 8 │ src=“https://example.com/script.js”
> 9 │ strategy=“beforeInteractive”
> 10 │ ></Script>
│ ^
11 │ </div>
12 │ )
ℹ See the Next.js docs for more details.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
import { Html, Head, Main, NextScript } from 'next/document'import Script from 'next/script'
export default function Document() { return ( <Html> <Head /> <body> <Main /> <NextScript /> <Script src="https://example.com/script.js" strategy="beforeInteractive" ></Script> </body> </Html> )}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.