Fix path transformation for dot files that are sibling to current file#253
Conversation
Codecov Report
|
|
Ping @tleunen |
|
Please address the comments I left so we can move forward with this PR. |
|
@fatfisz Maybe I'm looking in the wrong place, but I don't see any comments? |
|
That's strange, I'll try to make them visible to you too somehow (I can still see them). |
|
I don't see any comment neither @fatfisz. Did you forget to publish them? :) |
| } | ||
|
|
||
| export function isRelativePath(nodePath) { | ||
| return nodePath.match(/\.?\.\//); |
There was a problem hiding this comment.
Shouldn't this be /^\.?\.\//? Otherwise it will match foo./bar too. Could you add a test for that just in case of a regression?
| root: './test/fakepath/', | ||
| alias: { | ||
| constants: './test/testproject/src/constants', | ||
| src: './test/testproject/src', |
There was a problem hiding this comment.
Not sure, might have snuck in from another change, reverting.
| plugins: [ | ||
| [plugin, { | ||
| alias: { | ||
| elintrc: './.eslintrc', |
There was a problem hiding this comment.
This test is ok, but could you add one more regression test in which the alias itself starts with a dot? I'm thinking of '.babel': 'babel-core'.
|
Wow, I didn't know that I had to do that. Sorry for the confusion 🙏 |
|
Looks great! I'll go ahead and merge. Thanks again for your contribution @amosyuen! |
Currently the code checks for a relative path by checking if it starts with a dot. This incorrectly identifies a path resolved dot file e.g.
.eslintrcas a relative path. So it does NOT transform the path to relative path such as./.eslintric. This is fixed by using a regex that checks for a./or../at the start of the path.