File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -118,8 +118,12 @@ export default {
118118 } )
119119 }
120120
121+ const isDirectAlias =
122+ options . alias | > keys | > some ( alias => sourcePath === alias )
123+
121124 const shouldUnalias =
122125 hasAlias &&
126+ ! isDirectAlias &&
123127 ( ( ( importWithoutAlias | > isSiblingImport ) && ! options . forSiblings ) ||
124128 ( ( importWithoutAlias | > isSubpathImport ) && ! options . forSubpaths ) )
125129 if ( shouldUnalias ) {
Original file line number Diff line number Diff line change @@ -245,6 +245,32 @@ export default tester(
245245 output : "import foo from '@/foo'" ,
246246 } )
247247 } ,
248+ 'direct import of an alias from a parent' : async ( ) => {
249+ await outputFiles ( {
250+ '.babelrc.json' : JSON . stringify ( {
251+ plugins : [
252+ [
253+ packageName `babel-plugin-module-resolver` ,
254+ { alias : { '@components' : './sub/components' } } ,
255+ ] ,
256+ ] ,
257+ } ) ,
258+ } )
259+ expect ( lint ( "import { foo } from '@components'" ) . messages ) . toEqual ( [ ] )
260+ } ,
261+ 'direct import of an alias from a sibling' : async ( ) => {
262+ await outputFiles ( {
263+ '.babelrc.json' : JSON . stringify ( {
264+ plugins : [
265+ [
266+ packageName `babel-plugin-module-resolver` ,
267+ { alias : { '@components' : './components' } } ,
268+ ] ,
269+ ] ,
270+ } ) ,
271+ } )
272+ expect ( lint ( "import { foo } from '@components'" ) . messages ) . toEqual ( [ ] )
273+ } ,
248274 'direct import of an alias from another one' : async ( ) => {
249275 await outputFiles ( {
250276 '.babelrc.json' : JSON . stringify ( {
You can’t perform that action at this time.
0 commit comments