Rules
Every rule from ESLint, Oxlint and Biome. Pick a rule to see its example. Reach is the weekly npm downloads of the presets that enable a rule; trend is its change over the last quarter.
Every rule from ESLint, Oxlint and Biome. Pick a rule to see its example. Reach is the weekly npm downloads of the presets that enable a rule; trend is its change over the last quarter.
// pages/index.js
import Script from 'next/script'
export default function HomePage() {
return (
<div>
<Script
src="https://example.com/script.js"
strategy="beforeInteractive" // ❌ Wrong placement
/>
</div>
)
}// pages/_document.js
import Document, { Html, Head, Main, NextScript } from 'next/document'
import Script from 'next/script'
class MyDocument extends Document {
render() {
return (
<Html>
<Head />
<body>
<Script
src="https://example.com/script.js"
strategy="beforeInteractive" // ✅ Correct placement
/>
<Main />
<NextScript />
</body>
</Html>
)
}
}
export default MyDocumentPopular · 1 of 11
Prevent usage of next/script's beforeInteractive strategy outside of pages/_document.js.
// pages/index.js
import Script from 'next/script'
export default function HomePage() {
return (
<div>
<Script
src="https://example.com/script.js"
strategy="beforeInteractive" // ❌ Wrong placement
/>
</div>
)
}// pages/_document.js
import Document, { Html, Head, Main, NextScript } from 'next/document'
import Script from 'next/script'
class MyDocument extends Document {
render() {
return (
<Html>
<Head />
<body>
<Script
src="https://example.com/script.js"
strategy="beforeInteractive" // ✅ Correct placement
/>
<Main />
<NextScript />
</body>
</Html>
)
}
}
export default MyDocument