@@ -24,7 +24,7 @@ let ts;
24
24
const log = debug ( 'eslint-plugin-import:ExportMap' ) ;
25
25
26
26
const exportCache = new Map ( ) ;
27
- const tsConfigCache = new Map ( ) ;
27
+ const tsconfigCache = new Map ( ) ;
28
28
29
29
export default class ExportMap {
30
30
constructor ( path ) {
@@ -361,14 +361,14 @@ ExportMap.for = function (context) {
361
361
362
362
ExportMap . parse = function ( path , content , context ) {
363
363
const m = new ExportMap ( path ) ;
364
- const tsCompilerOptions = getTsCompilerOptions ( ) ;
364
+ const tsconfig = getTsconfig ( ) ;
365
365
366
- const isEsModuleInteropTrue = ! ! tsCompilerOptions . esModuleInterop ;
366
+ const isEsModuleInteropTrue = ! ! ( tsconfig && tsconfig . options && tsconfig . options . esModuleInterop ) ;
367
367
368
368
let ast ;
369
369
let visitorKeys ;
370
370
try {
371
- const result = parse ( path , content , context , { tsCompilerOptions } ) ;
371
+ const result = parse ( path , content , context , { tsconfig } ) ;
372
372
ast = result . ast ;
373
373
visitorKeys = result . visitorKeys ;
374
374
} catch ( err ) {
@@ -550,22 +550,22 @@ ExportMap.parse = function (path, content, context) {
550
550
const source = makeSourceCode ( content , ast ) ;
551
551
552
552
function readTsConfig ( ) {
553
- const tsConfigInfo = tsConfigLoader ( {
553
+ const tsconfigInfo = tsConfigLoader ( {
554
554
cwd :
555
555
( context . parserOptions && context . parserOptions . tsconfigRootDir ) ||
556
556
process . cwd ( ) ,
557
557
getEnv : ( key ) => process . env [ key ] ,
558
558
} ) ;
559
559
try {
560
- if ( tsConfigInfo . tsConfigPath !== undefined ) {
560
+ if ( tsconfigInfo . tsConfigPath !== undefined ) {
561
561
// Projects not using TypeScript won't have `typescript` installed.
562
562
if ( ! ts ) { ts = require ( 'typescript' ) ; }
563
563
564
- const configFile = ts . readConfigFile ( tsConfigInfo . tsConfigPath , ts . sys . readFile ) ;
564
+ const configFile = ts . readConfigFile ( tsconfigInfo . tsConfigPath , ts . sys . readFile ) ;
565
565
return ts . parseJsonConfigFileContent (
566
566
configFile . config ,
567
567
ts . sys ,
568
- dirname ( tsConfigInfo . tsConfigPath ) ,
568
+ dirname ( tsconfigInfo . tsConfigPath ) ,
569
569
) ;
570
570
}
571
571
} catch ( e ) {
@@ -575,17 +575,17 @@ ExportMap.parse = function (path, content, context) {
575
575
return null ;
576
576
}
577
577
578
- function getTsCompilerOptions ( ) {
578
+ function getTsconfig ( ) {
579
579
const cacheKey = hashObject ( {
580
580
tsconfigRootDir : context . parserOptions && context . parserOptions . tsconfigRootDir ,
581
581
} ) . digest ( 'hex' ) ;
582
- let tsConfig = tsConfigCache . get ( cacheKey ) ;
583
- if ( typeof tsConfig === 'undefined' ) {
584
- tsConfig = readTsConfig ( context ) ;
585
- tsConfigCache . set ( cacheKey , tsConfig ) ;
582
+ let tsconfig = tsconfigCache . get ( cacheKey ) ;
583
+ if ( typeof tsconfig === 'undefined' ) {
584
+ tsconfig = readTsConfig ( context ) ;
585
+ tsconfigCache . set ( cacheKey , tsconfig ) ;
586
586
}
587
587
588
- return tsConfig && tsConfig . options || { } ;
588
+ return tsconfig ;
589
589
}
590
590
591
591
ast . body . forEach ( function ( n ) {
0 commit comments