eslint-plugin-import icon indicating copy to clipboard operation
eslint-plugin-import copied to clipboard

[import/no-restricted-paths]: Correctly resolve symlinks in file path

Open bensampaio opened this issue 6 years ago • 7 comments

I have been using this rule for a while in a monorepo and turns out it never worked because it wasn't resolving the symlinks inside node_modules correctly. I am not sure if this is the right location and if I should use the sync or async version of this function but this does solve my problem. Would like to hear what you think of this solution.

bensampaio avatar Jan 24 '19 13:01 bensampaio

Coverage Status

Coverage decreased (-0.5%) to 93.651% when pulling 2506f1a64f7ada9563ea9b2c8e6476ca08e27f68 on bensampaio:patch-1 into bdc05aa1d029b70125ae415e5ca5dca22250858b on benmosher:master.

coveralls avatar Jan 24 '19 14:01 coveralls

This seems great, but now it needs a test :-)

I'm trying to figure out where to place the test but I don't really get how to test this based on what's already there. I guess I should place my test in tests/src/core/resolve.js. However, in this file I can only find tests that use different types of resolvers (whatever those are 🤔).

Do I need to add a test to every it or create a new it? And what should that test do exactly?

How can I test symlinks and make sure they are resolved correctly? I guess, I could add symlinks to the tests/files folder but what then?

Sorry, but I am not that familiar with all concepts in this repo, and can't really figure out what these tests are doing 😩

bensampaio avatar Feb 04 '19 16:02 bensampaio

Hmm - I believe you can git commit an actual symlink, and use that to ensure it's resolved properly?

ljharb avatar Feb 04 '19 22:02 ljharb

@ljharb I added a test as you requested. There are lots of tests failing, is this normal?

bensampaio avatar Feb 06 '19 09:02 bensampaio

Thanks! it's not normal - although there is a few failures on master, they're not the same ones here.

ljharb avatar Feb 07 '19 00:02 ljharb

Ok, I thought the tests failing in master were the same as in my branch but I noticed now that I was wrong. I was really looking forward to having this fixed but this is taking me too much time and I am having quite some difficulties understanding the code base. I don't get why these other tests stopped working.

If you still think my initial solution is not ideal then I would say someone has to continue this or you can close it since I cannot invest more time into trying to fix this. Maybe an issue should be open instead in that case?

bensampaio avatar Feb 08 '19 09:02 bensampaio