New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
False positive for no-document-import-in-page
#28596
Comments
I'm getting the same eslint error after updating next.js from 11.1.0 to 11.1.1. I don't recall getting this error when I was on next.js 11.1.0. In my case, the custom other npm packages I updated that might cause this error:
Also, I should mention that I have upgraded to the latest typescript 4.4.2. And it seems upgrading |
Yeah I just started getting this when I went to update to next 11.1.1. It doesn't like/consider |
this is not just a problem for I wonder if this is caused by the recent typescript version update and eslint and/or typescript @types not yet being updated with the latest changes to typescript. 🤷♂️ |
Is there a reason why you are creating a |
Although I do agree that creating a |
@samsisle It shouldn't matter--this issue is a bug no matter what reason I'm doing it for, because it is a valid location that makes sense and that Next.js recognizes. Regardless, my personal (and again, irrelevant) reason is just for the sake of consistency, since most other pages and components in my project need to be in a folder in order to be able to have a Additionally, because folders are sorted in VS Code by default independently from files (which I like), Again though, none of that matters anyway, as this is a trivial bug which should be fixed either way. |
I'm using on Windows yarn v3, next 11.1.2 and typescript 4.4.2. Same problem after these updates:
Edit: |
I get the same false positive when using npm All I did was update from Next v11.1.0 to Next 11.1.2 and update eslint-config-next from 11.1.0 to 11.1.2. I'm on Windows 10, using node v16.7.0. |
It is introduced by v11.1.1-canary.17 with:
No problems with v11.1.1-canary.16. |
I got this issue with Next being version |
Thanks for logging this issue @GrantGryczan, and thanks to everyone else sharing their details which always helps. For some reason, I can't reproduce this. I've tried next & eslint-config-next versions 11.1.0, 11.1.1, and 11.1.2 and it seems to work fine . I've even tried spinning up a new application and still couldn't reproduce it:
I've also tried variations of the document file (
That's the only major change that's been introduced to the file since 11.1.0, but doesn't seem to be causing the error on my machine. I can revert the changes if necessary though. Can anyone share their repository of where they're seeing this issue if it's public? Not sure if I'm missing something obvious here 😅 . Also, I would suggest running |
@housseindjirdeh - I think you need to create a TypeScript project with create-next-app (i.e., |
@housseindjirdeh - I've created a minimal reproducible repo at https://github.com/kimbaudi/test-next-app that results in the error. If you look at to see the error, just clone the repo and Failed to compile.
./src/pages/_document.tsx
1:1 Error: next/document should not be imported outside of pages/_document.js. See https://nextjs.org/docs/messages/no-document-import-in-page. @next/next/no-document-import-in-page
|
Steps to reproduce:
import Document, { Html, Head, Main, NextScript } from 'next/document'
class MyDocument extends Document {
render() {
return (
<Html>
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
}
export default MyDocument
extends:
- next
|
@kimbaudi Unable to replicate with your repro 🤔 Unable to reproduce with the Yarn example above as well → |
Let me try on my Ubuntu VM, maybe this issue only affects Windows users |
@kimbaudi That was for the other repro. Here is yours → |
@housseindjirdeh @samsisle - I can confirm that this issue only affects Windows users. I just tried on my Ubuntu VM and am able to build without error. |
Can confirm as well that it's reproducible on Windows. Letting the Next.js team know! |
Huh, why was this reopened? |
Update:Seems like I'm going blind. This was fixed in #28745 and can confirm it works on Old post:I'm hitting this error while trying to add Tailwind support to Create Next Stack. I have ensured the import is not present in any other files. I'm using OS: Windows 10 Pro Relevant dependencies:
I am also using
But I assume that's irrelevant. |
Update:Seems like I'm going blind. This was fixed in #28745 and can confirm it works on Old post:My guess is that the change to test for I believe the solution would be to keep the change from
to
but revert the change from
to
|
This is fixed in #28745 and works in |
Getting this same issue in |
same with 11.1.3-canary.15 |
Temporary fix for me was to downgrade |
@darrylhuffman @realdocweird @ivenuss Are you using Windows and have both the Let me know if you're still seeing the issue and I can help investigate why it's still happening |
i've tryed the canary.7 and .15. I'm nooby i didn't understand very well how to |
TLDR; it works for me (on both v11.1.3-canary.18 and v11.1.2) I no longer get this error in either v11.1.3-canary.18 or v11.1.2. I thought I would still get this error on v11.1.2, but I don't anymore. The important thing I did was run Steps I took:
Update: |
It now works for me on next & eslint-config-next v11.1.3-canary.18 The problem I had was that I was running It's one of those silly mistakes you might do if you're not paying attention :p |
This issue occurred in |
Im using the same version but still the same issues |
To everyone who still has the issue after upgrading to both Next.js and Eslint >= v11.1.3-canary.18 - run
Also, I had run
|
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
What version of Next.js are you using?
11.1.0
What version of Node.js are you using?
14.17.1
What browser are you using?
Chrome
What operating system are you using?
Windows
How are you deploying your application?
next start
Describe the Bug
The
@next/next/no-document-import-in-page
ESLint rule displays an error in a custom_document
if it is located atpages/_document/index.js
,pages/_document/index.jsx
,pages/_document/index.ts
, orpages/_document/index.tsx
.Expected Behavior
I expect there to be no ESLint error from the
@next/next/no-document-import-in-page
rule in all valid custom_document
file locations.To Reproduce
Create
pages/_document/index.jsx
as follows with the ESLint rule enabled.This results in an error on line 1.
The text was updated successfully, but these errors were encountered: