Skip to content

noDocumentImportInPage

¥Summary

¥How to configure

biome.json
{
"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