question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add eslint rule for importing `next/document` outside of `pages/_document.js`

See original GitHub issue

Feature request

Is your feature request related to a problem? Please describe.

Currently next/document can be imported anywhere even though it should only be used in pages/_document.js and causes issues when imported elsewhere.

Describe the solution you’d like

  • Disallow importing next/document outside of pages/_document.js

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

25reactions
ghostcommented, Aug 31, 2021

I am not importing document anywhere besides in _document, but this lint error is now showing up as I update to the latest version of next. Maybe I updated wrong?

16reactions
kaleabmelkiecommented, Sep 1, 2021

I’m getting a warning for this starting in version 11.1.2 in my pages/_document.tsx file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nextjs - importing next/document outside of pages/_document ...
I am getting this error during build time because of Next.js custom document. So, during the build ...
Read more >
no-restricted-imports - ESLint - Pluggable JavaScript Linter
This rule allows you to specify imports that you don't want to use in your application. It applies to static imports only, not...
Read more >
Basic Features: ESLint - Next.js
These conformance rules help you use Next.js in the optimal way. ... Prevent importing next/document outside of pages/_document.js .
Read more >
eslint-plugin-import - npm
IF YOU ARE USING THIS WITH SUBLIME: see the bottom section for important info. Rules. Static analysis. Ensure imports point to a file/module ......
Read more >
ESLint | WebStorm Documentation - JetBrains
Besides JavaScript and TypeScript, ESLint can be applied to files of ... more information about ESLint configuration files and adding rules.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found