Closed parvezalisha closed 5 years ago
@parvezalisha You are right. The resolver will find all the "helpers" words in package path and replace it with its alias. If you just want to make alias for "src/helpers", use ['^helpers$', 'src/helpers']
instead.
My issue is resolved by changing the order of the paths. If i resolve src/abcd/helpers/ first then src/helpers/ doesn't throw errors. Thanks
Can this be mentioned in the usage documentation?
@parvezalisha Actually, I still don't know quite well what your configuration of alias resolver is, can you post it here so that I can be sure that description of the thrid note item in the usage section doesn't cover this situation. thanks.
@johvin I have a folder structure like:
src/helpers/
src/abcd/helpers/
and if i try to map it as below:
map: [
['helpers', path.resolve(__dirname, './src/helpers')],
['abcd', path.resolve(__dirname, './src/abcd/helpers')],
],
eslint throws unresolved path errors because the plugin tries to resolve src/abcd/helpers to the first helpers path. But if i change the order to:
map: [
['abcd', path.resolve(__dirname, './src/abcd/helpers')],
['helpers', path.resolve(__dirname, './src/helpers')],
],
everything works fine because now src/abcd/helpers gets resolved first and does not conflict with the other 'helpers' mapping.
@parvezalisha Actually, description of the fourth note item in the usage section just explains the importance of the config rules' order, but maybe not clear enough for your situation. I will improve the notes with this issue soon. Many thanks.
@parvezalisha After much thought, I think your problem is caused by a bug of this plugin, not the order of configuration. The bug, actually, is specially designed as a feature to resolve path/to/file
to path/from/file
with the configuration of ['to', 'from']
, but it now seems problematic. I have fixed it in version 1.1.2
and welcome to upgrade to that. Sorry for the trouble to you and thanks.
@johvin it works fine now. Thanks.
Hi, I have a folder structure like:
If i have an alias "helpers" for src/helpers then the resolver tries to resolve src/abcs/helpers to that alias too and then eslint throws import/no-unresolved.
Wanted to know if i am doing something wrong or if this is not supported.
Thanks