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

Add options to enable aliases for siblings and subpaths

Open chapa opened this issue 1 year ago • 12 comments

Hello,

This is a continuation of #130 (which has been closed by its author) and closes #133.

This adds 2 options forSubpaths and forSiblings, to enable aliases for these specific cases. I separated them because I wanted only siblings (import from './foo') and not subpaths (import from ./sub/foo) to be converted to aliases.

I took the liberty to refactor a bit because the previous main conditional branches (if (sourcePath |> isParentImport) and if (!(importWithoutAlias |> isParentImport) && hasAlias)) were making things too convoluted. Feel free to improve/refactor as you wish.

And lastly, I had to create a importType variable to be able to make the tests pass (having Unexpected parent import in the eslint message). I would suggest to remove this word for the sake of simplicity, but that would imply updating the tests and I didn't want to take this decision myself.

chapa avatar Jun 04 '24 17:06 chapa