noDocumentImportInPage
¥Summary
-
规则生效日期:
v1.9.4¥Rule available since:
v1.9.4 -
诊断类别:
lint/suspicious/noDocumentImportInPage¥Diagnostic Category:
lint/suspicious/noDocumentImportInPage -
此规则没有修复方案。
¥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": { "suspicious": { "noDocumentImportInPage": "error" } } }}¥Description
防止在 Next.js 项目中从 pages/_document.jsx 之外导入 next/document。
¥Prevents importing next/document outside of pages/_document.jsx in Next.js projects.
next/document 模块用于在 Next.js 中全局自定义文档结构。在 pages/_document.js 之外导入可能会导致意外行为,并破坏框架的某些功能。
¥The next/document module is intended for customizing the document structure globally in Next.js.
Importing it outside of pages/_document.js can cause unexpected behavior and break certain features of the framework.
¥Examples
¥Valid
import { Document, Html } from 'next/document'
export default class MyDocument extends Document { render() { return ( <Html lang="en"> {/* */} </Html> ) }}¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号