noDocumentImportInPage
Summary
Section titled Summary- Rule available since:
v1.9.4 - Diagnostic Category:
lint/nursery/noDocumentImportInPage - This rule doesn’t have a fix.
- The default severity of this rule is information.
- This rule belongs to the following domains:
- Sources:
- Same as
@next/no-document-import-in-page
- Same as
Description
Section titled DescriptionPrevents importing next/document outside of pages/_document.jsx in Next.js projects.
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
Section titled ExamplesValid
Section titled Validimport { Document, Html } from 'next/document'
export default class MyDocument extends Document { render() { return ( <Html lang="en"> {/* */} </Html> ) }}How to configure
Section titled How to configure{ "linter": { "rules": { "nursery": { "noDocumentImportInPage": "error" } } }}