useInlineScriptId
このコンテンツはまだ日本語訳がありません。
Summary
Section titled “Summary”- Rule available since:
v2.3.12 - Diagnostic Category:
lint/nursery/useInlineScriptId - This rule doesn’t have a fix.
- The default severity of this rule is error.
- This rule belongs to the following domains:
- Sources:
- Same as
@next/next/inline-script-id
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "useInlineScriptId": "error" } } }}Description
Section titled “Description”Enforce id attribute on next/script components with inline content or dangerouslySetInnerHTML.
Using inline scripts or dangerouslySetInnerHTML in next/script components requires an id attribute to ensure that Next.js can track and optimize them correctly.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”import Script from 'next/script'
export default function Page() { return ( <Script>{`console.log('Hello world!');`}</Script> )}code-block.jsx:5:6 lint/nursery/useInlineScriptId ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ next/script components have inline content or `dangerouslySetInnerHTML` without id attribute.
3 │ export default function Page() {
4 │ return (
> 5 │ <Script>{`console.log(‘Hello world!’);`}</Script>
│ ^^^^^^^^
6 │ )
7 │ }
ℹ Next.js requires id attribute to track and optimize inline scripts. Without it, performance issues may occur.
ℹ 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 Script from 'next/script'
export default function Page() { return ( <Script dangerouslySetInnerHTML={{ __html: `console.log('Hello world!');` }} /> )}code-block.jsx:5:6 lint/nursery/useInlineScriptId ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ next/script components have inline content or `dangerouslySetInnerHTML` without id attribute.
3 │ export default function Page() {
4 │ return (
> 5 │ <Script dangerouslySetInnerHTML={{ __html: `console.log(‘Hello world!’);` }} />
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6 │ )
7 │ }
ℹ Next.js requires id attribute to track and optimize inline scripts. Without it, performance issues may occur.
ℹ 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 Script from 'next/script'
export default function Page() { return ( <Script id="my-script">{`console.log('Hello world!');`}</Script> )}import Script from 'next/script'
export default function Page() { return ( <Script id="my-script" dangerouslySetInnerHTML={{ __html: `console.log('Hello world!');` }} /> )}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.