@@ -20,10 +20,6 @@ const findMatchingAlias = (sourcePath, currentFile, options) => {
2020}
2121
2222export default {
23- meta : {
24- type : 'suggestion' ,
25- fixable : true ,
26- } ,
2723 create : context => {
2824 const currentFile = context . getFilename ( )
2925 const folder = P . dirname ( currentFile )
@@ -32,8 +28,8 @@ export default {
3228 const manager = new OptionManager ( )
3329 const babelConfig = manager . init ( {
3430 babelrc : true ,
35- root : folder ,
3631 filename : currentFile ,
32+ root : folder ,
3733 } )
3834 const plugin = babelConfig . plugins | > find ( { key : 'module-resolver' } )
3935 const options = plugin . options
@@ -54,8 +50,8 @@ export default {
5450 )
5551 if ( ! matchingAlias ) {
5652 return context . report ( {
57- node,
5853 message : `Unexpected parent import '${ sourcePath } '. No matching alias found to fix the issue` ,
54+ node,
5955 } )
6056 }
6157 const absoluteImportPath = P . resolve ( folder , sourcePath )
@@ -64,29 +60,33 @@ export default {
6460 | > replace ( / \\ / g, '/' )
6561 } `
6662 return context . report ( {
67- node,
68- message : `Unexpected parent import '${ sourcePath } '. Use '${ rewrittenImport } ' instead` ,
6963 fix : fixer =>
7064 fixer . replaceTextRange (
7165 [ node . source . range [ 0 ] + 1 , node . source . range [ 1 ] - 1 ] ,
7266 rewrittenImport
7367 ) ,
68+ message : `Unexpected parent import '${ sourcePath } '. Use '${ rewrittenImport } ' instead` ,
69+ node,
7470 } )
7571 }
7672 const importWithoutAlias = resolvePath ( sourcePath , currentFile , options )
7773 if ( ! ( importWithoutAlias | > isParentImport ) && hasAlias ) {
7874 return context . report ( {
79- node,
80- message : `Unexpected subpath import via alias '${ sourcePath } '. Use '${ importWithoutAlias } ' instead` ,
8175 fix : fixer =>
8276 fixer . replaceTextRange (
8377 [ node . source . range [ 0 ] + 1 , node . source . range [ 1 ] - 1 ] ,
8478 importWithoutAlias
8579 ) ,
80+ message : `Unexpected subpath import via alias '${ sourcePath } '. Use '${ importWithoutAlias } ' instead` ,
81+ node,
8682 } )
8783 }
8884 return undefined
8985 } ,
9086 }
9187 } ,
88+ meta : {
89+ fixable : true ,
90+ type : 'suggestion' ,
91+ } ,
9292}
0 commit comments