@next/next/no-server-import-in-page ESLint rule throws on test files
See original GitHub issueVerify canary release
- I verified that the issue exists in Next.js canary release
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP Tue Jun 23 12:58:10 UTC 2020
Binaries:
Node: 16.14.2
npm: 8.5.0
Yarn: 3.2.0
pnpm: N/A
Relevant packages:
next: 12.1.6
react: 18.1.0
react-dom: 18.1.0
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
Vercel
Describe the Bug
When a test file in the pages folder exists that imports next/server
, the rule @next/next/no-server-import-in-page
throws during next build
.
Expected Behavior
Test files, either those in __tests__
or file.test.ts
should be ignored for this rule
To Reproduce
package.json
"@typescript-eslint/parser": "^5.25.0",
"eslint": "^8.15.0",
"eslint-config-next": "^12.1.6",
"eslint-plugin-react": "^7.29.4",
.eslint.json
{
"root": true,
"extends": "next/core-web-vitals",
"parser": "@typescript-eslint/parser"
}
Create a file at pages/__tests__/example.test.ts
import "jest";
import { NextRequest } from "next/server";
describe("example", () => {
it("should pass", () => {});
});
Run next build or deploy to Vercel
Issue Analytics
- State:
- Created a year ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
eslint doesn't recognize rule violations in test files and built-in ...
I'm expecting failing tests and linter errors but both are passing... The funny thing: When deleting the lib folder, at least the linter...
Read more >Unit Tests - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Writing custom TypeScript Eslint rules with unit tests for ...
After reading this article you will know how to create a custom Eslint rule in Typescript for Angular project and how to test...
Read more >Guide to JUnit 4 Rules - Baeldung
As we can see, we first define the TemporaryFolder rule tmpFolder. Next, our test method creates a file called test-file.txt in the temporary ......
Read more >Working and unit testing with temporary files in Java
@Rule public TemporaryFolder folder = new TemporaryFolder(); /* executed before every test: create temporary files */ @Before public void ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@aboqasem Please take it.
@Shubhamchinda go for it