@@ -10,7 +10,6 @@ const runTest = config => () => {
1010 const filename = config . filename || 'index.js'
1111 const output = config . output || config . code
1212 const messages = config . messages || [ ]
13- const options = config . options || [ ]
1413 return withLocalTmpDir ( async ( ) => {
1514 await outputFiles ( config . files )
1615 const linter = new Linter ( )
@@ -21,7 +20,7 @@ const runTest = config => () => {
2120 ecmaVersion : 2015 ,
2221 } ,
2322 rules : {
24- 'self/self' : [ 1 , ... options ] ,
23+ 'self/self' : 'error' ,
2524 } ,
2625 }
2726 const lintedMessages = linter . verify ( config . code , lintingConfig , {
@@ -37,9 +36,19 @@ const runTest = config => () => {
3736
3837export default {
3938 external : {
39+ files : {
40+ '.babelrc.json' : JSON . stringify ( {
41+ plugins : [ [ 'module-resolver' , { alias : { '@' : '.' } } ] ] ,
42+ } ) ,
43+ } ,
4044 code : "import foo from 'foo'" ,
4145 } ,
4246 parent : {
47+ files : {
48+ '.babelrc.json' : JSON . stringify ( {
49+ plugins : [ [ 'module-resolver' , { alias : { '@' : '.' } } ] ] ,
50+ } ) ,
51+ } ,
4352 code : "import foo from '../foo/bar'" ,
4453 filename : P . join ( 'sub' , 'index.js' ) ,
4554 messages : [
@@ -48,26 +57,42 @@ export default {
4857 output : "import foo from '@/foo/bar'" ,
4958 } ,
5059 'parent in-between folder' : {
60+ files : {
61+ '.babelrc.json' : JSON . stringify ( {
62+ plugins : [ [ 'module-resolver' , { alias : { '@' : '.' } } ] ] ,
63+ } ) ,
64+ } ,
5165 code : "import foo from '../foo'" ,
5266 filename : P . join ( 'sub' , 'sub' , 'index.js' ) ,
5367 messages : [ "Unexpected parent import '../foo'. Use '@/sub/foo' instead" ] ,
5468 output : "import foo from '@/sub/foo'" ,
5569 } ,
5670 'parent import but no matching alias' : {
71+ files : {
72+ '.babelrc.json' : JSON . stringify ( {
73+ plugins : [ [ 'module-resolver' , { alias : { '@' : '.' } } ] ] ,
74+ } ) ,
75+ } ,
5776 code : "import foo from '../../foo'" ,
5877 messages : [
5978 "Unexpected parent import '../../foo'. No matching alias found to fix the issue" ,
6079 ] ,
6180 } ,
6281 'alias parent' : {
6382 files : {
83+ '.babelrc.json' : JSON . stringify ( {
84+ plugins : [ [ 'module-resolver' , { alias : { '@' : '.' } } ] ] ,
85+ } ) ,
6486 'foo.js' : '' ,
6587 } ,
6688 code : "import foo from '@/foo'" ,
6789 filename : 'sub/index.js' ,
6890 } ,
6991 'alias subpath' : {
7092 files : {
93+ '.babelrc.json' : JSON . stringify ( {
94+ plugins : [ [ 'module-resolver' , { alias : { '@' : '.' } } ] ] ,
95+ } ) ,
7196 'foo.js' : '' ,
7297 } ,
7398 code : "import foo from '@/foo'" ,
@@ -78,17 +103,22 @@ export default {
78103 } ,
79104 scoped : {
80105 files : {
106+ '.babelrc.json' : JSON . stringify ( {
107+ plugins : [ [ 'module-resolver' , { alias : { '@' : '.' } } ] ] ,
108+ } ) ,
81109 'foo.js' : '' ,
82110 } ,
83111 code : "import foo from '@foo/bar'" ,
84112 } ,
85113 'cwd: subfolder' : {
86114 files : {
115+ '.babelrc.json' : JSON . stringify ( {
116+ plugins : [ [ 'module-resolver' , { alias : { '@' : '.' } , cwd : 'sub' } ] ] ,
117+ } ) ,
87118 'sub/foo.js' : '' ,
88119 } ,
89120 code : "import foo from '../foo'" ,
90121 filename : P . join ( 'sub' , 'sub' , 'index.js' ) ,
91- options : [ { cwd : 'sub' } ] ,
92122 messages : [ "Unexpected parent import '../foo'. Use '@/foo' instead" ] ,
93123 output : "import foo from '@/foo'" ,
94124 } ,
@@ -97,24 +127,31 @@ export default {
97127 sub : {
98128 'foo.js' : '' ,
99129 'package.json' : JSON . stringify ( { } ) ,
130+ '.babelrc.json' : JSON . stringify ( {
131+ plugins : [
132+ [ 'module-resolver' , { alias : { '@' : '.' } , cwd : 'packagejson' } ] ,
133+ ] ,
134+ } ) ,
100135 } ,
101136 } ,
102137 code : "import foo from '../foo'" ,
103138 filename : P . join ( 'sub' , 'sub' , 'index.js' ) ,
104- options : [ { cwd : 'packagejson' } ] ,
105139 messages : [ "Unexpected parent import '../foo'. Use '@/foo' instead" ] ,
106140 output : "import foo from '@/foo'" ,
107141 } ,
108142 'cwd: babelrc' : {
109143 files : {
110144 sub : {
111145 'foo.js' : '' ,
112- '.babelrc.json' : JSON . stringify ( { } ) ,
146+ '.babelrc.json' : JSON . stringify ( {
147+ plugins : [
148+ [ 'module-resolver' , { alias : { '@' : '.' } , cwd : 'babelrc' } ] ,
149+ ] ,
150+ } ) ,
113151 } ,
114152 } ,
115153 code : "import foo from '../foo'" ,
116154 filename : P . join ( 'sub' , 'sub' , 'index.js' ) ,
117- options : [ { cwd : 'babelrc' } ] ,
118155 messages : [ "Unexpected parent import '../foo'. Use '@/foo' instead" ] ,
119156 output : "import foo from '@/foo'" ,
120157 } ,
0 commit comments