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

Include . resolves to an empty string #88

Open
1 of 2 tasks
carlocorradini opened this issue Feb 21, 2025 · 4 comments
Open
1 of 2 tasks

Include . resolves to an empty string #88

carlocorradini opened this issue Feb 21, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@carlocorradini
Copy link

Problem

If include contains . (in our case ../.), it is incorrectly resolved to an empty string ("").

We (from eslint-import-resolver-typescript) are trying to solve issue 363 where react-parallax-tilt has ../. in its include array (see tsconfig.dev.json#L5)

The call to getTsconfig correctly handles all other properties (i.e. extends, etc...), however the include entry that formerly included ../. now has an empty string ("").

This was noticed by @pralkarz in comment import-js/eslint-import-resolver-typescript#363 (comment)

PS: To reproduce:

  1. yarn --immutable
  2. yarn run build
  3. yarn run bug
  4. Print tsconfigResult where include: [ '' ]

Expected behavior

The include path should be correctly translated into a non-empty, valid string path/glob.

Minimal reproduction URL

https://github.com/carlocorradini/eslint-import-resolver-typescript/tree/bug

Version

v4.10.0

Node.js version

v20.16.0

Package manager

npm

Operating system

Windows

Bugs are expected to be fixed by those affected by it

  • I'm interested in working on this issue

Compensating engineering work financially will speed up resolution

  • I'm willing to offer financial support
@pralkarz
Copy link

I dug into this a bit, and it seems to stem from how path.relative behaves when both passed paths are the same:
If from and to each resolve to the same path (after calling path.resolve() on each), a zero-length string is returned. (https://nodejs.org/api/path.html#pathrelativefrom-to)

This is indeed what happens in react-parallax-tilt:
Image

A simple fix could be to return . instead when an empty string is returned from path.relative, but there might be some edge cases I'm missing.

CC: @carlocorradini @mkosir

@privatenumber
Copy link
Owner

Would one of you be able to provide a minimal reproduction or a failing test?

@carlocorradini
Copy link
Author

carlocorradini commented Feb 22, 2025

Would one of you be able to provide a minimal reproduction or a failing test?

https://github.com/carlocorradini/eslint-import-resolver-typescript/tree/bug

Both the repro and commands are available in this issue's first comment 👍

@pralkarz
Copy link

Would one of you be able to provide a minimal reproduction or a failing test?

I also created a very tiny repro here: https://github.com/pralkarz/get-tsconfig-88-repro.

  1. npm i
  2. node repro.mjs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants