Skip to content
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

lint TP1006 #65280

Open
artola opened this issue May 2, 2024 · 1 comment
Open

lint TP1006 #65280

artola opened this issue May 2, 2024 · 1 comment
Labels
bug Issue was opened via the bug report template. linear: turbopack Confirmed issue that is tracked by the Turbopack team. Turbopack Related to Turbopack with Next.js.

Comments

@artola
Copy link

artola commented May 2, 2024

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/goofy-ritchie-39dq82

To Reproduce

  1. start the app (next dev --turbo) or yarn dev (already modified for turbo).
  2. the app contains 2 links for 2 routes, click to navigate:
  • /foo = the console has NO ERROR printed
import { NextResponse, type NextRequest } from "next/server";
import path from "node:path";

export async function GET() {
  const p = path.resolve("./foo.txt");

  return new NextResponse("NO ERROR :)");
}
  • /bar = the console has ERROR printed
import { NextResponse, type NextRequest } from "next/server";
import path from "node:path";

function getPath(target: string) {
  return path.resolve(target);
}

export async function GET() {
  const p = getPath("./foo.txt");

  return new NextResponse("ERROR :(");
}

Note: Even if the function getPath is defined within the GET still the linter show errors:

 ✓ Compiled /bar in 156ms
 ⚠ ./app/bar/route.ts:5:10
lint TP1006 path.resolve(???*0*) is very dynamic
  3 |
  4 | function getPath(target: string) {
> 5 |   return path.resolve(target);
    |          ^^^^^^^^^^^^^^^^^^^^
  6 | }
  7 |
  8 | export async function GET() {

- *0* arguments[0]
  ⚠️  function calls are not analysed yet


 GET /bar 200 in 205ms
 ⚠ ./app/bar/route.ts:5:10
lint TP1006 path.resolve(???*0*) is very dynamic
  3 |
  4 | function getPath(target: string) {
> 5 |   return path.resolve(target);
    |          ^^^^^^^^^^^^^^^^^^^^
  6 | }
  7 |
  8 | export async function GET() {

- *0* arguments[0]
  ⚠️  function calls are not analysed yet


 GET /bar 200 in 27ms

Current vs. Expected behavior

Linter should understand these calls, otherwise I should know what to do :)

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 4102
  Available CPU cores: 2
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 14.3.0-canary.36 // Latest available version is detected (14.3.0-canary.36).
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.3
Next.js Config:
  output: N/A
Done in 1.76s.

Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

Same behavior in latest as in canary 36.

PACK-3045

@artola artola added the bug Issue was opened via the bug report template. label May 2, 2024
@github-actions github-actions bot added the Turbopack Related to Turbopack with Next.js. label May 2, 2024
@timneutkens timneutkens added the linear: turbopack Confirmed issue that is tracked by the Turbopack team. label May 7, 2024
@artola

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. linear: turbopack Confirmed issue that is tracked by the Turbopack team. Turbopack Related to Turbopack with Next.js.
Projects
None yet
Development

No branches or pull requests

2 participants