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

Error parsing git format in package.json (pnpm) #3020

Open
nobiit opened this issue Jun 28, 2024 · 4 comments
Open

Error parsing git format in package.json (pnpm) #3020

nobiit opened this issue Jun 28, 2024 · 4 comments

Comments

@nobiit
Copy link

nobiit commented Jun 28, 2024

If package.json has a package installed from git, it will include sha in the path, and this seems to cause an error with the import/namespace rule

Error

admin@NobiPC ➜ materio git:(develop) ✗ eslint src/db/server/server.ts

Oops! Something went wrong! :(

ESLint: 8.57.0

TypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string, Uint8Array, or URL without null bytes. Received '/Users/admin/<user>/<repo>/node_modules/.pnpm/<repo>@[email protected]+<user>+<repo>.git\x00#6affeaa31c0e...
Occurred while linting /Users/admin/nobidev/materio/src/db/server/server.ts:1
Rule: "import/namespace"
    at Object.statSync (node:fs:1657:10)
    at ExportMap.for (/Users/admin/nobidev/materio/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]___pi7blvkmllwoqjthpibydoafqm/node_modules/eslint-plugin-import/lib/ExportMap.js:802:69)
    at ExportMap.get (/Users/admin/nobidev/materio/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]___pi7blvkmllwoqjthpibydoafqm/node_modules/eslint-plugin-import/lib/ExportMap.js:801:465)
    at processBodyStatement (/Users/admin/nobidev/materio/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]___pi7blvkmllwoqjthpibydoafqm/node_modules/eslint-plugin-import/lib/rules/namespace.js:11:40)
    at /Users/admin/nobidev/materio/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]___pi7blvkmllwoqjthpibydoafqm/node_modules/eslint-plugin-import/lib/rules/namespace.js:84:40
    at Array.forEach (<anonymous>)
    at Program (/Users/admin/nobidev/materio/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]___pi7blvkmllwoqjthpibydoafqm/node_modules/eslint-plugin-import/lib/rules/namespace.js:84:18)
    at ruleErrorHandler (/Users/admin/nobidev/materio/node_modules/.pnpm/[email protected]/node_modules/eslint/lib/linter/linter.js:1076:28)
    at /Users/admin/nobidev/materio/node_modules/.pnpm/[email protected]/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)

Other information:

eslint-plugin-import version v2.29.1

{
  "dependencies": {
    "<repo>": "<user>/<repo>#<sha>",
  }
}
import {a,b,c} from '<user>/<repo>';
pnpm install
eslint src/main.ts
@nobiit
Copy link
Author

nobiit commented Jun 28, 2024

It seems to be related to this paragraph.

https://github.com/import-js/eslint-plugin-import/blob/main/src/exportMap/builder.js#L52

I think I need to cut off the fragment in the path?

@nobiit
Copy link
Author

nobiit commented Jun 28, 2024

I see a '\x00' character in the path variable. Does it make sense?

@nobiit
Copy link
Author

nobiit commented Jun 28, 2024

I had success with this little patch, it works for me :D

nobidev@27e8862

It seems the problem comes from eslint-import-resolver-typescript . I hope if someone sees this problem confirm it (to avoid blame on my part)


P/s: eslint-import-resolver-typescript: v3.6.1

@ljharb
Copy link
Member

ljharb commented Jun 28, 2024

It is very very strange to see a null character in any string, especially here.

Can you confirm that eslint-import-resolver-typescript is producing that character? If so, please file an issue there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants